babylon.module.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753
  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. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Returns a Color3 value containing a white color
  539. * @returns a new Color3 object
  540. */
  541. static White(): Color3;
  542. /**
  543. * Returns a Color3 value containing a purple color
  544. * @returns a new Color3 object
  545. */
  546. static Purple(): Color3;
  547. /**
  548. * Returns a Color3 value containing a magenta color
  549. * @returns a new Color3 object
  550. */
  551. static Magenta(): Color3;
  552. /**
  553. * Returns a Color3 value containing a yellow color
  554. * @returns a new Color3 object
  555. */
  556. static Yellow(): Color3;
  557. /**
  558. * Returns a Color3 value containing a gray color
  559. * @returns a new Color3 object
  560. */
  561. static Gray(): Color3;
  562. /**
  563. * Returns a Color3 value containing a teal color
  564. * @returns a new Color3 object
  565. */
  566. static Teal(): Color3;
  567. /**
  568. * Returns a Color3 value containing a random color
  569. * @returns a new Color3 object
  570. */
  571. static Random(): Color3;
  572. }
  573. /**
  574. * Class used to hold a RBGA color
  575. */
  576. export class Color4 {
  577. /**
  578. * Defines the red component (between 0 and 1, default is 0)
  579. */
  580. r: number;
  581. /**
  582. * Defines the green component (between 0 and 1, default is 0)
  583. */
  584. g: number;
  585. /**
  586. * Defines the blue component (between 0 and 1, default is 0)
  587. */
  588. b: number;
  589. /**
  590. * Defines the alpha component (between 0 and 1, default is 1)
  591. */
  592. a: number;
  593. /**
  594. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  595. * @param r defines the red component (between 0 and 1, default is 0)
  596. * @param g defines the green component (between 0 and 1, default is 0)
  597. * @param b defines the blue component (between 0 and 1, default is 0)
  598. * @param a defines the alpha component (between 0 and 1, default is 1)
  599. */
  600. constructor(
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r?: number,
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g?: number,
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b?: number,
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a?: number);
  617. /**
  618. * Adds in place the given Color4 values to the current Color4 object
  619. * @param right defines the second operand
  620. * @returns the current updated Color4 object
  621. */
  622. addInPlace(right: DeepImmutable<Color4>): Color4;
  623. /**
  624. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  625. * @returns the new array
  626. */
  627. asArray(): number[];
  628. /**
  629. * Stores from the starting index in the given array the Color4 successive values
  630. * @param array defines the array where to store the r,g,b components
  631. * @param index defines an optional index in the target array to define where to start storing values
  632. * @returns the current Color4 object
  633. */
  634. toArray(array: number[], index?: number): Color4;
  635. /**
  636. * Determines equality between Color4 objects
  637. * @param otherColor defines the second operand
  638. * @returns true if the rgba values are equal to the given ones
  639. */
  640. equals(otherColor: DeepImmutable<Color4>): boolean;
  641. /**
  642. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  643. * @param right defines the second operand
  644. * @returns a new Color4 object
  645. */
  646. add(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. subtract(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  655. * @param right defines the second operand
  656. * @param result defines the Color4 object where to store the result
  657. * @returns the current Color4 object
  658. */
  659. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  660. /**
  661. * Creates a new Color4 with the current Color4 values multiplied by scale
  662. * @param scale defines the scaling factor to apply
  663. * @returns a new Color4 object
  664. */
  665. scale(scale: number): Color4;
  666. /**
  667. * Multiplies the current Color4 values by scale and stores the result in "result"
  668. * @param scale defines the scaling factor to apply
  669. * @param result defines the Color4 object where to store the result
  670. * @returns the current unmodified Color4
  671. */
  672. scaleToRef(scale: number, result: Color4): Color4;
  673. /**
  674. * Scale the current Color4 values by a factor and add the result to a given Color4
  675. * @param scale defines the scale factor
  676. * @param result defines the Color4 object where to store the result
  677. * @returns the unmodified current Color4
  678. */
  679. scaleAndAddToRef(scale: number, result: Color4): Color4;
  680. /**
  681. * Clamps the rgb values by the min and max values and stores the result into "result"
  682. * @param min defines minimum clamping value (default is 0)
  683. * @param max defines maximum clamping value (default is 1)
  684. * @param result defines color to store the result into.
  685. * @returns the cuurent Color4
  686. */
  687. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  688. /**
  689. * Multipy an Color4 value by another and return a new Color4 object
  690. * @param color defines the Color4 value to multiply by
  691. * @returns a new Color4 object
  692. */
  693. multiply(color: Color4): Color4;
  694. /**
  695. * Multipy a Color4 value by another and push the result in a reference value
  696. * @param color defines the Color4 value to multiply by
  697. * @param result defines the Color4 to fill the result in
  698. * @returns the result Color4
  699. */
  700. multiplyToRef(color: Color4, result: Color4): Color4;
  701. /**
  702. * Creates a string with the Color4 current values
  703. * @returns the string representation of the Color4 object
  704. */
  705. toString(): string;
  706. /**
  707. * Returns the string "Color4"
  708. * @returns "Color4"
  709. */
  710. getClassName(): string;
  711. /**
  712. * Compute the Color4 hash code
  713. * @returns an unique number that can be used to hash Color4 objects
  714. */
  715. getHashCode(): number;
  716. /**
  717. * Creates a new Color4 copied from the current one
  718. * @returns a new Color4 object
  719. */
  720. clone(): Color4;
  721. /**
  722. * Copies the given Color4 values into the current one
  723. * @param source defines the source Color4 object
  724. * @returns the current updated Color4 object
  725. */
  726. copyFrom(source: Color4): Color4;
  727. /**
  728. * Copies the given float values into the current one
  729. * @param r defines the red component to read from
  730. * @param g defines the green component to read from
  731. * @param b defines the blue component to read from
  732. * @param a defines the alpha component to read from
  733. * @returns the current updated Color4 object
  734. */
  735. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  736. /**
  737. * Copies the given float values into the current one
  738. * @param r defines the red component to read from
  739. * @param g defines the green component to read from
  740. * @param b defines the blue component to read from
  741. * @param a defines the alpha component to read from
  742. * @returns the current updated Color4 object
  743. */
  744. set(r: number, g: number, b: number, a: number): Color4;
  745. /**
  746. * Compute the Color4 hexadecimal code as a string
  747. * @returns a string containing the hexadecimal representation of the Color4 object
  748. */
  749. toHexString(): string;
  750. /**
  751. * Computes a new Color4 converted from the current one to linear space
  752. * @returns a new Color4 object
  753. */
  754. toLinearSpace(): Color4;
  755. /**
  756. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  757. * @param convertedColor defines the Color4 object where to store the linear space version
  758. * @returns the unmodified Color4
  759. */
  760. toLinearSpaceToRef(convertedColor: Color4): Color4;
  761. /**
  762. * Computes a new Color4 converted from the current one to gamma space
  763. * @returns a new Color4 object
  764. */
  765. toGammaSpace(): Color4;
  766. /**
  767. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  768. * @param convertedColor defines the Color4 object where to store the gamma space version
  769. * @returns the unmodified Color4
  770. */
  771. toGammaSpaceToRef(convertedColor: Color4): Color4;
  772. /**
  773. * Creates a new Color4 from the string containing valid hexadecimal values
  774. * @param hex defines a string containing valid hexadecimal values
  775. * @returns a new Color4 object
  776. */
  777. static FromHexString(hex: string): Color4;
  778. /**
  779. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  780. * @param left defines the start value
  781. * @param right defines the end value
  782. * @param amount defines the gradient factor
  783. * @returns a new Color4 object
  784. */
  785. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  786. /**
  787. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  788. * @param left defines the start value
  789. * @param right defines the end value
  790. * @param amount defines the gradient factor
  791. * @param result defines the Color4 object where to store data
  792. */
  793. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  794. /**
  795. * Creates a new Color4 from a Color3 and an alpha value
  796. * @param color3 defines the source Color3 to read from
  797. * @param alpha defines the alpha component (1.0 by default)
  798. * @returns a new Color4 object
  799. */
  800. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  801. /**
  802. * Creates a new Color4 from the starting index element of the given array
  803. * @param array defines the source array to read from
  804. * @param offset defines the offset in the source array
  805. * @returns a new Color4 object
  806. */
  807. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  808. /**
  809. * Creates a new Color3 from integer values (< 256)
  810. * @param r defines the red component to read from (value between 0 and 255)
  811. * @param g defines the green component to read from (value between 0 and 255)
  812. * @param b defines the blue component to read from (value between 0 and 255)
  813. * @param a defines the alpha component to read from (value between 0 and 255)
  814. * @returns a new Color3 object
  815. */
  816. static FromInts(r: number, g: number, b: number, a: number): Color4;
  817. /**
  818. * Check the content of a given array and convert it to an array containing RGBA data
  819. * If the original array was already containing count * 4 values then it is returned directly
  820. * @param colors defines the array to check
  821. * @param count defines the number of RGBA data to expect
  822. * @returns an array containing count * 4 values (RGBA)
  823. */
  824. static CheckColors4(colors: number[], count: number): number[];
  825. }
  826. /**
  827. * Class representing a vector containing 2 coordinates
  828. */
  829. export class Vector2 {
  830. /** defines the first coordinate */
  831. x: number;
  832. /** defines the second coordinate */
  833. y: number;
  834. /**
  835. * Creates a new Vector2 from the given x and y coordinates
  836. * @param x defines the first coordinate
  837. * @param y defines the second coordinate
  838. */
  839. constructor(
  840. /** defines the first coordinate */
  841. x?: number,
  842. /** defines the second coordinate */
  843. y?: number);
  844. /**
  845. * Gets a string with the Vector2 coordinates
  846. * @returns a string with the Vector2 coordinates
  847. */
  848. toString(): string;
  849. /**
  850. * Gets class name
  851. * @returns the string "Vector2"
  852. */
  853. getClassName(): string;
  854. /**
  855. * Gets current vector hash code
  856. * @returns the Vector2 hash code as a number
  857. */
  858. getHashCode(): number;
  859. /**
  860. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  861. * @param array defines the source array
  862. * @param index defines the offset in source array
  863. * @returns the current Vector2
  864. */
  865. toArray(array: FloatArray, index?: number): Vector2;
  866. /**
  867. * Copy the current vector to an array
  868. * @returns a new array with 2 elements: the Vector2 coordinates.
  869. */
  870. asArray(): number[];
  871. /**
  872. * Sets the Vector2 coordinates with the given Vector2 coordinates
  873. * @param source defines the source Vector2
  874. * @returns the current updated Vector2
  875. */
  876. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  877. /**
  878. * Sets the Vector2 coordinates with the given floats
  879. * @param x defines the first coordinate
  880. * @param y defines the second coordinate
  881. * @returns the current updated Vector2
  882. */
  883. copyFromFloats(x: number, y: number): Vector2;
  884. /**
  885. * Sets the Vector2 coordinates with the given floats
  886. * @param x defines the first coordinate
  887. * @param y defines the second coordinate
  888. * @returns the current updated Vector2
  889. */
  890. set(x: number, y: number): Vector2;
  891. /**
  892. * Add another vector with the current one
  893. * @param otherVector defines the other vector
  894. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  895. */
  896. add(otherVector: DeepImmutable<Vector2>): Vector2;
  897. /**
  898. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  899. * @param otherVector defines the other vector
  900. * @param result defines the target vector
  901. * @returns the unmodified current Vector2
  902. */
  903. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  904. /**
  905. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  906. * @param otherVector defines the other vector
  907. * @returns the current updated Vector2
  908. */
  909. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  910. /**
  911. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  912. * @param otherVector defines the other vector
  913. * @returns a new Vector2
  914. */
  915. addVector3(otherVector: Vector3): Vector2;
  916. /**
  917. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. subtract(otherVector: Vector2): Vector2;
  922. /**
  923. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  924. * @param otherVector defines the other vector
  925. * @param result defines the target vector
  926. * @returns the unmodified current Vector2
  927. */
  928. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  929. /**
  930. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  931. * @param otherVector defines the other vector
  932. * @returns the current updated Vector2
  933. */
  934. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  935. /**
  936. * Multiplies in place the current Vector2 coordinates by the given ones
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  943. * @param otherVector defines the other vector
  944. * @returns a new Vector2
  945. */
  946. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @param result defines the target vector
  951. * @returns the unmodified current Vector2
  952. */
  953. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  954. /**
  955. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  956. * @param x defines the first coordinate
  957. * @param y defines the second coordinate
  958. * @returns a new Vector2
  959. */
  960. multiplyByFloats(x: number, y: number): Vector2;
  961. /**
  962. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  963. * @param otherVector defines the other vector
  964. * @returns a new Vector2
  965. */
  966. divide(otherVector: Vector2): Vector2;
  967. /**
  968. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @param result defines the target vector
  971. * @returns the unmodified current Vector2
  972. */
  973. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  974. /**
  975. * Divides the current Vector2 coordinates by the given ones
  976. * @param otherVector defines the other vector
  977. * @returns the current updated Vector2
  978. */
  979. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  980. /**
  981. * Gets a new Vector2 with current Vector2 negated coordinates
  982. * @returns a new Vector2
  983. */
  984. negate(): Vector2;
  985. /**
  986. * Multiply the Vector2 coordinates by scale
  987. * @param scale defines the scaling factor
  988. * @returns the current updated Vector2
  989. */
  990. scaleInPlace(scale: number): Vector2;
  991. /**
  992. * Returns a new Vector2 scaled by "scale" from the current Vector2
  993. * @param scale defines the scaling factor
  994. * @returns a new Vector2
  995. */
  996. scale(scale: number): Vector2;
  997. /**
  998. * Scale the current Vector2 values by a factor to a given Vector2
  999. * @param scale defines the scale factor
  1000. * @param result defines the Vector2 object where to store the result
  1001. * @returns the unmodified current Vector2
  1002. */
  1003. scaleToRef(scale: number, result: Vector2): Vector2;
  1004. /**
  1005. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1006. * @param scale defines the scale factor
  1007. * @param result defines the Vector2 object where to store the result
  1008. * @returns the unmodified current Vector2
  1009. */
  1010. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1011. /**
  1012. * Gets a boolean if two vectors are equals
  1013. * @param otherVector defines the other vector
  1014. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1015. */
  1016. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1017. /**
  1018. * Gets a boolean if two vectors are equals (using an epsilon value)
  1019. * @param otherVector defines the other vector
  1020. * @param epsilon defines the minimal distance to consider equality
  1021. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1022. */
  1023. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1024. /**
  1025. * Gets a new Vector2 from current Vector2 floored values
  1026. * @returns a new Vector2
  1027. */
  1028. floor(): Vector2;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. fract(): Vector2;
  1034. /**
  1035. * Gets the length of the vector
  1036. * @returns the vector length (float)
  1037. */
  1038. length(): number;
  1039. /**
  1040. * Gets the vector squared length
  1041. * @returns the vector squared length (float)
  1042. */
  1043. lengthSquared(): number;
  1044. /**
  1045. * Normalize the vector
  1046. * @returns the current updated Vector2
  1047. */
  1048. normalize(): Vector2;
  1049. /**
  1050. * Gets a new Vector2 copied from the Vector2
  1051. * @returns a new Vector2
  1052. */
  1053. clone(): Vector2;
  1054. /**
  1055. * Gets a new Vector2(0, 0)
  1056. * @returns a new Vector2
  1057. */
  1058. static Zero(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(1, 1)
  1061. * @returns a new Vector2
  1062. */
  1063. static One(): Vector2;
  1064. /**
  1065. * Gets a new Vector2 set from the given index element of the given array
  1066. * @param array defines the data source
  1067. * @param offset defines the offset in the data source
  1068. * @returns a new Vector2
  1069. */
  1070. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1071. /**
  1072. * Sets "result" from the given index element of the given array
  1073. * @param array defines the data source
  1074. * @param offset defines the offset in the data source
  1075. * @param result defines the target vector
  1076. */
  1077. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1078. /**
  1079. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1080. * @param value1 defines 1st point of control
  1081. * @param value2 defines 2nd point of control
  1082. * @param value3 defines 3rd point of control
  1083. * @param value4 defines 4th point of control
  1084. * @param amount defines the interpolation factor
  1085. * @returns a new Vector2
  1086. */
  1087. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1088. /**
  1089. * 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".
  1090. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1091. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1092. * @param value defines the value to clamp
  1093. * @param min defines the lower limit
  1094. * @param max defines the upper limit
  1095. * @returns a new Vector2
  1096. */
  1097. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1098. /**
  1099. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1100. * @param value1 defines the 1st control point
  1101. * @param tangent1 defines the outgoing tangent
  1102. * @param value2 defines the 2nd control point
  1103. * @param tangent2 defines the incoming tangent
  1104. * @param amount defines the interpolation factor
  1105. * @returns a new Vector2
  1106. */
  1107. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1108. /**
  1109. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1110. * @param start defines the start vector
  1111. * @param end defines the end vector
  1112. * @param amount defines the interpolation factor
  1113. * @returns a new Vector2
  1114. */
  1115. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1116. /**
  1117. * Gets the dot product of the vector "left" and the vector "right"
  1118. * @param left defines first vector
  1119. * @param right defines second vector
  1120. * @returns the dot product (float)
  1121. */
  1122. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1123. /**
  1124. * Returns a new Vector2 equal to the normalized given vector
  1125. * @param vector defines the vector to normalize
  1126. * @returns a new Vector2
  1127. */
  1128. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1129. /**
  1130. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1131. * @param left defines 1st vector
  1132. * @param right defines 2nd vector
  1133. * @returns a new Vector2
  1134. */
  1135. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1136. /**
  1137. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1138. * @param left defines 1st vector
  1139. * @param right defines 2nd vector
  1140. * @returns a new Vector2
  1141. */
  1142. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1143. /**
  1144. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1145. * @param vector defines the vector to transform
  1146. * @param transformation defines the matrix to apply
  1147. * @returns a new Vector2
  1148. */
  1149. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1150. /**
  1151. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1152. * @param vector defines the vector to transform
  1153. * @param transformation defines the matrix to apply
  1154. * @param result defines the target vector
  1155. */
  1156. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1157. /**
  1158. * Determines if a given vector is included in a triangle
  1159. * @param p defines the vector to test
  1160. * @param p0 defines 1st triangle point
  1161. * @param p1 defines 2nd triangle point
  1162. * @param p2 defines 3rd triangle point
  1163. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1164. */
  1165. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1166. /**
  1167. * Gets the distance between the vectors "value1" and "value2"
  1168. * @param value1 defines first vector
  1169. * @param value2 defines second vector
  1170. * @returns the distance between vectors
  1171. */
  1172. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1173. /**
  1174. * Returns the squared distance between the vectors "value1" and "value2"
  1175. * @param value1 defines first vector
  1176. * @param value2 defines second vector
  1177. * @returns the squared distance between vectors
  1178. */
  1179. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1180. /**
  1181. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1182. * @param value1 defines first vector
  1183. * @param value2 defines second vector
  1184. * @returns a new Vector2
  1185. */
  1186. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1187. /**
  1188. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1189. * @param p defines the middle point
  1190. * @param segA defines one point of the segment
  1191. * @param segB defines the other point of the segment
  1192. * @returns the shortest distance
  1193. */
  1194. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1195. }
  1196. /**
  1197. * Classed used to store (x,y,z) vector representation
  1198. * A Vector3 is the main object used in 3D geometry
  1199. * It can represent etiher the coordinates of a point the space, either a direction
  1200. * Reminder: js uses a left handed forward facing system
  1201. */
  1202. export class Vector3 {
  1203. /**
  1204. * Defines the first coordinates (on X axis)
  1205. */
  1206. x: number;
  1207. /**
  1208. * Defines the second coordinates (on Y axis)
  1209. */
  1210. y: number;
  1211. /**
  1212. * Defines the third coordinates (on Z axis)
  1213. */
  1214. z: number;
  1215. /**
  1216. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1217. * @param x defines the first coordinates (on X axis)
  1218. * @param y defines the second coordinates (on Y axis)
  1219. * @param z defines the third coordinates (on Z axis)
  1220. */
  1221. constructor(
  1222. /**
  1223. * Defines the first coordinates (on X axis)
  1224. */
  1225. x?: number,
  1226. /**
  1227. * Defines the second coordinates (on Y axis)
  1228. */
  1229. y?: number,
  1230. /**
  1231. * Defines the third coordinates (on Z axis)
  1232. */
  1233. z?: number);
  1234. /**
  1235. * Creates a string representation of the Vector3
  1236. * @returns a string with the Vector3 coordinates.
  1237. */
  1238. toString(): string;
  1239. /**
  1240. * Gets the class name
  1241. * @returns the string "Vector3"
  1242. */
  1243. getClassName(): string;
  1244. /**
  1245. * Creates the Vector3 hash code
  1246. * @returns a number which tends to be unique between Vector3 instances
  1247. */
  1248. getHashCode(): number;
  1249. /**
  1250. * Creates an array containing three elements : the coordinates of the Vector3
  1251. * @returns a new array of numbers
  1252. */
  1253. asArray(): number[];
  1254. /**
  1255. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1256. * @param array defines the destination array
  1257. * @param index defines the offset in the destination array
  1258. * @returns the current Vector3
  1259. */
  1260. toArray(array: FloatArray, index?: number): Vector3;
  1261. /**
  1262. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1263. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1264. */
  1265. toQuaternion(): Quaternion;
  1266. /**
  1267. * Adds the given vector to the current Vector3
  1268. * @param otherVector defines the second operand
  1269. * @returns the current updated Vector3
  1270. */
  1271. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1272. /**
  1273. * Adds the given coordinates to the current Vector3
  1274. * @param x defines the x coordinate of the operand
  1275. * @param y defines the y coordinate of the operand
  1276. * @param z defines the z coordinate of the operand
  1277. * @returns the current updated Vector3
  1278. */
  1279. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1280. /**
  1281. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1282. * @param otherVector defines the second operand
  1283. * @returns the resulting Vector3
  1284. */
  1285. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1286. /**
  1287. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1288. * @param otherVector defines the second operand
  1289. * @param result defines the Vector3 object where to store the result
  1290. * @returns the current Vector3
  1291. */
  1292. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1293. /**
  1294. * Subtract the given vector from the current Vector3
  1295. * @param otherVector defines the second operand
  1296. * @returns the current updated Vector3
  1297. */
  1298. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1299. /**
  1300. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the resulting Vector3
  1303. */
  1304. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1307. * @param otherVector defines the second operand
  1308. * @param result defines the Vector3 object where to store the result
  1309. * @returns the current Vector3
  1310. */
  1311. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1312. /**
  1313. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1314. * @param x defines the x coordinate of the operand
  1315. * @param y defines the y coordinate of the operand
  1316. * @param z defines the z coordinate of the operand
  1317. * @returns the resulting Vector3
  1318. */
  1319. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1320. /**
  1321. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1322. * @param x defines the x coordinate of the operand
  1323. * @param y defines the y coordinate of the operand
  1324. * @param z defines the z coordinate of the operand
  1325. * @param result defines the Vector3 object where to store the result
  1326. * @returns the current Vector3
  1327. */
  1328. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1329. /**
  1330. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1331. * @returns a new Vector3
  1332. */
  1333. negate(): Vector3;
  1334. /**
  1335. * Multiplies the Vector3 coordinates by the float "scale"
  1336. * @param scale defines the multiplier factor
  1337. * @returns the current updated Vector3
  1338. */
  1339. scaleInPlace(scale: number): Vector3;
  1340. /**
  1341. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns a new Vector3
  1344. */
  1345. scale(scale: number): Vector3;
  1346. /**
  1347. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1348. * @param scale defines the multiplier factor
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. scaleToRef(scale: number, result: Vector3): Vector3;
  1353. /**
  1354. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1355. * @param scale defines the scale factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the unmodified current Vector3
  1358. */
  1359. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1362. * @param otherVector defines the second operand
  1363. * @returns true if both vectors are equals
  1364. */
  1365. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1368. * @param otherVector defines the second operand
  1369. * @param epsilon defines the minimal distance to define values as equals
  1370. * @returns true if both vectors are distant less than epsilon
  1371. */
  1372. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 coordinates equals the given floats
  1375. * @param x defines the x coordinate of the operand
  1376. * @param y defines the y coordinate of the operand
  1377. * @param z defines the z coordinate of the operand
  1378. * @returns true if both vectors are equals
  1379. */
  1380. equalsToFloats(x: number, y: number, z: number): boolean;
  1381. /**
  1382. * Multiplies the current Vector3 coordinates by the given ones
  1383. * @param otherVector defines the second operand
  1384. * @returns the current updated Vector3
  1385. */
  1386. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1387. /**
  1388. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1389. * @param otherVector defines the second operand
  1390. * @returns the new Vector3
  1391. */
  1392. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1395. * @param otherVector defines the second operand
  1396. * @param result defines the Vector3 object where to store the result
  1397. * @returns the current Vector3
  1398. */
  1399. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1400. /**
  1401. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1402. * @param x defines the x coordinate of the operand
  1403. * @param y defines the y coordinate of the operand
  1404. * @param z defines the z coordinate of the operand
  1405. * @returns the new Vector3
  1406. */
  1407. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1408. /**
  1409. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1410. * @param otherVector defines the second operand
  1411. * @returns the new Vector3
  1412. */
  1413. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1414. /**
  1415. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1416. * @param otherVector defines the second operand
  1417. * @param result defines the Vector3 object where to store the result
  1418. * @returns the current Vector3
  1419. */
  1420. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones.
  1423. * @param otherVector defines the second operand
  1424. * @returns the current updated Vector3
  1425. */
  1426. divideInPlace(otherVector: Vector3): Vector3;
  1427. /**
  1428. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1429. * @param other defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1441. * @param x defines the x coordinate of the operand
  1442. * @param y defines the y coordinate of the operand
  1443. * @param z defines the z coordinate of the operand
  1444. * @returns the current updated Vector3
  1445. */
  1446. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1447. /**
  1448. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1449. * @param x defines the x coordinate of the operand
  1450. * @param y defines the y coordinate of the operand
  1451. * @param z defines the z coordinate of the operand
  1452. * @returns the current updated Vector3
  1453. */
  1454. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1455. /**
  1456. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1457. */
  1458. readonly isNonUniform: boolean;
  1459. /**
  1460. * Gets a new Vector3 from current Vector3 floored values
  1461. * @returns a new Vector3
  1462. */
  1463. floor(): Vector3;
  1464. /**
  1465. * Gets a new Vector3 from current Vector3 floored values
  1466. * @returns a new Vector3
  1467. */
  1468. fract(): Vector3;
  1469. /**
  1470. * Gets the length of the Vector3
  1471. * @returns the length of the Vecto3
  1472. */
  1473. length(): number;
  1474. /**
  1475. * Gets the squared length of the Vector3
  1476. * @returns squared length of the Vector3
  1477. */
  1478. lengthSquared(): number;
  1479. /**
  1480. * Normalize the current Vector3.
  1481. * Please note that this is an in place operation.
  1482. * @returns the current updated Vector3
  1483. */
  1484. normalize(): Vector3;
  1485. /**
  1486. * Reorders the x y z properties of the vector in place
  1487. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1488. * @returns the current updated vector
  1489. */
  1490. reorderInPlace(order: string): this;
  1491. /**
  1492. * Rotates the vector around 0,0,0 by a quaternion
  1493. * @param quaternion the rotation quaternion
  1494. * @param result vector to store the result
  1495. * @returns the resulting vector
  1496. */
  1497. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1498. /**
  1499. * Rotates a vector around a given point
  1500. * @param quaternion the rotation quaternion
  1501. * @param point the point to rotate around
  1502. * @param result vector to store the result
  1503. * @returns the resulting vector
  1504. */
  1505. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1506. /**
  1507. * Normalize the current Vector3 with the given input length.
  1508. * Please note that this is an in place operation.
  1509. * @param len the length of the vector
  1510. * @returns the current updated Vector3
  1511. */
  1512. normalizeFromLength(len: number): Vector3;
  1513. /**
  1514. * Normalize the current Vector3 to a new vector
  1515. * @returns the new Vector3
  1516. */
  1517. normalizeToNew(): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 to the reference
  1520. * @param reference define the Vector3 to update
  1521. * @returns the updated Vector3
  1522. */
  1523. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1524. /**
  1525. * Creates a new Vector3 copied from the current Vector3
  1526. * @returns the new Vector3
  1527. */
  1528. clone(): Vector3;
  1529. /**
  1530. * Copies the given vector coordinates to the current Vector3 ones
  1531. * @param source defines the source Vector3
  1532. * @returns the current updated Vector3
  1533. */
  1534. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1535. /**
  1536. * Copies the given floats to the current Vector3 coordinates
  1537. * @param x defines the x coordinate of the operand
  1538. * @param y defines the y coordinate of the operand
  1539. * @param z defines the z coordinate of the operand
  1540. * @returns the current updated Vector3
  1541. */
  1542. copyFromFloats(x: number, y: number, z: number): Vector3;
  1543. /**
  1544. * Copies the given floats to the current Vector3 coordinates
  1545. * @param x defines the x coordinate of the operand
  1546. * @param y defines the y coordinate of the operand
  1547. * @param z defines the z coordinate of the operand
  1548. * @returns the current updated Vector3
  1549. */
  1550. set(x: number, y: number, z: number): Vector3;
  1551. /**
  1552. * Copies the given float to the current Vector3 coordinates
  1553. * @param v defines the x, y and z coordinates of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. setAll(v: number): Vector3;
  1557. /**
  1558. * Get the clip factor between two vectors
  1559. * @param vector0 defines the first operand
  1560. * @param vector1 defines the second operand
  1561. * @param axis defines the axis to use
  1562. * @param size defines the size along the axis
  1563. * @returns the clip factor
  1564. */
  1565. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1566. /**
  1567. * Get angle between two vectors
  1568. * @param vector0 angle between vector0 and vector1
  1569. * @param vector1 angle between vector0 and vector1
  1570. * @param normal direction of the normal
  1571. * @return the angle between vector0 and vector1
  1572. */
  1573. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1574. /**
  1575. * Returns a new Vector3 set from the index "offset" of the given array
  1576. * @param array defines the source array
  1577. * @param offset defines the offset in the source array
  1578. * @returns the new Vector3
  1579. */
  1580. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1581. /**
  1582. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1583. * This function is deprecated. Use FromArray instead
  1584. * @param array defines the source array
  1585. * @param offset defines the offset in the source array
  1586. * @returns the new Vector3
  1587. */
  1588. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1589. /**
  1590. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1591. * @param array defines the source array
  1592. * @param offset defines the offset in the source array
  1593. * @param result defines the Vector3 where to store the result
  1594. */
  1595. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1596. /**
  1597. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1598. * This function is deprecated. Use FromArrayToRef instead.
  1599. * @param array defines the source array
  1600. * @param offset defines the offset in the source array
  1601. * @param result defines the Vector3 where to store the result
  1602. */
  1603. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1604. /**
  1605. * Sets the given vector "result" with the given floats.
  1606. * @param x defines the x coordinate of the source
  1607. * @param y defines the y coordinate of the source
  1608. * @param z defines the z coordinate of the source
  1609. * @param result defines the Vector3 where to store the result
  1610. */
  1611. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1612. /**
  1613. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1614. * @returns a new empty Vector3
  1615. */
  1616. static Zero(): Vector3;
  1617. /**
  1618. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1619. * @returns a new unit Vector3
  1620. */
  1621. static One(): Vector3;
  1622. /**
  1623. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1624. * @returns a new up Vector3
  1625. */
  1626. static Up(): Vector3;
  1627. /**
  1628. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1629. * @returns a new down Vector3
  1630. */
  1631. static Down(): Vector3;
  1632. /**
  1633. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1634. * @returns a new forward Vector3
  1635. */
  1636. static Forward(): Vector3;
  1637. /**
  1638. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1639. * @returns a new forward Vector3
  1640. */
  1641. static Backward(): Vector3;
  1642. /**
  1643. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1644. * @returns a new right Vector3
  1645. */
  1646. static Right(): Vector3;
  1647. /**
  1648. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1649. * @returns a new left Vector3
  1650. */
  1651. static Left(): Vector3;
  1652. /**
  1653. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1654. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1655. * @param vector defines the Vector3 to transform
  1656. * @param transformation defines the transformation matrix
  1657. * @returns the transformed Vector3
  1658. */
  1659. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1660. /**
  1661. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1662. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1663. * @param vector defines the Vector3 to transform
  1664. * @param transformation defines the transformation matrix
  1665. * @param result defines the Vector3 where to store the result
  1666. */
  1667. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1668. /**
  1669. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1670. * This method computes tranformed coordinates only, not transformed direction vectors
  1671. * @param x define the x coordinate of the source vector
  1672. * @param y define the y coordinate of the source vector
  1673. * @param z define the z coordinate of the source vector
  1674. * @param transformation defines the transformation matrix
  1675. * @param result defines the Vector3 where to store the result
  1676. */
  1677. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1678. /**
  1679. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1680. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @returns the new Vector3
  1684. */
  1685. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1686. /**
  1687. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1688. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1689. * @param vector defines the Vector3 to transform
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param x define the x coordinate of the source vector
  1698. * @param y define the y coordinate of the source vector
  1699. * @param z define the z coordinate of the source vector
  1700. * @param transformation defines the transformation matrix
  1701. * @param result defines the Vector3 where to store the result
  1702. */
  1703. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1704. /**
  1705. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1706. * @param value1 defines the first control point
  1707. * @param value2 defines the second control point
  1708. * @param value3 defines the third control point
  1709. * @param value4 defines the fourth control point
  1710. * @param amount defines the amount on the spline to use
  1711. * @returns the new Vector3
  1712. */
  1713. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1714. /**
  1715. * 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"
  1716. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1717. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1718. * @param value defines the current value
  1719. * @param min defines the lower range value
  1720. * @param max defines the upper range value
  1721. * @returns the new Vector3
  1722. */
  1723. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1724. /**
  1725. * 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"
  1726. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1727. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1728. * @param value defines the current value
  1729. * @param min defines the lower range value
  1730. * @param max defines the upper range value
  1731. * @param result defines the Vector3 where to store the result
  1732. */
  1733. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1734. /**
  1735. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1736. * @param value1 defines the first control point
  1737. * @param tangent1 defines the first tangent vector
  1738. * @param value2 defines the second control point
  1739. * @param tangent2 defines the second tangent vector
  1740. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1741. * @returns the new Vector3
  1742. */
  1743. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1744. /**
  1745. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1746. * @param start defines the start value
  1747. * @param end defines the end value
  1748. * @param amount max defines amount between both (between 0 and 1)
  1749. * @returns the new Vector3
  1750. */
  1751. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1752. /**
  1753. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1754. * @param start defines the start value
  1755. * @param end defines the end value
  1756. * @param amount max defines amount between both (between 0 and 1)
  1757. * @param result defines the Vector3 where to store the result
  1758. */
  1759. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1760. /**
  1761. * Returns the dot product (float) between the vectors "left" and "right"
  1762. * @param left defines the left operand
  1763. * @param right defines the right operand
  1764. * @returns the dot product
  1765. */
  1766. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1767. /**
  1768. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1769. * The cross product is then orthogonal to both "left" and "right"
  1770. * @param left defines the left operand
  1771. * @param right defines the right operand
  1772. * @returns the cross product
  1773. */
  1774. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1775. /**
  1776. * Sets the given vector "result" with the cross product of "left" and "right"
  1777. * The cross product is then orthogonal to both "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @param result defines the Vector3 where to store the result
  1781. */
  1782. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1783. /**
  1784. * Returns a new Vector3 as the normalization of the given vector
  1785. * @param vector defines the Vector3 to normalize
  1786. * @returns the new Vector3
  1787. */
  1788. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1789. /**
  1790. * Sets the given vector "result" with the normalization of the given first vector
  1791. * @param vector defines the Vector3 to normalize
  1792. * @param result defines the Vector3 where to store the result
  1793. */
  1794. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1795. /**
  1796. * Project a Vector3 onto screen space
  1797. * @param vector defines the Vector3 to project
  1798. * @param world defines the world matrix to use
  1799. * @param transform defines the transform (view x projection) matrix to use
  1800. * @param viewport defines the screen viewport to use
  1801. * @returns the new Vector3
  1802. */
  1803. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1804. /** @hidden */
  1805. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1806. /**
  1807. * Unproject from screen space to object space
  1808. * @param source defines the screen space Vector3 to use
  1809. * @param viewportWidth defines the current width of the viewport
  1810. * @param viewportHeight defines the current height of the viewport
  1811. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1812. * @param transform defines the transform (view x projection) matrix to use
  1813. * @returns the new Vector3
  1814. */
  1815. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1816. /**
  1817. * Unproject from screen space to object space
  1818. * @param source defines the screen space Vector3 to use
  1819. * @param viewportWidth defines the current width of the viewport
  1820. * @param viewportHeight defines the current height of the viewport
  1821. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1822. * @param view defines the view matrix to use
  1823. * @param projection defines the projection matrix to use
  1824. * @returns the new Vector3
  1825. */
  1826. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1827. /**
  1828. * Unproject from screen space to object space
  1829. * @param source defines the screen space Vector3 to use
  1830. * @param viewportWidth defines the current width of the viewport
  1831. * @param viewportHeight defines the current height of the viewport
  1832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1833. * @param view defines the view matrix to use
  1834. * @param projection defines the projection matrix to use
  1835. * @param result defines the Vector3 where to store the result
  1836. */
  1837. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1838. /**
  1839. * Unproject from screen space to object space
  1840. * @param sourceX defines the screen space x coordinate to use
  1841. * @param sourceY defines the screen space y coordinate to use
  1842. * @param sourceZ defines the screen space z coordinate to use
  1843. * @param viewportWidth defines the current width of the viewport
  1844. * @param viewportHeight defines the current height of the viewport
  1845. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1846. * @param view defines the view matrix to use
  1847. * @param projection defines the projection matrix to use
  1848. * @param result defines the Vector3 where to store the result
  1849. */
  1850. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1851. /**
  1852. * Gets the minimal coordinate values between two Vector3
  1853. * @param left defines the first operand
  1854. * @param right defines the second operand
  1855. * @returns the new Vector3
  1856. */
  1857. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1858. /**
  1859. * Gets the maximal coordinate values between two Vector3
  1860. * @param left defines the first operand
  1861. * @param right defines the second operand
  1862. * @returns the new Vector3
  1863. */
  1864. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1865. /**
  1866. * Returns the distance between the vectors "value1" and "value2"
  1867. * @param value1 defines the first operand
  1868. * @param value2 defines the second operand
  1869. * @returns the distance
  1870. */
  1871. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1872. /**
  1873. * Returns the squared distance between the vectors "value1" and "value2"
  1874. * @param value1 defines the first operand
  1875. * @param value2 defines the second operand
  1876. * @returns the squared distance
  1877. */
  1878. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1879. /**
  1880. * Returns a new Vector3 located at the center between "value1" and "value2"
  1881. * @param value1 defines the first operand
  1882. * @param value2 defines the second operand
  1883. * @returns the new Vector3
  1884. */
  1885. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1886. /**
  1887. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1888. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1889. * to something in order to rotate it from its local system to the given target system
  1890. * Note: axis1, axis2 and axis3 are normalized during this operation
  1891. * @param axis1 defines the first axis
  1892. * @param axis2 defines the second axis
  1893. * @param axis3 defines the third axis
  1894. * @returns a new Vector3
  1895. */
  1896. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1899. * @param axis1 defines the first axis
  1900. * @param axis2 defines the second axis
  1901. * @param axis3 defines the third axis
  1902. * @param ref defines the Vector3 where to store the result
  1903. */
  1904. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1905. }
  1906. /**
  1907. * Vector4 class created for EulerAngle class conversion to Quaternion
  1908. */
  1909. export class Vector4 {
  1910. /** x value of the vector */
  1911. x: number;
  1912. /** y value of the vector */
  1913. y: number;
  1914. /** z value of the vector */
  1915. z: number;
  1916. /** w value of the vector */
  1917. w: number;
  1918. /**
  1919. * Creates a Vector4 object from the given floats.
  1920. * @param x x value of the vector
  1921. * @param y y value of the vector
  1922. * @param z z value of the vector
  1923. * @param w w value of the vector
  1924. */
  1925. constructor(
  1926. /** x value of the vector */
  1927. x: number,
  1928. /** y value of the vector */
  1929. y: number,
  1930. /** z value of the vector */
  1931. z: number,
  1932. /** w value of the vector */
  1933. w: number);
  1934. /**
  1935. * Returns the string with the Vector4 coordinates.
  1936. * @returns a string containing all the vector values
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Returns the string "Vector4".
  1941. * @returns "Vector4"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Returns the Vector4 hash code.
  1946. * @returns a unique hash code
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1951. * @returns the resulting array
  1952. */
  1953. asArray(): number[];
  1954. /**
  1955. * Populates the given array from the given index with the Vector4 coordinates.
  1956. * @param array array to populate
  1957. * @param index index of the array to start at (default: 0)
  1958. * @returns the Vector4.
  1959. */
  1960. toArray(array: FloatArray, index?: number): Vector4;
  1961. /**
  1962. * Adds the given vector to the current Vector4.
  1963. * @param otherVector the vector to add
  1964. * @returns the updated Vector4.
  1965. */
  1966. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1967. /**
  1968. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1969. * @param otherVector the vector to add
  1970. * @returns the resulting vector
  1971. */
  1972. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1973. /**
  1974. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1975. * @param otherVector the vector to add
  1976. * @param result the vector to store the result
  1977. * @returns the current Vector4.
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1980. /**
  1981. * Subtract in place the given vector from the current Vector4.
  1982. * @param otherVector the vector to subtract
  1983. * @returns the updated Vector4.
  1984. */
  1985. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1986. /**
  1987. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  1988. * @param otherVector the vector to add
  1989. * @returns the new vector with the result
  1990. */
  1991. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  1992. /**
  1993. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  1994. * @param otherVector the vector to subtract
  1995. * @param result the vector to store the result
  1996. * @returns the current Vector4.
  1997. */
  1998. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1999. /**
  2000. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2001. */
  2002. /**
  2003. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2004. * @param x value to subtract
  2005. * @param y value to subtract
  2006. * @param z value to subtract
  2007. * @param w value to subtract
  2008. * @returns new vector containing the result
  2009. */
  2010. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2011. /**
  2012. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2013. * @param x value to subtract
  2014. * @param y value to subtract
  2015. * @param z value to subtract
  2016. * @param w value to subtract
  2017. * @param result the vector to store the result in
  2018. * @returns the current Vector4.
  2019. */
  2020. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2021. /**
  2022. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2023. * @returns a new vector with the negated values
  2024. */
  2025. negate(): Vector4;
  2026. /**
  2027. * Multiplies the current Vector4 coordinates by scale (float).
  2028. * @param scale the number to scale with
  2029. * @returns the updated Vector4.
  2030. */
  2031. scaleInPlace(scale: number): Vector4;
  2032. /**
  2033. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2034. * @param scale the number to scale with
  2035. * @returns a new vector with the result
  2036. */
  2037. scale(scale: number): Vector4;
  2038. /**
  2039. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2040. * @param scale the number to scale with
  2041. * @param result a vector to store the result in
  2042. * @returns the current Vector4.
  2043. */
  2044. scaleToRef(scale: number, result: Vector4): Vector4;
  2045. /**
  2046. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2047. * @param scale defines the scale factor
  2048. * @param result defines the Vector4 object where to store the result
  2049. * @returns the unmodified current Vector4
  2050. */
  2051. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2052. /**
  2053. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2054. * @param otherVector the vector to compare against
  2055. * @returns true if they are equal
  2056. */
  2057. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2058. /**
  2059. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2060. * @param otherVector vector to compare against
  2061. * @param epsilon (Default: very small number)
  2062. * @returns true if they are equal
  2063. */
  2064. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2065. /**
  2066. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2067. * @param x x value to compare against
  2068. * @param y y value to compare against
  2069. * @param z z value to compare against
  2070. * @param w w value to compare against
  2071. * @returns true if equal
  2072. */
  2073. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2074. /**
  2075. * Multiplies in place the current Vector4 by the given one.
  2076. * @param otherVector vector to multiple with
  2077. * @returns the updated Vector4.
  2078. */
  2079. multiplyInPlace(otherVector: Vector4): Vector4;
  2080. /**
  2081. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2082. * @param otherVector vector to multiple with
  2083. * @returns resulting new vector
  2084. */
  2085. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2086. /**
  2087. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2088. * @param otherVector vector to multiple with
  2089. * @param result vector to store the result
  2090. * @returns the current Vector4.
  2091. */
  2092. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2093. /**
  2094. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2095. * @param x x value multiply with
  2096. * @param y y value multiply with
  2097. * @param z z value multiply with
  2098. * @param w w value multiply with
  2099. * @returns resulting new vector
  2100. */
  2101. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2102. /**
  2103. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2104. * @param otherVector vector to devide with
  2105. * @returns resulting new vector
  2106. */
  2107. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2108. /**
  2109. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2110. * @param otherVector vector to devide with
  2111. * @param result vector to store the result
  2112. * @returns the current Vector4.
  2113. */
  2114. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2115. /**
  2116. * Divides the current Vector3 coordinates by the given ones.
  2117. * @param otherVector vector to devide with
  2118. * @returns the updated Vector3.
  2119. */
  2120. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2121. /**
  2122. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2123. * @param other defines the second operand
  2124. * @returns the current updated Vector4
  2125. */
  2126. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2129. * @param other defines the second operand
  2130. * @returns the current updated Vector4
  2131. */
  2132. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2133. /**
  2134. * Gets a new Vector4 from current Vector4 floored values
  2135. * @returns a new Vector4
  2136. */
  2137. floor(): Vector4;
  2138. /**
  2139. * Gets a new Vector4 from current Vector3 floored values
  2140. * @returns a new Vector4
  2141. */
  2142. fract(): Vector4;
  2143. /**
  2144. * Returns the Vector4 length (float).
  2145. * @returns the length
  2146. */
  2147. length(): number;
  2148. /**
  2149. * Returns the Vector4 squared length (float).
  2150. * @returns the length squared
  2151. */
  2152. lengthSquared(): number;
  2153. /**
  2154. * Normalizes in place the Vector4.
  2155. * @returns the updated Vector4.
  2156. */
  2157. normalize(): Vector4;
  2158. /**
  2159. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2160. * @returns this converted to a new vector3
  2161. */
  2162. toVector3(): Vector3;
  2163. /**
  2164. * Returns a new Vector4 copied from the current one.
  2165. * @returns the new cloned vector
  2166. */
  2167. clone(): Vector4;
  2168. /**
  2169. * Updates the current Vector4 with the given one coordinates.
  2170. * @param source the source vector to copy from
  2171. * @returns the updated Vector4.
  2172. */
  2173. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Updates the current Vector4 coordinates with the given floats.
  2176. * @param x float to copy from
  2177. * @param y float to copy from
  2178. * @param z float to copy from
  2179. * @param w float to copy from
  2180. * @returns the updated Vector4.
  2181. */
  2182. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2183. /**
  2184. * Updates the current Vector4 coordinates with the given floats.
  2185. * @param x float to set from
  2186. * @param y float to set from
  2187. * @param z float to set from
  2188. * @param w float to set from
  2189. * @returns the updated Vector4.
  2190. */
  2191. set(x: number, y: number, z: number, w: number): Vector4;
  2192. /**
  2193. * Copies the given float to the current Vector3 coordinates
  2194. * @param v defines the x, y, z and w coordinates of the operand
  2195. * @returns the current updated Vector3
  2196. */
  2197. setAll(v: number): Vector4;
  2198. /**
  2199. * Returns a new Vector4 set from the starting index of the given array.
  2200. * @param array the array to pull values from
  2201. * @param offset the offset into the array to start at
  2202. * @returns the new vector
  2203. */
  2204. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2205. /**
  2206. * Updates the given vector "result" from the starting index of the given array.
  2207. * @param array the array to pull values from
  2208. * @param offset the offset into the array to start at
  2209. * @param result the vector to store the result in
  2210. */
  2211. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2212. /**
  2213. * Updates the given vector "result" from the starting index of the given Float32Array.
  2214. * @param array the array to pull values from
  2215. * @param offset the offset into the array to start at
  2216. * @param result the vector to store the result in
  2217. */
  2218. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2219. /**
  2220. * Updates the given vector "result" coordinates from the given floats.
  2221. * @param x float to set from
  2222. * @param y float to set from
  2223. * @param z float to set from
  2224. * @param w float to set from
  2225. * @param result the vector to the floats in
  2226. */
  2227. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2228. /**
  2229. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2230. * @returns the new vector
  2231. */
  2232. static Zero(): Vector4;
  2233. /**
  2234. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2235. * @returns the new vector
  2236. */
  2237. static One(): Vector4;
  2238. /**
  2239. * Returns a new normalized Vector4 from the given one.
  2240. * @param vector the vector to normalize
  2241. * @returns the vector
  2242. */
  2243. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the normalization of the given one.
  2246. * @param vector the vector to normalize
  2247. * @param result the vector to store the result in
  2248. */
  2249. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2250. /**
  2251. * Returns a vector with the minimum values from the left and right vectors
  2252. * @param left left vector to minimize
  2253. * @param right right vector to minimize
  2254. * @returns a new vector with the minimum of the left and right vector values
  2255. */
  2256. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2257. /**
  2258. * Returns a vector with the maximum values from the left and right vectors
  2259. * @param left left vector to maximize
  2260. * @param right right vector to maximize
  2261. * @returns a new vector with the maximum of the left and right vector values
  2262. */
  2263. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2264. /**
  2265. * Returns the distance (float) between the vectors "value1" and "value2".
  2266. * @param value1 value to calulate the distance between
  2267. * @param value2 value to calulate the distance between
  2268. * @return the distance between the two vectors
  2269. */
  2270. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2271. /**
  2272. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2273. * @param value1 value to calulate the distance between
  2274. * @param value2 value to calulate the distance between
  2275. * @return the distance between the two vectors squared
  2276. */
  2277. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2278. /**
  2279. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2280. * @param value1 value to calulate the center between
  2281. * @param value2 value to calulate the center between
  2282. * @return the center between the two vectors
  2283. */
  2284. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2287. * This methods computes transformed normalized direction vectors only.
  2288. * @param vector the vector to transform
  2289. * @param transformation the transformation matrix to apply
  2290. * @returns the new vector
  2291. */
  2292. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2293. /**
  2294. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2295. * This methods computes transformed normalized direction vectors only.
  2296. * @param vector the vector to transform
  2297. * @param transformation the transformation matrix to apply
  2298. * @param result the vector to store the result in
  2299. */
  2300. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2301. /**
  2302. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param x value to transform
  2305. * @param y value to transform
  2306. * @param z value to transform
  2307. * @param w value to transform
  2308. * @param transformation the transformation matrix to apply
  2309. * @param result the vector to store the results in
  2310. */
  2311. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2312. }
  2313. /**
  2314. * Interface for the size containing width and height
  2315. */
  2316. export interface ISize {
  2317. /**
  2318. * Width
  2319. */
  2320. width: number;
  2321. /**
  2322. * Heighht
  2323. */
  2324. height: number;
  2325. }
  2326. /**
  2327. * Size containing widht and height
  2328. */
  2329. export class Size implements ISize {
  2330. /**
  2331. * Width
  2332. */
  2333. width: number;
  2334. /**
  2335. * Height
  2336. */
  2337. height: number;
  2338. /**
  2339. * Creates a Size object from the given width and height (floats).
  2340. * @param width width of the new size
  2341. * @param height height of the new size
  2342. */
  2343. constructor(width: number, height: number);
  2344. /**
  2345. * Returns a string with the Size width and height
  2346. * @returns a string with the Size width and height
  2347. */
  2348. toString(): string;
  2349. /**
  2350. * "Size"
  2351. * @returns the string "Size"
  2352. */
  2353. getClassName(): string;
  2354. /**
  2355. * Returns the Size hash code.
  2356. * @returns a hash code for a unique width and height
  2357. */
  2358. getHashCode(): number;
  2359. /**
  2360. * Updates the current size from the given one.
  2361. * @param src the given size
  2362. */
  2363. copyFrom(src: Size): void;
  2364. /**
  2365. * Updates in place the current Size from the given floats.
  2366. * @param width width of the new size
  2367. * @param height height of the new size
  2368. * @returns the updated Size.
  2369. */
  2370. copyFromFloats(width: number, height: number): Size;
  2371. /**
  2372. * Updates in place the current Size from the given floats.
  2373. * @param width width to set
  2374. * @param height height to set
  2375. * @returns the updated Size.
  2376. */
  2377. set(width: number, height: number): Size;
  2378. /**
  2379. * Multiplies the width and height by numbers
  2380. * @param w factor to multiple the width by
  2381. * @param h factor to multiple the height by
  2382. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2383. */
  2384. multiplyByFloats(w: number, h: number): Size;
  2385. /**
  2386. * Clones the size
  2387. * @returns a new Size copied from the given one.
  2388. */
  2389. clone(): Size;
  2390. /**
  2391. * True if the current Size and the given one width and height are strictly equal.
  2392. * @param other the other size to compare against
  2393. * @returns True if the current Size and the given one width and height are strictly equal.
  2394. */
  2395. equals(other: Size): boolean;
  2396. /**
  2397. * The surface of the Size : width * height (float).
  2398. */
  2399. readonly surface: number;
  2400. /**
  2401. * Create a new size of zero
  2402. * @returns a new Size set to (0.0, 0.0)
  2403. */
  2404. static Zero(): Size;
  2405. /**
  2406. * Sums the width and height of two sizes
  2407. * @param otherSize size to add to this size
  2408. * @returns a new Size set as the addition result of the current Size and the given one.
  2409. */
  2410. add(otherSize: Size): Size;
  2411. /**
  2412. * Subtracts the width and height of two
  2413. * @param otherSize size to subtract to this size
  2414. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2415. */
  2416. subtract(otherSize: Size): Size;
  2417. /**
  2418. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2419. * @param start starting size to lerp between
  2420. * @param end end size to lerp between
  2421. * @param amount amount to lerp between the start and end values
  2422. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2423. */
  2424. static Lerp(start: Size, end: Size, amount: number): Size;
  2425. }
  2426. /**
  2427. * Class used to store quaternion data
  2428. * @see https://en.wikipedia.org/wiki/Quaternion
  2429. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2430. */
  2431. export class Quaternion {
  2432. /** defines the first component (0 by default) */
  2433. x: number;
  2434. /** defines the second component (0 by default) */
  2435. y: number;
  2436. /** defines the third component (0 by default) */
  2437. z: number;
  2438. /** defines the fourth component (1.0 by default) */
  2439. w: number;
  2440. /**
  2441. * Creates a new Quaternion from the given floats
  2442. * @param x defines the first component (0 by default)
  2443. * @param y defines the second component (0 by default)
  2444. * @param z defines the third component (0 by default)
  2445. * @param w defines the fourth component (1.0 by default)
  2446. */
  2447. constructor(
  2448. /** defines the first component (0 by default) */
  2449. x?: number,
  2450. /** defines the second component (0 by default) */
  2451. y?: number,
  2452. /** defines the third component (0 by default) */
  2453. z?: number,
  2454. /** defines the fourth component (1.0 by default) */
  2455. w?: number);
  2456. /**
  2457. * Gets a string representation for the current quaternion
  2458. * @returns a string with the Quaternion coordinates
  2459. */
  2460. toString(): string;
  2461. /**
  2462. * Gets the class name of the quaternion
  2463. * @returns the string "Quaternion"
  2464. */
  2465. getClassName(): string;
  2466. /**
  2467. * Gets a hash code for this quaternion
  2468. * @returns the quaternion hash code
  2469. */
  2470. getHashCode(): number;
  2471. /**
  2472. * Copy the quaternion to an array
  2473. * @returns a new array populated with 4 elements from the quaternion coordinates
  2474. */
  2475. asArray(): number[];
  2476. /**
  2477. * Check if two quaternions are equals
  2478. * @param otherQuaternion defines the second operand
  2479. * @return true if the current quaternion and the given one coordinates are strictly equals
  2480. */
  2481. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2482. /**
  2483. * Clone the current quaternion
  2484. * @returns a new quaternion copied from the current one
  2485. */
  2486. clone(): Quaternion;
  2487. /**
  2488. * Copy a quaternion to the current one
  2489. * @param other defines the other quaternion
  2490. * @returns the updated current quaternion
  2491. */
  2492. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2493. /**
  2494. * Updates the current quaternion with the given float coordinates
  2495. * @param x defines the x coordinate
  2496. * @param y defines the y coordinate
  2497. * @param z defines the z coordinate
  2498. * @param w defines the w coordinate
  2499. * @returns the updated current quaternion
  2500. */
  2501. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2502. /**
  2503. * Updates the current quaternion from the given float coordinates
  2504. * @param x defines the x coordinate
  2505. * @param y defines the y coordinate
  2506. * @param z defines the z coordinate
  2507. * @param w defines the w coordinate
  2508. * @returns the updated current quaternion
  2509. */
  2510. set(x: number, y: number, z: number, w: number): Quaternion;
  2511. /**
  2512. * Adds two quaternions
  2513. * @param other defines the second operand
  2514. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2515. */
  2516. add(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Add a quaternion to the current one
  2519. * @param other defines the quaternion to add
  2520. * @returns the current quaternion
  2521. */
  2522. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2523. /**
  2524. * Subtract two quaternions
  2525. * @param other defines the second operand
  2526. * @returns a new quaternion as the subtraction result of the given one from the current one
  2527. */
  2528. subtract(other: Quaternion): Quaternion;
  2529. /**
  2530. * Multiplies the current quaternion by a scale factor
  2531. * @param value defines the scale factor
  2532. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2533. */
  2534. scale(value: number): Quaternion;
  2535. /**
  2536. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2537. * @param scale defines the scale factor
  2538. * @param result defines the Quaternion object where to store the result
  2539. * @returns the unmodified current quaternion
  2540. */
  2541. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2542. /**
  2543. * Multiplies in place the current quaternion by a scale factor
  2544. * @param value defines the scale factor
  2545. * @returns the current modified quaternion
  2546. */
  2547. scaleInPlace(value: number): Quaternion;
  2548. /**
  2549. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2550. * @param scale defines the scale factor
  2551. * @param result defines the Quaternion object where to store the result
  2552. * @returns the unmodified current quaternion
  2553. */
  2554. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2555. /**
  2556. * Multiplies two quaternions
  2557. * @param q1 defines the second operand
  2558. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2559. */
  2560. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2561. /**
  2562. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2563. * @param q1 defines the second operand
  2564. * @param result defines the target quaternion
  2565. * @returns the current quaternion
  2566. */
  2567. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2568. /**
  2569. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2570. * @param q1 defines the second operand
  2571. * @returns the currentupdated quaternion
  2572. */
  2573. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2574. /**
  2575. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2576. * @param ref defines the target quaternion
  2577. * @returns the current quaternion
  2578. */
  2579. conjugateToRef(ref: Quaternion): Quaternion;
  2580. /**
  2581. * Conjugates in place (1-q) the current quaternion
  2582. * @returns the current updated quaternion
  2583. */
  2584. conjugateInPlace(): Quaternion;
  2585. /**
  2586. * Conjugates in place (1-q) the current quaternion
  2587. * @returns a new quaternion
  2588. */
  2589. conjugate(): Quaternion;
  2590. /**
  2591. * Gets length of current quaternion
  2592. * @returns the quaternion length (float)
  2593. */
  2594. length(): number;
  2595. /**
  2596. * Normalize in place the current quaternion
  2597. * @returns the current updated quaternion
  2598. */
  2599. normalize(): Quaternion;
  2600. /**
  2601. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2602. * @param order is a reserved parameter and is ignore for now
  2603. * @returns a new Vector3 containing the Euler angles
  2604. */
  2605. toEulerAngles(order?: string): Vector3;
  2606. /**
  2607. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2608. * @param result defines the vector which will be filled with the Euler angles
  2609. * @param order is a reserved parameter and is ignore for now
  2610. * @returns the current unchanged quaternion
  2611. */
  2612. toEulerAnglesToRef(result: Vector3): Quaternion;
  2613. /**
  2614. * Updates the given rotation matrix with the current quaternion values
  2615. * @param result defines the target matrix
  2616. * @returns the current unchanged quaternion
  2617. */
  2618. toRotationMatrix(result: Matrix): Quaternion;
  2619. /**
  2620. * Updates the current quaternion from the given rotation matrix values
  2621. * @param matrix defines the source matrix
  2622. * @returns the current updated quaternion
  2623. */
  2624. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2625. /**
  2626. * Creates a new quaternion from a rotation matrix
  2627. * @param matrix defines the source matrix
  2628. * @returns a new quaternion created from the given rotation matrix values
  2629. */
  2630. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2631. /**
  2632. * Updates the given quaternion with the given rotation matrix values
  2633. * @param matrix defines the source matrix
  2634. * @param result defines the target quaternion
  2635. */
  2636. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2637. /**
  2638. * Returns the dot product (float) between the quaternions "left" and "right"
  2639. * @param left defines the left operand
  2640. * @param right defines the right operand
  2641. * @returns the dot product
  2642. */
  2643. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2644. /**
  2645. * Checks if the two quaternions are close to each other
  2646. * @param quat0 defines the first quaternion to check
  2647. * @param quat1 defines the second quaternion to check
  2648. * @returns true if the two quaternions are close to each other
  2649. */
  2650. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2651. /**
  2652. * Creates an empty quaternion
  2653. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2654. */
  2655. static Zero(): Quaternion;
  2656. /**
  2657. * Inverse a given quaternion
  2658. * @param q defines the source quaternion
  2659. * @returns a new quaternion as the inverted current quaternion
  2660. */
  2661. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2662. /**
  2663. * Inverse a given quaternion
  2664. * @param q defines the source quaternion
  2665. * @param result the quaternion the result will be stored in
  2666. * @returns the result quaternion
  2667. */
  2668. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2669. /**
  2670. * Creates an identity quaternion
  2671. * @returns the identity quaternion
  2672. */
  2673. static Identity(): Quaternion;
  2674. /**
  2675. * Gets a boolean indicating if the given quaternion is identity
  2676. * @param quaternion defines the quaternion to check
  2677. * @returns true if the quaternion is identity
  2678. */
  2679. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2680. /**
  2681. * Creates a quaternion from a rotation around an axis
  2682. * @param axis defines the axis to use
  2683. * @param angle defines the angle to use
  2684. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2685. */
  2686. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2687. /**
  2688. * Creates a rotation around an axis and stores it into the given quaternion
  2689. * @param axis defines the axis to use
  2690. * @param angle defines the angle to use
  2691. * @param result defines the target quaternion
  2692. * @returns the target quaternion
  2693. */
  2694. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2695. /**
  2696. * Creates a new quaternion from data stored into an array
  2697. * @param array defines the data source
  2698. * @param offset defines the offset in the source array where the data starts
  2699. * @returns a new quaternion
  2700. */
  2701. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2702. /**
  2703. * Create a quaternion from Euler rotation angles
  2704. * @param x Pitch
  2705. * @param y Yaw
  2706. * @param z Roll
  2707. * @returns the new Quaternion
  2708. */
  2709. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2710. /**
  2711. * Updates a quaternion from Euler rotation angles
  2712. * @param x Pitch
  2713. * @param y Yaw
  2714. * @param z Roll
  2715. * @param result the quaternion to store the result
  2716. * @returns the updated quaternion
  2717. */
  2718. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Create a quaternion from Euler rotation vector
  2721. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2722. * @returns the new Quaternion
  2723. */
  2724. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2725. /**
  2726. * Updates a quaternion from Euler rotation vector
  2727. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2728. * @param result the quaternion to store the result
  2729. * @returns the updated quaternion
  2730. */
  2731. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2732. /**
  2733. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2734. * @param yaw defines the rotation around Y axis
  2735. * @param pitch defines the rotation around X axis
  2736. * @param roll defines the rotation around Z axis
  2737. * @returns the new quaternion
  2738. */
  2739. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2740. /**
  2741. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2742. * @param yaw defines the rotation around Y axis
  2743. * @param pitch defines the rotation around X axis
  2744. * @param roll defines the rotation around Z axis
  2745. * @param result defines the target quaternion
  2746. */
  2747. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2748. /**
  2749. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2750. * @param alpha defines the rotation around first axis
  2751. * @param beta defines the rotation around second axis
  2752. * @param gamma defines the rotation around third axis
  2753. * @returns the new quaternion
  2754. */
  2755. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2758. * @param alpha defines the rotation around first axis
  2759. * @param beta defines the rotation around second axis
  2760. * @param gamma defines the rotation around third axis
  2761. * @param result defines the target quaternion
  2762. */
  2763. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2764. /**
  2765. * 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)
  2766. * @param axis1 defines the first axis
  2767. * @param axis2 defines the second axis
  2768. * @param axis3 defines the third axis
  2769. * @returns the new quaternion
  2770. */
  2771. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2772. /**
  2773. * 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
  2774. * @param axis1 defines the first axis
  2775. * @param axis2 defines the second axis
  2776. * @param axis3 defines the third axis
  2777. * @param ref defines the target quaternion
  2778. */
  2779. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2780. /**
  2781. * Interpolates between two quaternions
  2782. * @param left defines first quaternion
  2783. * @param right defines second quaternion
  2784. * @param amount defines the gradient to use
  2785. * @returns the new interpolated quaternion
  2786. */
  2787. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2788. /**
  2789. * Interpolates between two quaternions and stores it into a target quaternion
  2790. * @param left defines first quaternion
  2791. * @param right defines second quaternion
  2792. * @param amount defines the gradient to use
  2793. * @param result defines the target quaternion
  2794. */
  2795. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2796. /**
  2797. * Interpolate between two quaternions using Hermite interpolation
  2798. * @param value1 defines first quaternion
  2799. * @param tangent1 defines the incoming tangent
  2800. * @param value2 defines second quaternion
  2801. * @param tangent2 defines the outgoing tangent
  2802. * @param amount defines the target quaternion
  2803. * @returns the new interpolated quaternion
  2804. */
  2805. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2806. }
  2807. /**
  2808. * Class used to store matrix data (4x4)
  2809. */
  2810. export class Matrix {
  2811. private static _updateFlagSeed;
  2812. private static _identityReadOnly;
  2813. private _isIdentity;
  2814. private _isIdentityDirty;
  2815. private _isIdentity3x2;
  2816. private _isIdentity3x2Dirty;
  2817. /**
  2818. * Gets the update flag of the matrix which is an unique number for the matrix.
  2819. * It will be incremented every time the matrix data change.
  2820. * You can use it to speed the comparison between two versions of the same matrix.
  2821. */
  2822. updateFlag: number;
  2823. private readonly _m;
  2824. /**
  2825. * Gets the internal data of the matrix
  2826. */
  2827. readonly m: DeepImmutable<Float32Array>;
  2828. /** @hidden */
  2829. _markAsUpdated(): void;
  2830. /** @hidden */
  2831. private _updateIdentityStatus;
  2832. /**
  2833. * Creates an empty matrix (filled with zeros)
  2834. */
  2835. constructor();
  2836. /**
  2837. * Check if the current matrix is identity
  2838. * @returns true is the matrix is the identity matrix
  2839. */
  2840. isIdentity(): boolean;
  2841. /**
  2842. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2843. * @returns true is the matrix is the identity matrix
  2844. */
  2845. isIdentityAs3x2(): boolean;
  2846. /**
  2847. * Gets the determinant of the matrix
  2848. * @returns the matrix determinant
  2849. */
  2850. determinant(): number;
  2851. /**
  2852. * Returns the matrix as a Float32Array
  2853. * @returns the matrix underlying array
  2854. */
  2855. toArray(): DeepImmutable<Float32Array>;
  2856. /**
  2857. * Returns the matrix as a Float32Array
  2858. * @returns the matrix underlying array.
  2859. */
  2860. asArray(): DeepImmutable<Float32Array>;
  2861. /**
  2862. * Inverts the current matrix in place
  2863. * @returns the current inverted matrix
  2864. */
  2865. invert(): Matrix;
  2866. /**
  2867. * Sets all the matrix elements to zero
  2868. * @returns the current matrix
  2869. */
  2870. reset(): Matrix;
  2871. /**
  2872. * Adds the current matrix with a second one
  2873. * @param other defines the matrix to add
  2874. * @returns a new matrix as the addition of the current matrix and the given one
  2875. */
  2876. add(other: DeepImmutable<Matrix>): Matrix;
  2877. /**
  2878. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2879. * @param other defines the matrix to add
  2880. * @param result defines the target matrix
  2881. * @returns the current matrix
  2882. */
  2883. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2884. /**
  2885. * Adds in place the given matrix to the current matrix
  2886. * @param other defines the second operand
  2887. * @returns the current updated matrix
  2888. */
  2889. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2890. /**
  2891. * Sets the given matrix to the current inverted Matrix
  2892. * @param other defines the target matrix
  2893. * @returns the unmodified current matrix
  2894. */
  2895. invertToRef(other: Matrix): Matrix;
  2896. /**
  2897. * add a value at the specified position in the current Matrix
  2898. * @param index the index of the value within the matrix. between 0 and 15.
  2899. * @param value the value to be added
  2900. * @returns the current updated matrix
  2901. */
  2902. addAtIndex(index: number, value: number): Matrix;
  2903. /**
  2904. * mutiply the specified position in the current Matrix by a value
  2905. * @param index the index of the value within the matrix. between 0 and 15.
  2906. * @param value the value to be added
  2907. * @returns the current updated matrix
  2908. */
  2909. multiplyAtIndex(index: number, value: number): Matrix;
  2910. /**
  2911. * Inserts the translation vector (using 3 floats) in the current matrix
  2912. * @param x defines the 1st component of the translation
  2913. * @param y defines the 2nd component of the translation
  2914. * @param z defines the 3rd component of the translation
  2915. * @returns the current updated matrix
  2916. */
  2917. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2918. /**
  2919. * Inserts the translation vector in the current matrix
  2920. * @param vector3 defines the translation to insert
  2921. * @returns the current updated matrix
  2922. */
  2923. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2924. /**
  2925. * Gets the translation value of the current matrix
  2926. * @returns a new Vector3 as the extracted translation from the matrix
  2927. */
  2928. getTranslation(): Vector3;
  2929. /**
  2930. * Fill a Vector3 with the extracted translation from the matrix
  2931. * @param result defines the Vector3 where to store the translation
  2932. * @returns the current matrix
  2933. */
  2934. getTranslationToRef(result: Vector3): Matrix;
  2935. /**
  2936. * Remove rotation and scaling part from the matrix
  2937. * @returns the updated matrix
  2938. */
  2939. removeRotationAndScaling(): Matrix;
  2940. /**
  2941. * Multiply two matrices
  2942. * @param other defines the second operand
  2943. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2944. */
  2945. multiply(other: DeepImmutable<Matrix>): Matrix;
  2946. /**
  2947. * Copy the current matrix from the given one
  2948. * @param other defines the source matrix
  2949. * @returns the current updated matrix
  2950. */
  2951. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2952. /**
  2953. * Populates the given array from the starting index with the current matrix values
  2954. * @param array defines the target array
  2955. * @param offset defines the offset in the target array where to start storing values
  2956. * @returns the current matrix
  2957. */
  2958. copyToArray(array: Float32Array, offset?: number): Matrix;
  2959. /**
  2960. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2961. * @param other defines the second operand
  2962. * @param result defines the matrix where to store the multiplication
  2963. * @returns the current matrix
  2964. */
  2965. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2966. /**
  2967. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2968. * @param other defines the second operand
  2969. * @param result defines the array where to store the multiplication
  2970. * @param offset defines the offset in the target array where to start storing values
  2971. * @returns the current matrix
  2972. */
  2973. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2974. /**
  2975. * Check equality between this matrix and a second one
  2976. * @param value defines the second matrix to compare
  2977. * @returns true is the current matrix and the given one values are strictly equal
  2978. */
  2979. equals(value: DeepImmutable<Matrix>): boolean;
  2980. /**
  2981. * Clone the current matrix
  2982. * @returns a new matrix from the current matrix
  2983. */
  2984. clone(): Matrix;
  2985. /**
  2986. * Returns the name of the current matrix class
  2987. * @returns the string "Matrix"
  2988. */
  2989. getClassName(): string;
  2990. /**
  2991. * Gets the hash code of the current matrix
  2992. * @returns the hash code
  2993. */
  2994. getHashCode(): number;
  2995. /**
  2996. * Decomposes the current Matrix into a translation, rotation and scaling components
  2997. * @param scale defines the scale vector3 given as a reference to update
  2998. * @param rotation defines the rotation quaternion given as a reference to update
  2999. * @param translation defines the translation vector3 given as a reference to update
  3000. * @returns true if operation was successful
  3001. */
  3002. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3003. /**
  3004. * Gets specific row of the matrix
  3005. * @param index defines the number of the row to get
  3006. * @returns the index-th row of the current matrix as a new Vector4
  3007. */
  3008. getRow(index: number): Nullable<Vector4>;
  3009. /**
  3010. * Sets the index-th row of the current matrix to the vector4 values
  3011. * @param index defines the number of the row to set
  3012. * @param row defines the target vector4
  3013. * @returns the updated current matrix
  3014. */
  3015. setRow(index: number, row: Vector4): Matrix;
  3016. /**
  3017. * Compute the transpose of the matrix
  3018. * @returns the new transposed matrix
  3019. */
  3020. transpose(): Matrix;
  3021. /**
  3022. * Compute the transpose of the matrix and store it in a given matrix
  3023. * @param result defines the target matrix
  3024. * @returns the current matrix
  3025. */
  3026. transposeToRef(result: Matrix): Matrix;
  3027. /**
  3028. * Sets the index-th row of the current matrix with the given 4 x float values
  3029. * @param index defines the row index
  3030. * @param x defines the x component to set
  3031. * @param y defines the y component to set
  3032. * @param z defines the z component to set
  3033. * @param w defines the w component to set
  3034. * @returns the updated current matrix
  3035. */
  3036. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3037. /**
  3038. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3039. * @param scale defines the scale factor
  3040. * @returns a new matrix
  3041. */
  3042. scale(scale: number): Matrix;
  3043. /**
  3044. * Scale the current matrix values by a factor to a given result matrix
  3045. * @param scale defines the scale factor
  3046. * @param result defines the matrix to store the result
  3047. * @returns the current matrix
  3048. */
  3049. scaleToRef(scale: number, result: Matrix): Matrix;
  3050. /**
  3051. * Scale the current matrix values by a factor and add the result to a given matrix
  3052. * @param scale defines the scale factor
  3053. * @param result defines the Matrix to store the result
  3054. * @returns the current matrix
  3055. */
  3056. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3057. /**
  3058. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3059. * @param ref matrix to store the result
  3060. */
  3061. toNormalMatrix(ref: Matrix): void;
  3062. /**
  3063. * Gets only rotation part of the current matrix
  3064. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3065. */
  3066. getRotationMatrix(): Matrix;
  3067. /**
  3068. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3069. * @param result defines the target matrix to store data to
  3070. * @returns the current matrix
  3071. */
  3072. getRotationMatrixToRef(result: Matrix): Matrix;
  3073. /**
  3074. * Toggles model matrix from being right handed to left handed in place and vice versa
  3075. */
  3076. toggleModelMatrixHandInPlace(): void;
  3077. /**
  3078. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3079. */
  3080. toggleProjectionMatrixHandInPlace(): void;
  3081. /**
  3082. * Creates a matrix from an array
  3083. * @param array defines the source array
  3084. * @param offset defines an offset in the source array
  3085. * @returns a new Matrix set from the starting index of the given array
  3086. */
  3087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3088. /**
  3089. * Copy the content of an array into a given matrix
  3090. * @param array defines the source array
  3091. * @param offset defines an offset in the source array
  3092. * @param result defines the target matrix
  3093. */
  3094. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3095. /**
  3096. * Stores an array into a matrix after having multiplied each component by a given factor
  3097. * @param array defines the source array
  3098. * @param offset defines the offset in the source array
  3099. * @param scale defines the scaling factor
  3100. * @param result defines the target matrix
  3101. */
  3102. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3103. /**
  3104. * Gets an identity matrix that must not be updated
  3105. */
  3106. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3107. /**
  3108. * Stores a list of values (16) inside a given matrix
  3109. * @param initialM11 defines 1st value of 1st row
  3110. * @param initialM12 defines 2nd value of 1st row
  3111. * @param initialM13 defines 3rd value of 1st row
  3112. * @param initialM14 defines 4th value of 1st row
  3113. * @param initialM21 defines 1st value of 2nd row
  3114. * @param initialM22 defines 2nd value of 2nd row
  3115. * @param initialM23 defines 3rd value of 2nd row
  3116. * @param initialM24 defines 4th value of 2nd row
  3117. * @param initialM31 defines 1st value of 3rd row
  3118. * @param initialM32 defines 2nd value of 3rd row
  3119. * @param initialM33 defines 3rd value of 3rd row
  3120. * @param initialM34 defines 4th value of 3rd row
  3121. * @param initialM41 defines 1st value of 4th row
  3122. * @param initialM42 defines 2nd value of 4th row
  3123. * @param initialM43 defines 3rd value of 4th row
  3124. * @param initialM44 defines 4th value of 4th row
  3125. * @param result defines the target matrix
  3126. */
  3127. 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;
  3128. /**
  3129. * Creates new matrix from a list of values (16)
  3130. * @param initialM11 defines 1st value of 1st row
  3131. * @param initialM12 defines 2nd value of 1st row
  3132. * @param initialM13 defines 3rd value of 1st row
  3133. * @param initialM14 defines 4th value of 1st row
  3134. * @param initialM21 defines 1st value of 2nd row
  3135. * @param initialM22 defines 2nd value of 2nd row
  3136. * @param initialM23 defines 3rd value of 2nd row
  3137. * @param initialM24 defines 4th value of 2nd row
  3138. * @param initialM31 defines 1st value of 3rd row
  3139. * @param initialM32 defines 2nd value of 3rd row
  3140. * @param initialM33 defines 3rd value of 3rd row
  3141. * @param initialM34 defines 4th value of 3rd row
  3142. * @param initialM41 defines 1st value of 4th row
  3143. * @param initialM42 defines 2nd value of 4th row
  3144. * @param initialM43 defines 3rd value of 4th row
  3145. * @param initialM44 defines 4th value of 4th row
  3146. * @returns the new matrix
  3147. */
  3148. 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;
  3149. /**
  3150. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3151. * @param scale defines the scale vector3
  3152. * @param rotation defines the rotation quaternion
  3153. * @param translation defines the translation vector3
  3154. * @returns a new matrix
  3155. */
  3156. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3157. /**
  3158. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3159. * @param scale defines the scale vector3
  3160. * @param rotation defines the rotation quaternion
  3161. * @param translation defines the translation vector3
  3162. * @param result defines the target matrix
  3163. */
  3164. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3165. /**
  3166. * Creates a new identity matrix
  3167. * @returns a new identity matrix
  3168. */
  3169. static Identity(): Matrix;
  3170. /**
  3171. * Creates a new identity matrix and stores the result in a given matrix
  3172. * @param result defines the target matrix
  3173. */
  3174. static IdentityToRef(result: Matrix): void;
  3175. /**
  3176. * Creates a new zero matrix
  3177. * @returns a new zero matrix
  3178. */
  3179. static Zero(): Matrix;
  3180. /**
  3181. * Creates a new rotation matrix for "angle" radians around the X axis
  3182. * @param angle defines the angle (in radians) to use
  3183. * @return the new matrix
  3184. */
  3185. static RotationX(angle: number): Matrix;
  3186. /**
  3187. * Creates a new matrix as the invert of a given matrix
  3188. * @param source defines the source matrix
  3189. * @returns the new matrix
  3190. */
  3191. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3192. /**
  3193. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3194. * @param angle defines the angle (in radians) to use
  3195. * @param result defines the target matrix
  3196. */
  3197. static RotationXToRef(angle: number, result: Matrix): void;
  3198. /**
  3199. * Creates a new rotation matrix for "angle" radians around the Y axis
  3200. * @param angle defines the angle (in radians) to use
  3201. * @return the new matrix
  3202. */
  3203. static RotationY(angle: number): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3206. * @param angle defines the angle (in radians) to use
  3207. * @param result defines the target matrix
  3208. */
  3209. static RotationYToRef(angle: number, result: Matrix): void;
  3210. /**
  3211. * Creates a new rotation matrix for "angle" radians around the Z axis
  3212. * @param angle defines the angle (in radians) to use
  3213. * @return the new matrix
  3214. */
  3215. static RotationZ(angle: number): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the Z 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 RotationZToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the given axis
  3224. * @param axis defines the axis to use
  3225. * @param angle defines the angle (in radians) to use
  3226. * @return the new matrix
  3227. */
  3228. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3231. * @param axis defines the axis to use
  3232. * @param angle defines the angle (in radians) to use
  3233. * @param result defines the target matrix
  3234. */
  3235. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3236. /**
  3237. * Creates a rotation matrix
  3238. * @param yaw defines the yaw angle in radians (Y axis)
  3239. * @param pitch defines the pitch angle in radians (X axis)
  3240. * @param roll defines the roll angle in radians (X axis)
  3241. * @returns the new rotation matrix
  3242. */
  3243. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3244. /**
  3245. * Creates a rotation matrix and stores it in a given matrix
  3246. * @param yaw defines the yaw angle in radians (Y axis)
  3247. * @param pitch defines the pitch angle in radians (X axis)
  3248. * @param roll defines the roll angle in radians (X axis)
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3252. /**
  3253. * Creates a scaling matrix
  3254. * @param x defines the scale factor on X axis
  3255. * @param y defines the scale factor on Y axis
  3256. * @param z defines the scale factor on Z axis
  3257. * @returns the new matrix
  3258. */
  3259. static Scaling(x: number, y: number, z: number): Matrix;
  3260. /**
  3261. * Creates a scaling matrix and stores it in a given matrix
  3262. * @param x defines the scale factor on X axis
  3263. * @param y defines the scale factor on Y axis
  3264. * @param z defines the scale factor on Z axis
  3265. * @param result defines the target matrix
  3266. */
  3267. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3268. /**
  3269. * Creates a translation matrix
  3270. * @param x defines the translation on X axis
  3271. * @param y defines the translation on Y axis
  3272. * @param z defines the translationon Z axis
  3273. * @returns the new matrix
  3274. */
  3275. static Translation(x: number, y: number, z: number): Matrix;
  3276. /**
  3277. * Creates a translation matrix and stores it in a given matrix
  3278. * @param x defines the translation on X axis
  3279. * @param y defines the translation on Y axis
  3280. * @param z defines the translationon Z axis
  3281. * @param result defines the target matrix
  3282. */
  3283. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3284. /**
  3285. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3286. * @param startValue defines the start value
  3287. * @param endValue defines the end value
  3288. * @param gradient defines the gradient factor
  3289. * @returns the new matrix
  3290. */
  3291. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3292. /**
  3293. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3294. * @param startValue defines the start value
  3295. * @param endValue defines the end value
  3296. * @param gradient defines the gradient factor
  3297. * @param result defines the Matrix object where to store data
  3298. */
  3299. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3300. /**
  3301. * Builds a new matrix whose values are computed by:
  3302. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3303. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3304. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3305. * @param startValue defines the first matrix
  3306. * @param endValue defines the second matrix
  3307. * @param gradient defines the gradient between the two matrices
  3308. * @returns the new matrix
  3309. */
  3310. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3311. /**
  3312. * Update a matrix to values which are computed by:
  3313. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3314. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3315. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3316. * @param startValue defines the first matrix
  3317. * @param endValue defines the second matrix
  3318. * @param gradient defines the gradient between the two matrices
  3319. * @param result defines the target matrix
  3320. */
  3321. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3322. /**
  3323. * 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"
  3324. * This function works in left handed mode
  3325. * @param eye defines the final position of the entity
  3326. * @param target defines where the entity should look at
  3327. * @param up defines the up vector for the entity
  3328. * @returns the new matrix
  3329. */
  3330. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3331. /**
  3332. * 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".
  3333. * This function works in left handed mode
  3334. * @param eye defines the final position of the entity
  3335. * @param target defines where the entity should look at
  3336. * @param up defines the up vector for the entity
  3337. * @param result defines the target matrix
  3338. */
  3339. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3340. /**
  3341. * 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"
  3342. * This function works in right handed mode
  3343. * @param eye defines the final position of the entity
  3344. * @param target defines where the entity should look at
  3345. * @param up defines the up vector for the entity
  3346. * @returns the new matrix
  3347. */
  3348. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3349. /**
  3350. * 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".
  3351. * This function works in right handed mode
  3352. * @param eye defines the final position of the entity
  3353. * @param target defines where the entity should look at
  3354. * @param up defines the up vector for the entity
  3355. * @param result defines the target matrix
  3356. */
  3357. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3358. /**
  3359. * Create a left-handed orthographic projection matrix
  3360. * @param width defines the viewport width
  3361. * @param height defines the viewport height
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @returns a new matrix as a left-handed orthographic projection matrix
  3365. */
  3366. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3367. /**
  3368. * Store a left-handed orthographic projection to a given matrix
  3369. * @param width defines the viewport width
  3370. * @param height defines the viewport height
  3371. * @param znear defines the near clip plane
  3372. * @param zfar defines the far clip plane
  3373. * @param result defines the target matrix
  3374. */
  3375. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3376. /**
  3377. * Create a left-handed orthographic projection matrix
  3378. * @param left defines the viewport left coordinate
  3379. * @param right defines the viewport right coordinate
  3380. * @param bottom defines the viewport bottom coordinate
  3381. * @param top defines the viewport top coordinate
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a left-handed orthographic projection matrix
  3385. */
  3386. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Stores a left-handed orthographic projection into a given matrix
  3389. * @param left defines the viewport left coordinate
  3390. * @param right defines the viewport right coordinate
  3391. * @param bottom defines the viewport bottom coordinate
  3392. * @param top defines the viewport top coordinate
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. */
  3397. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3398. /**
  3399. * Creates a right-handed orthographic projection matrix
  3400. * @param left defines the viewport left coordinate
  3401. * @param right defines the viewport right coordinate
  3402. * @param bottom defines the viewport bottom coordinate
  3403. * @param top defines the viewport top coordinate
  3404. * @param znear defines the near clip plane
  3405. * @param zfar defines the far clip plane
  3406. * @returns a new matrix as a right-handed orthographic projection matrix
  3407. */
  3408. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3409. /**
  3410. * Stores a right-handed orthographic projection into a given matrix
  3411. * @param left defines the viewport left coordinate
  3412. * @param right defines the viewport right coordinate
  3413. * @param bottom defines the viewport bottom coordinate
  3414. * @param top defines the viewport top coordinate
  3415. * @param znear defines the near clip plane
  3416. * @param zfar defines the far clip plane
  3417. * @param result defines the target matrix
  3418. */
  3419. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3420. /**
  3421. * Creates a left-handed perspective projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed perspective projection matrix
  3427. */
  3428. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Creates a left-handed perspective projection matrix
  3431. * @param fov defines the horizontal field of view
  3432. * @param aspect defines the aspect ratio
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @returns a new matrix as a left-handed perspective projection matrix
  3436. */
  3437. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3438. /**
  3439. * Stores a left-handed perspective projection into a given matrix
  3440. * @param fov defines the horizontal field of view
  3441. * @param aspect defines the aspect ratio
  3442. * @param znear defines the near clip plane
  3443. * @param zfar defines the far clip plane
  3444. * @param result defines the target matrix
  3445. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3446. */
  3447. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3448. /**
  3449. * Creates a right-handed perspective projection matrix
  3450. * @param fov defines the horizontal field of view
  3451. * @param aspect defines the aspect ratio
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @returns a new matrix as a right-handed perspective projection matrix
  3455. */
  3456. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3457. /**
  3458. * Stores a right-handed perspective projection into a given matrix
  3459. * @param fov defines the horizontal field of view
  3460. * @param aspect defines the aspect ratio
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @param result defines the target matrix
  3464. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3465. */
  3466. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3467. /**
  3468. * Stores a perspective projection for WebVR info a given matrix
  3469. * @param fov defines the field of view
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @param result defines the target matrix
  3473. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3474. */
  3475. static PerspectiveFovWebVRToRef(fov: {
  3476. upDegrees: number;
  3477. downDegrees: number;
  3478. leftDegrees: number;
  3479. rightDegrees: number;
  3480. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3481. /**
  3482. * Computes a complete transformation matrix
  3483. * @param viewport defines the viewport to use
  3484. * @param world defines the world matrix
  3485. * @param view defines the view matrix
  3486. * @param projection defines the projection matrix
  3487. * @param zmin defines the near clip plane
  3488. * @param zmax defines the far clip plane
  3489. * @returns the transformation matrix
  3490. */
  3491. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3492. /**
  3493. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3494. * @param matrix defines the matrix to use
  3495. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3496. */
  3497. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3498. /**
  3499. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3500. * @param matrix defines the matrix to use
  3501. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3502. */
  3503. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3504. /**
  3505. * Compute the transpose of a given matrix
  3506. * @param matrix defines the matrix to transpose
  3507. * @returns the new matrix
  3508. */
  3509. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3510. /**
  3511. * Compute the transpose of a matrix and store it in a target matrix
  3512. * @param matrix defines the matrix to transpose
  3513. * @param result defines the target matrix
  3514. */
  3515. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3516. /**
  3517. * Computes a reflection matrix from a plane
  3518. * @param plane defines the reflection plane
  3519. * @returns a new matrix
  3520. */
  3521. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3522. /**
  3523. * Computes a reflection matrix from a plane
  3524. * @param plane defines the reflection plane
  3525. * @param result defines the target matrix
  3526. */
  3527. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3528. /**
  3529. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3530. * @param xaxis defines the value of the 1st axis
  3531. * @param yaxis defines the value of the 2nd axis
  3532. * @param zaxis defines the value of the 3rd axis
  3533. * @param result defines the target matrix
  3534. */
  3535. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3536. /**
  3537. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3538. * @param quat defines the quaternion to use
  3539. * @param result defines the target matrix
  3540. */
  3541. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3542. }
  3543. /**
  3544. * Represens a plane by the equation ax + by + cz + d = 0
  3545. */
  3546. export class Plane {
  3547. /**
  3548. * Normal of the plane (a,b,c)
  3549. */
  3550. normal: Vector3;
  3551. /**
  3552. * d component of the plane
  3553. */
  3554. d: number;
  3555. /**
  3556. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3557. * @param a a component of the plane
  3558. * @param b b component of the plane
  3559. * @param c c component of the plane
  3560. * @param d d component of the plane
  3561. */
  3562. constructor(a: number, b: number, c: number, d: number);
  3563. /**
  3564. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3565. */
  3566. asArray(): number[];
  3567. /**
  3568. * @returns a new plane copied from the current Plane.
  3569. */
  3570. clone(): Plane;
  3571. /**
  3572. * @returns the string "Plane".
  3573. */
  3574. getClassName(): string;
  3575. /**
  3576. * @returns the Plane hash code.
  3577. */
  3578. getHashCode(): number;
  3579. /**
  3580. * Normalize the current Plane in place.
  3581. * @returns the updated Plane.
  3582. */
  3583. normalize(): Plane;
  3584. /**
  3585. * Applies a transformation the plane and returns the result
  3586. * @param transformation the transformation matrix to be applied to the plane
  3587. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3588. */
  3589. transform(transformation: DeepImmutable<Matrix>): Plane;
  3590. /**
  3591. * Calcualtte the dot product between the point and the plane normal
  3592. * @param point point to calculate the dot product with
  3593. * @returns the dot product (float) of the point coordinates and the plane normal.
  3594. */
  3595. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3596. /**
  3597. * Updates the current Plane from the plane defined by the three given points.
  3598. * @param point1 one of the points used to contruct the plane
  3599. * @param point2 one of the points used to contruct the plane
  3600. * @param point3 one of the points used to contruct the plane
  3601. * @returns the updated Plane.
  3602. */
  3603. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3604. /**
  3605. * Checks if the plane is facing a given direction
  3606. * @param direction the direction to check if the plane is facing
  3607. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3608. * @returns True is the vector "direction" is the same side than the plane normal.
  3609. */
  3610. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3611. /**
  3612. * Calculates the distance to a point
  3613. * @param point point to calculate distance to
  3614. * @returns the signed distance (float) from the given point to the Plane.
  3615. */
  3616. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3617. /**
  3618. * Creates a plane from an array
  3619. * @param array the array to create a plane from
  3620. * @returns a new Plane from the given array.
  3621. */
  3622. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3623. /**
  3624. * Creates a plane from three points
  3625. * @param point1 point used to create the plane
  3626. * @param point2 point used to create the plane
  3627. * @param point3 point used to create the plane
  3628. * @returns a new Plane defined by the three given points.
  3629. */
  3630. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3631. /**
  3632. * Creates a plane from an origin point and a normal
  3633. * @param origin origin of the plane to be constructed
  3634. * @param normal normal of the plane to be constructed
  3635. * @returns a new Plane the normal vector to this plane at the given origin point.
  3636. * Note : the vector "normal" is updated because normalized.
  3637. */
  3638. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3639. /**
  3640. * Calculates the distance from a plane and a point
  3641. * @param origin origin of the plane to be constructed
  3642. * @param normal normal of the plane to be constructed
  3643. * @param point point to calculate distance to
  3644. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3645. */
  3646. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3647. }
  3648. /**
  3649. * Class used to represent a viewport on screen
  3650. */
  3651. export class Viewport {
  3652. /** viewport left coordinate */
  3653. x: number;
  3654. /** viewport top coordinate */
  3655. y: number;
  3656. /**viewport width */
  3657. width: number;
  3658. /** viewport height */
  3659. height: number;
  3660. /**
  3661. * Creates a Viewport object located at (x, y) and sized (width, height)
  3662. * @param x defines viewport left coordinate
  3663. * @param y defines viewport top coordinate
  3664. * @param width defines the viewport width
  3665. * @param height defines the viewport height
  3666. */
  3667. constructor(
  3668. /** viewport left coordinate */
  3669. x: number,
  3670. /** viewport top coordinate */
  3671. y: number,
  3672. /**viewport width */
  3673. width: number,
  3674. /** viewport height */
  3675. height: number);
  3676. /**
  3677. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3678. * @param renderWidth defines the rendering width
  3679. * @param renderHeight defines the rendering height
  3680. * @returns a new Viewport
  3681. */
  3682. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3683. /**
  3684. * Returns a new Viewport copied from the current one
  3685. * @returns a new Viewport
  3686. */
  3687. clone(): Viewport;
  3688. }
  3689. /**
  3690. * Reprasents a camera frustum
  3691. */
  3692. export class Frustum {
  3693. /**
  3694. * Gets the planes representing the frustum
  3695. * @param transform matrix to be applied to the returned planes
  3696. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3697. */
  3698. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3699. /**
  3700. * Gets the near frustum plane transformed by the transform matrix
  3701. * @param transform transformation matrix to be applied to the resulting frustum plane
  3702. * @param frustumPlane the resuling frustum plane
  3703. */
  3704. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3705. /**
  3706. * Gets the far frustum plane transformed by the transform matrix
  3707. * @param transform transformation matrix to be applied to the resulting frustum plane
  3708. * @param frustumPlane the resuling frustum plane
  3709. */
  3710. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3711. /**
  3712. * Gets the left frustum plane transformed by the transform matrix
  3713. * @param transform transformation matrix to be applied to the resulting frustum plane
  3714. * @param frustumPlane the resuling frustum plane
  3715. */
  3716. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3717. /**
  3718. * Gets the right frustum plane transformed by the transform matrix
  3719. * @param transform transformation matrix to be applied to the resulting frustum plane
  3720. * @param frustumPlane the resuling frustum plane
  3721. */
  3722. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3723. /**
  3724. * Gets the top frustum plane transformed by the transform matrix
  3725. * @param transform transformation matrix to be applied to the resulting frustum plane
  3726. * @param frustumPlane the resuling frustum plane
  3727. */
  3728. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3729. /**
  3730. * Gets the bottom frustum plane transformed by the transform matrix
  3731. * @param transform transformation matrix to be applied to the resulting frustum plane
  3732. * @param frustumPlane the resuling frustum plane
  3733. */
  3734. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3735. /**
  3736. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3737. * @param transform transformation matrix to be applied to the resulting frustum planes
  3738. * @param frustumPlanes the resuling frustum planes
  3739. */
  3740. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3741. }
  3742. /** Defines supported spaces */
  3743. export enum Space {
  3744. /** Local (object) space */
  3745. LOCAL = 0,
  3746. /** World space */
  3747. WORLD = 1,
  3748. /** Bone space */
  3749. BONE = 2
  3750. }
  3751. /** Defines the 3 main axes */
  3752. export class Axis {
  3753. /** X axis */
  3754. static X: Vector3;
  3755. /** Y axis */
  3756. static Y: Vector3;
  3757. /** Z axis */
  3758. static Z: Vector3;
  3759. }
  3760. /** Class used to represent a Bezier curve */
  3761. export class BezierCurve {
  3762. /**
  3763. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3764. * @param t defines the time
  3765. * @param x1 defines the left coordinate on X axis
  3766. * @param y1 defines the left coordinate on Y axis
  3767. * @param x2 defines the right coordinate on X axis
  3768. * @param y2 defines the right coordinate on Y axis
  3769. * @returns the interpolated value
  3770. */
  3771. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3772. }
  3773. /**
  3774. * Defines potential orientation for back face culling
  3775. */
  3776. export enum Orientation {
  3777. /**
  3778. * Clockwise
  3779. */
  3780. CW = 0,
  3781. /** Counter clockwise */
  3782. CCW = 1
  3783. }
  3784. /**
  3785. * Defines angle representation
  3786. */
  3787. export class Angle {
  3788. private _radians;
  3789. /**
  3790. * Creates an Angle object of "radians" radians (float).
  3791. */
  3792. constructor(radians: number);
  3793. /**
  3794. * Get value in degrees
  3795. * @returns the Angle value in degrees (float)
  3796. */
  3797. degrees(): number;
  3798. /**
  3799. * Get value in radians
  3800. * @returns the Angle value in radians (float)
  3801. */
  3802. radians(): number;
  3803. /**
  3804. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3805. * @param a defines first vector
  3806. * @param b defines second vector
  3807. * @returns a new Angle
  3808. */
  3809. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3810. /**
  3811. * Gets a new Angle object from the given float in radians
  3812. * @param radians defines the angle value in radians
  3813. * @returns a new Angle
  3814. */
  3815. static FromRadians(radians: number): Angle;
  3816. /**
  3817. * Gets a new Angle object from the given float in degrees
  3818. * @param degrees defines the angle value in degrees
  3819. * @returns a new Angle
  3820. */
  3821. static FromDegrees(degrees: number): Angle;
  3822. }
  3823. /**
  3824. * This represents an arc in a 2d space.
  3825. */
  3826. export class Arc2 {
  3827. /** Defines the start point of the arc */
  3828. startPoint: Vector2;
  3829. /** Defines the mid point of the arc */
  3830. midPoint: Vector2;
  3831. /** Defines the end point of the arc */
  3832. endPoint: Vector2;
  3833. /**
  3834. * Defines the center point of the arc.
  3835. */
  3836. centerPoint: Vector2;
  3837. /**
  3838. * Defines the radius of the arc.
  3839. */
  3840. radius: number;
  3841. /**
  3842. * Defines the angle of the arc (from mid point to end point).
  3843. */
  3844. angle: Angle;
  3845. /**
  3846. * Defines the start angle of the arc (from start point to middle point).
  3847. */
  3848. startAngle: Angle;
  3849. /**
  3850. * Defines the orientation of the arc (clock wise/counter clock wise).
  3851. */
  3852. orientation: Orientation;
  3853. /**
  3854. * Creates an Arc object from the three given points : start, middle and end.
  3855. * @param startPoint Defines the start point of the arc
  3856. * @param midPoint Defines the midlle point of the arc
  3857. * @param endPoint Defines the end point of the arc
  3858. */
  3859. constructor(
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2,
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2,
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2);
  3866. }
  3867. /**
  3868. * Represents a 2D path made up of multiple 2D points
  3869. */
  3870. export class Path2 {
  3871. private _points;
  3872. private _length;
  3873. /**
  3874. * If the path start and end point are the same
  3875. */
  3876. closed: boolean;
  3877. /**
  3878. * Creates a Path2 object from the starting 2D coordinates x and y.
  3879. * @param x the starting points x value
  3880. * @param y the starting points y value
  3881. */
  3882. constructor(x: number, y: number);
  3883. /**
  3884. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3885. * @param x the added points x value
  3886. * @param y the added points y value
  3887. * @returns the updated Path2.
  3888. */
  3889. addLineTo(x: number, y: number): Path2;
  3890. /**
  3891. * 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.
  3892. * @param midX middle point x value
  3893. * @param midY middle point y value
  3894. * @param endX end point x value
  3895. * @param endY end point y value
  3896. * @param numberOfSegments (default: 36)
  3897. * @returns the updated Path2.
  3898. */
  3899. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3900. /**
  3901. * Closes the Path2.
  3902. * @returns the Path2.
  3903. */
  3904. close(): Path2;
  3905. /**
  3906. * Gets the sum of the distance between each sequential point in the path
  3907. * @returns the Path2 total length (float).
  3908. */
  3909. length(): number;
  3910. /**
  3911. * Gets the points which construct the path
  3912. * @returns the Path2 internal array of points.
  3913. */
  3914. getPoints(): Vector2[];
  3915. /**
  3916. * Retreives the point at the distance aways from the starting point
  3917. * @param normalizedLengthPosition the length along the path to retreive the point from
  3918. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3919. */
  3920. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3921. /**
  3922. * Creates a new path starting from an x and y position
  3923. * @param x starting x value
  3924. * @param y starting y value
  3925. * @returns a new Path2 starting at the coordinates (x, y).
  3926. */
  3927. static StartingAt(x: number, y: number): Path2;
  3928. }
  3929. /**
  3930. * Represents a 3D path made up of multiple 3D points
  3931. */
  3932. export class Path3D {
  3933. /**
  3934. * an array of Vector3, the curve axis of the Path3D
  3935. */
  3936. path: Vector3[];
  3937. private _curve;
  3938. private _distances;
  3939. private _tangents;
  3940. private _normals;
  3941. private _binormals;
  3942. private _raw;
  3943. /**
  3944. * new Path3D(path, normal, raw)
  3945. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3946. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3947. * @param path an array of Vector3, the curve axis of the Path3D
  3948. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3949. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3950. */
  3951. constructor(
  3952. /**
  3953. * an array of Vector3, the curve axis of the Path3D
  3954. */
  3955. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3956. /**
  3957. * Returns the Path3D array of successive Vector3 designing its curve.
  3958. * @returns the Path3D array of successive Vector3 designing its curve.
  3959. */
  3960. getCurve(): Vector3[];
  3961. /**
  3962. * Returns an array populated with tangent vectors on each Path3D curve point.
  3963. * @returns an array populated with tangent vectors on each Path3D curve point.
  3964. */
  3965. getTangents(): Vector3[];
  3966. /**
  3967. * Returns an array populated with normal vectors on each Path3D curve point.
  3968. * @returns an array populated with normal vectors on each Path3D curve point.
  3969. */
  3970. getNormals(): Vector3[];
  3971. /**
  3972. * Returns an array populated with binormal vectors on each Path3D curve point.
  3973. * @returns an array populated with binormal vectors on each Path3D curve point.
  3974. */
  3975. getBinormals(): Vector3[];
  3976. /**
  3977. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  3978. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  3979. */
  3980. getDistances(): number[];
  3981. /**
  3982. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  3983. * @param path path which all values are copied into the curves points
  3984. * @param firstNormal which should be projected onto the curve
  3985. * @returns the same object updated.
  3986. */
  3987. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  3988. private _compute;
  3989. private _getFirstNonNullVector;
  3990. private _getLastNonNullVector;
  3991. private _normalVector;
  3992. }
  3993. /**
  3994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  3995. * A Curve3 is designed from a series of successive Vector3.
  3996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  3997. */
  3998. export class Curve3 {
  3999. private _points;
  4000. private _length;
  4001. /**
  4002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4004. * @param v1 (Vector3) the control point
  4005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4006. * @param nbPoints (integer) the wanted number of points in the curve
  4007. * @returns the created Curve3
  4008. */
  4009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4010. /**
  4011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4013. * @param v1 (Vector3) the first control point
  4014. * @param v2 (Vector3) the second control point
  4015. * @param v3 (Vector3) the end point of the Cubic Bezier
  4016. * @param nbPoints (integer) the wanted number of points in the curve
  4017. * @returns the created Curve3
  4018. */
  4019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4020. /**
  4021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4022. * @param p1 (Vector3) the origin point of the Hermite Spline
  4023. * @param t1 (Vector3) the tangent vector at the origin point
  4024. * @param p2 (Vector3) the end point of the Hermite Spline
  4025. * @param t2 (Vector3) the tangent vector at the end point
  4026. * @param nbPoints (integer) the wanted number of points in the curve
  4027. * @returns the created Curve3
  4028. */
  4029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4030. /**
  4031. * Returns a Curve3 object along a CatmullRom Spline curve :
  4032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4033. * @param nbPoints (integer) the wanted number of points between each curve control points
  4034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4035. * @returns the created Curve3
  4036. */
  4037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4038. /**
  4039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4040. * A Curve3 is designed from a series of successive Vector3.
  4041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4042. * @param points points which make up the curve
  4043. */
  4044. constructor(points: Vector3[]);
  4045. /**
  4046. * @returns the Curve3 stored array of successive Vector3
  4047. */
  4048. getPoints(): Vector3[];
  4049. /**
  4050. * @returns the computed length (float) of the curve.
  4051. */
  4052. length(): number;
  4053. /**
  4054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4056. * curveA and curveB keep unchanged.
  4057. * @param curve the curve to continue from this curve
  4058. * @returns the newly constructed curve
  4059. */
  4060. continue(curve: DeepImmutable<Curve3>): Curve3;
  4061. private _computeLength;
  4062. }
  4063. /**
  4064. * Contains position and normal vectors for a vertex
  4065. */
  4066. export class PositionNormalVertex {
  4067. /** the position of the vertex (defaut: 0,0,0) */
  4068. position: Vector3;
  4069. /** the normal of the vertex (defaut: 0,1,0) */
  4070. normal: Vector3;
  4071. /**
  4072. * Creates a PositionNormalVertex
  4073. * @param position the position of the vertex (defaut: 0,0,0)
  4074. * @param normal the normal of the vertex (defaut: 0,1,0)
  4075. */
  4076. constructor(
  4077. /** the position of the vertex (defaut: 0,0,0) */
  4078. position?: Vector3,
  4079. /** the normal of the vertex (defaut: 0,1,0) */
  4080. normal?: Vector3);
  4081. /**
  4082. * Clones the PositionNormalVertex
  4083. * @returns the cloned PositionNormalVertex
  4084. */
  4085. clone(): PositionNormalVertex;
  4086. }
  4087. /**
  4088. * Contains position, normal and uv vectors for a vertex
  4089. */
  4090. export class PositionNormalTextureVertex {
  4091. /** the position of the vertex (defaut: 0,0,0) */
  4092. position: Vector3;
  4093. /** the normal of the vertex (defaut: 0,1,0) */
  4094. normal: Vector3;
  4095. /** the uv of the vertex (default: 0,0) */
  4096. uv: Vector2;
  4097. /**
  4098. * Creates a PositionNormalTextureVertex
  4099. * @param position the position of the vertex (defaut: 0,0,0)
  4100. * @param normal the normal of the vertex (defaut: 0,1,0)
  4101. * @param uv the uv of the vertex (default: 0,0)
  4102. */
  4103. constructor(
  4104. /** the position of the vertex (defaut: 0,0,0) */
  4105. position?: Vector3,
  4106. /** the normal of the vertex (defaut: 0,1,0) */
  4107. normal?: Vector3,
  4108. /** the uv of the vertex (default: 0,0) */
  4109. uv?: Vector2);
  4110. /**
  4111. * Clones the PositionNormalTextureVertex
  4112. * @returns the cloned PositionNormalTextureVertex
  4113. */
  4114. clone(): PositionNormalTextureVertex;
  4115. }
  4116. /**
  4117. * @hidden
  4118. */
  4119. export class Tmp {
  4120. static Color3: Color3[];
  4121. static Color4: Color4[];
  4122. static Vector2: Vector2[];
  4123. static Vector3: Vector3[];
  4124. static Vector4: Vector4[];
  4125. static Quaternion: Quaternion[];
  4126. static Matrix: Matrix[];
  4127. }
  4128. }
  4129. declare module "babylonjs/Animations/runtimeAnimation" {
  4130. import { Animatable } from "babylonjs/Animations/animatable";
  4131. import { Animation } from "babylonjs/Animations/animation";
  4132. import { Scene } from "babylonjs/scene";
  4133. /**
  4134. * Defines a runtime animation
  4135. */
  4136. export class RuntimeAnimation {
  4137. private _events;
  4138. /**
  4139. * The current frame of the runtime animation
  4140. */
  4141. private _currentFrame;
  4142. /**
  4143. * The animation used by the runtime animation
  4144. */
  4145. private _animation;
  4146. /**
  4147. * The target of the runtime animation
  4148. */
  4149. private _target;
  4150. /**
  4151. * The initiating animatable
  4152. */
  4153. private _host;
  4154. /**
  4155. * The original value of the runtime animation
  4156. */
  4157. private _originalValue;
  4158. /**
  4159. * The original blend value of the runtime animation
  4160. */
  4161. private _originalBlendValue;
  4162. /**
  4163. * The offsets cache of the runtime animation
  4164. */
  4165. private _offsetsCache;
  4166. /**
  4167. * The high limits cache of the runtime animation
  4168. */
  4169. private _highLimitsCache;
  4170. /**
  4171. * Specifies if the runtime animation has been stopped
  4172. */
  4173. private _stopped;
  4174. /**
  4175. * The blending factor of the runtime animation
  4176. */
  4177. private _blendingFactor;
  4178. /**
  4179. * The BabylonJS scene
  4180. */
  4181. private _scene;
  4182. /**
  4183. * The current value of the runtime animation
  4184. */
  4185. private _currentValue;
  4186. /** @hidden */
  4187. _workValue: any;
  4188. /**
  4189. * The active target of the runtime animation
  4190. */
  4191. private _activeTarget;
  4192. /**
  4193. * The target path of the runtime animation
  4194. */
  4195. private _targetPath;
  4196. /**
  4197. * The weight of the runtime animation
  4198. */
  4199. private _weight;
  4200. /**
  4201. * The ratio offset of the runtime animation
  4202. */
  4203. private _ratioOffset;
  4204. /**
  4205. * The previous delay of the runtime animation
  4206. */
  4207. private _previousDelay;
  4208. /**
  4209. * The previous ratio of the runtime animation
  4210. */
  4211. private _previousRatio;
  4212. /**
  4213. * Gets the current frame of the runtime animation
  4214. */
  4215. readonly currentFrame: number;
  4216. /**
  4217. * Gets the weight of the runtime animation
  4218. */
  4219. readonly weight: number;
  4220. /**
  4221. * Gets the current value of the runtime animation
  4222. */
  4223. readonly currentValue: any;
  4224. /**
  4225. * Gets the target path of the runtime animation
  4226. */
  4227. readonly targetPath: string;
  4228. /**
  4229. * Gets the actual target of the runtime animation
  4230. */
  4231. readonly target: any;
  4232. /**
  4233. * Create a new RuntimeAnimation object
  4234. * @param target defines the target of the animation
  4235. * @param animation defines the source animation object
  4236. * @param scene defines the hosting scene
  4237. * @param host defines the initiating Animatable
  4238. */
  4239. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4240. /**
  4241. * Gets the animation from the runtime animation
  4242. */
  4243. readonly animation: Animation;
  4244. /**
  4245. * Resets the runtime animation to the beginning
  4246. * @param restoreOriginal defines whether to restore the target property to the original value
  4247. */
  4248. reset(restoreOriginal?: boolean): void;
  4249. /**
  4250. * Specifies if the runtime animation is stopped
  4251. * @returns Boolean specifying if the runtime animation is stopped
  4252. */
  4253. isStopped(): boolean;
  4254. /**
  4255. * Disposes of the runtime animation
  4256. */
  4257. dispose(): void;
  4258. /**
  4259. * Interpolates the animation from the current frame
  4260. * @param currentFrame The frame to interpolate the animation to
  4261. * @param repeatCount The number of times that the animation should loop
  4262. * @param loopMode The type of looping mode to use
  4263. * @param offsetValue Animation offset value
  4264. * @param highLimitValue The high limit value
  4265. * @returns The interpolated value
  4266. */
  4267. private _interpolate;
  4268. /**
  4269. * Apply the interpolated value to the target
  4270. * @param currentValue defines the value computed by the animation
  4271. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4272. */
  4273. setValue(currentValue: any, weight?: number): void;
  4274. private _setValue;
  4275. /**
  4276. * Gets the loop pmode of the runtime animation
  4277. * @returns Loop Mode
  4278. */
  4279. private _getCorrectLoopMode;
  4280. /**
  4281. * Move the current animation to a given frame
  4282. * @param frame defines the frame to move to
  4283. */
  4284. goToFrame(frame: number): void;
  4285. /**
  4286. * @hidden Internal use only
  4287. */
  4288. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4289. /**
  4290. * Execute the current animation
  4291. * @param delay defines the delay to add to the current frame
  4292. * @param from defines the lower bound of the animation range
  4293. * @param to defines the upper bound of the animation range
  4294. * @param loop defines if the current animation must loop
  4295. * @param speedRatio defines the current speed ratio
  4296. * @param weight defines the weight of the animation (default is -1 so no weight)
  4297. * @returns a boolean indicating if the animation is running
  4298. */
  4299. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4300. }
  4301. }
  4302. declare module "babylonjs/Misc/observable" {
  4303. import { Nullable } from "babylonjs/types";
  4304. /**
  4305. * A class serves as a medium between the observable and its observers
  4306. */
  4307. export class EventState {
  4308. /**
  4309. * Create a new EventState
  4310. * @param mask defines the mask associated with this state
  4311. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4312. * @param target defines the original target of the state
  4313. * @param currentTarget defines the current target of the state
  4314. */
  4315. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4316. /**
  4317. * Initialize the current event state
  4318. * @param mask defines the mask associated with this state
  4319. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4320. * @param target defines the original target of the state
  4321. * @param currentTarget defines the current target of the state
  4322. * @returns the current event state
  4323. */
  4324. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4325. /**
  4326. * An Observer can set this property to true to prevent subsequent observers of being notified
  4327. */
  4328. skipNextObservers: boolean;
  4329. /**
  4330. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4331. */
  4332. mask: number;
  4333. /**
  4334. * The object that originally notified the event
  4335. */
  4336. target?: any;
  4337. /**
  4338. * The current object in the bubbling phase
  4339. */
  4340. currentTarget?: any;
  4341. /**
  4342. * This will be populated with the return value of the last function that was executed.
  4343. * If it is the first function in the callback chain it will be the event data.
  4344. */
  4345. lastReturnValue?: any;
  4346. }
  4347. /**
  4348. * Represent an Observer registered to a given Observable object.
  4349. */
  4350. export class Observer<T> {
  4351. /**
  4352. * Defines the callback to call when the observer is notified
  4353. */
  4354. callback: (eventData: T, eventState: EventState) => void;
  4355. /**
  4356. * Defines the mask of the observer (used to filter notifications)
  4357. */
  4358. mask: number;
  4359. /**
  4360. * Defines the current scope used to restore the JS context
  4361. */
  4362. scope: any;
  4363. /** @hidden */
  4364. _willBeUnregistered: boolean;
  4365. /**
  4366. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4367. */
  4368. unregisterOnNextCall: boolean;
  4369. /**
  4370. * Creates a new observer
  4371. * @param callback defines the callback to call when the observer is notified
  4372. * @param mask defines the mask of the observer (used to filter notifications)
  4373. * @param scope defines the current scope used to restore the JS context
  4374. */
  4375. constructor(
  4376. /**
  4377. * Defines the callback to call when the observer is notified
  4378. */
  4379. callback: (eventData: T, eventState: EventState) => void,
  4380. /**
  4381. * Defines the mask of the observer (used to filter notifications)
  4382. */
  4383. mask: number,
  4384. /**
  4385. * Defines the current scope used to restore the JS context
  4386. */
  4387. scope?: any);
  4388. }
  4389. /**
  4390. * Represent a list of observers registered to multiple Observables object.
  4391. */
  4392. export class MultiObserver<T> {
  4393. private _observers;
  4394. private _observables;
  4395. /**
  4396. * Release associated resources
  4397. */
  4398. dispose(): void;
  4399. /**
  4400. * Raise a callback when one of the observable will notify
  4401. * @param observables defines a list of observables to watch
  4402. * @param callback defines the callback to call on notification
  4403. * @param mask defines the mask used to filter notifications
  4404. * @param scope defines the current scope used to restore the JS context
  4405. * @returns the new MultiObserver
  4406. */
  4407. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4408. }
  4409. /**
  4410. * The Observable class is a simple implementation of the Observable pattern.
  4411. *
  4412. * 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.
  4413. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4414. * 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).
  4415. * 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.
  4416. */
  4417. export class Observable<T> {
  4418. private _observers;
  4419. private _eventState;
  4420. private _onObserverAdded;
  4421. /**
  4422. * Creates a new observable
  4423. * @param onObserverAdded defines a callback to call when a new observer is added
  4424. */
  4425. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4426. /**
  4427. * Create a new Observer with the specified callback
  4428. * @param callback the callback that will be executed for that Observer
  4429. * @param mask the mask used to filter observers
  4430. * @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.
  4431. * @param scope optional scope for the callback to be called from
  4432. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4433. * @returns the new observer created for the callback
  4434. */
  4435. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4436. /**
  4437. * Create a new Observer with the specified callback and unregisters after the next notification
  4438. * @param callback the callback that will be executed for that Observer
  4439. * @returns the new observer created for the callback
  4440. */
  4441. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4442. /**
  4443. * Remove an Observer from the Observable object
  4444. * @param observer the instance of the Observer to remove
  4445. * @returns false if it doesn't belong to this Observable
  4446. */
  4447. remove(observer: Nullable<Observer<T>>): boolean;
  4448. /**
  4449. * Remove a callback from the Observable object
  4450. * @param callback the callback to remove
  4451. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4452. * @returns false if it doesn't belong to this Observable
  4453. */
  4454. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4455. private _deferUnregister;
  4456. private _remove;
  4457. /**
  4458. * Notify all Observers by calling their respective callback with the given data
  4459. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4460. * @param eventData defines the data to send to all observers
  4461. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4462. * @param target defines the original target of the state
  4463. * @param currentTarget defines the current target of the state
  4464. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4465. */
  4466. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4467. /**
  4468. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4469. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4470. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4471. * and it is crucial that all callbacks will be executed.
  4472. * The order of the callbacks is kept, callbacks are not executed parallel.
  4473. *
  4474. * @param eventData The data to be sent to each callback
  4475. * @param mask is used to filter observers defaults to -1
  4476. * @param target defines the callback target (see EventState)
  4477. * @param currentTarget defines he current object in the bubbling phase
  4478. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4479. */
  4480. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4481. /**
  4482. * Notify a specific observer
  4483. * @param observer defines the observer to notify
  4484. * @param eventData defines the data to be sent to each callback
  4485. * @param mask is used to filter observers defaults to -1
  4486. */
  4487. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4488. /**
  4489. * Gets a boolean indicating if the observable has at least one observer
  4490. * @returns true is the Observable has at least one Observer registered
  4491. */
  4492. hasObservers(): boolean;
  4493. /**
  4494. * Clear the list of observers
  4495. */
  4496. clear(): void;
  4497. /**
  4498. * Clone the current observable
  4499. * @returns a new observable
  4500. */
  4501. clone(): Observable<T>;
  4502. /**
  4503. * Does this observable handles observer registered with a given mask
  4504. * @param mask defines the mask to be tested
  4505. * @return whether or not one observer registered with the given mask is handeled
  4506. **/
  4507. hasSpecificMask(mask?: number): boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Animations/animatable" {
  4511. import { Animation } from "babylonjs/Animations/animation";
  4512. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  4513. import { Nullable } from "babylonjs/types";
  4514. import { Observable } from "babylonjs/Misc/observable";
  4515. import { Scene } from "babylonjs/scene";
  4516. /**
  4517. * Class used to store an actual running animation
  4518. */
  4519. export class Animatable {
  4520. /** defines the target object */
  4521. target: any;
  4522. /** defines the starting frame number (default is 0) */
  4523. fromFrame: number;
  4524. /** defines the ending frame number (default is 100) */
  4525. toFrame: number;
  4526. /** defines if the animation must loop (default is false) */
  4527. loopAnimation: boolean;
  4528. /** defines a callback to call when animation ends if it is not looping */
  4529. onAnimationEnd?: (() => void) | null | undefined;
  4530. private _localDelayOffset;
  4531. private _pausedDelay;
  4532. private _runtimeAnimations;
  4533. private _paused;
  4534. private _scene;
  4535. private _speedRatio;
  4536. private _weight;
  4537. private _syncRoot;
  4538. /**
  4539. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  4540. * This will only apply for non looping animation (default is true)
  4541. */
  4542. disposeOnEnd: boolean;
  4543. /**
  4544. * Gets a boolean indicating if the animation has started
  4545. */
  4546. animationStarted: boolean;
  4547. /**
  4548. * Observer raised when the animation ends
  4549. */
  4550. onAnimationEndObservable: Observable<Animatable>;
  4551. /**
  4552. * Gets the root Animatable used to synchronize and normalize animations
  4553. */
  4554. readonly syncRoot: Animatable;
  4555. /**
  4556. * Gets the current frame of the first RuntimeAnimation
  4557. * Used to synchronize Animatables
  4558. */
  4559. readonly masterFrame: number;
  4560. /**
  4561. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  4562. */
  4563. weight: number;
  4564. /**
  4565. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  4566. */
  4567. speedRatio: number;
  4568. /**
  4569. * Creates a new Animatable
  4570. * @param scene defines the hosting scene
  4571. * @param target defines the target object
  4572. * @param fromFrame defines the starting frame number (default is 0)
  4573. * @param toFrame defines the ending frame number (default is 100)
  4574. * @param loopAnimation defines if the animation must loop (default is false)
  4575. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  4576. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  4577. * @param animations defines a group of animation to add to the new Animatable
  4578. */
  4579. constructor(scene: Scene,
  4580. /** defines the target object */
  4581. target: any,
  4582. /** defines the starting frame number (default is 0) */
  4583. fromFrame?: number,
  4584. /** defines the ending frame number (default is 100) */
  4585. toFrame?: number,
  4586. /** defines if the animation must loop (default is false) */
  4587. loopAnimation?: boolean, speedRatio?: number,
  4588. /** defines a callback to call when animation ends if it is not looping */
  4589. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  4590. /**
  4591. * Synchronize and normalize current Animatable with a source Animatable
  4592. * This is useful when using animation weights and when animations are not of the same length
  4593. * @param root defines the root Animatable to synchronize with
  4594. * @returns the current Animatable
  4595. */
  4596. syncWith(root: Animatable): Animatable;
  4597. /**
  4598. * Gets the list of runtime animations
  4599. * @returns an array of RuntimeAnimation
  4600. */
  4601. getAnimations(): RuntimeAnimation[];
  4602. /**
  4603. * Adds more animations to the current animatable
  4604. * @param target defines the target of the animations
  4605. * @param animations defines the new animations to add
  4606. */
  4607. appendAnimations(target: any, animations: Animation[]): void;
  4608. /**
  4609. * Gets the source animation for a specific property
  4610. * @param property defines the propertyu to look for
  4611. * @returns null or the source animation for the given property
  4612. */
  4613. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  4614. /**
  4615. * Gets the runtime animation for a specific property
  4616. * @param property defines the propertyu to look for
  4617. * @returns null or the runtime animation for the given property
  4618. */
  4619. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  4620. /**
  4621. * Resets the animatable to its original state
  4622. */
  4623. reset(): void;
  4624. /**
  4625. * Allows the animatable to blend with current running animations
  4626. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4627. * @param blendingSpeed defines the blending speed to use
  4628. */
  4629. enableBlending(blendingSpeed: number): void;
  4630. /**
  4631. * Disable animation blending
  4632. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4633. */
  4634. disableBlending(): void;
  4635. /**
  4636. * Jump directly to a given frame
  4637. * @param frame defines the frame to jump to
  4638. */
  4639. goToFrame(frame: number): void;
  4640. /**
  4641. * Pause the animation
  4642. */
  4643. pause(): void;
  4644. /**
  4645. * Restart the animation
  4646. */
  4647. restart(): void;
  4648. private _raiseOnAnimationEnd;
  4649. /**
  4650. * Stop and delete the current animation
  4651. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  4652. * @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)
  4653. */
  4654. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  4655. /**
  4656. * Wait asynchronously for the animation to end
  4657. * @returns a promise which will be fullfilled when the animation ends
  4658. */
  4659. waitAsync(): Promise<Animatable>;
  4660. /** @hidden */
  4661. _animate(delay: number): boolean;
  4662. }
  4663. }
  4664. declare module "babylonjs/Animations/easing" {
  4665. /**
  4666. * This represents the main contract an easing function should follow.
  4667. * Easing functions are used throughout the animation system.
  4668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4669. */
  4670. export interface IEasingFunction {
  4671. /**
  4672. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4673. * of the easing function.
  4674. * The link below provides some of the most common examples of easing functions.
  4675. * @see https://easings.net/
  4676. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4677. * @returns the corresponding value on the curve defined by the easing function
  4678. */
  4679. ease(gradient: number): number;
  4680. }
  4681. /**
  4682. * Base class used for every default easing function.
  4683. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4684. */
  4685. export class EasingFunction implements IEasingFunction {
  4686. /**
  4687. * Interpolation follows the mathematical formula associated with the easing function.
  4688. */
  4689. static readonly EASINGMODE_EASEIN: number;
  4690. /**
  4691. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4692. */
  4693. static readonly EASINGMODE_EASEOUT: number;
  4694. /**
  4695. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4696. */
  4697. static readonly EASINGMODE_EASEINOUT: number;
  4698. private _easingMode;
  4699. /**
  4700. * Sets the easing mode of the current function.
  4701. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4702. */
  4703. setEasingMode(easingMode: number): void;
  4704. /**
  4705. * Gets the current easing mode.
  4706. * @returns the easing mode
  4707. */
  4708. getEasingMode(): number;
  4709. /**
  4710. * @hidden
  4711. */
  4712. easeInCore(gradient: number): number;
  4713. /**
  4714. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4715. * of the easing function.
  4716. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4717. * @returns the corresponding value on the curve defined by the easing function
  4718. */
  4719. ease(gradient: number): number;
  4720. }
  4721. /**
  4722. * Easing function with a circle shape (see link below).
  4723. * @see https://easings.net/#easeInCirc
  4724. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4725. */
  4726. export class CircleEase extends EasingFunction implements IEasingFunction {
  4727. /** @hidden */
  4728. easeInCore(gradient: number): number;
  4729. }
  4730. /**
  4731. * Easing function with a ease back shape (see link below).
  4732. * @see https://easings.net/#easeInBack
  4733. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4734. */
  4735. export class BackEase extends EasingFunction implements IEasingFunction {
  4736. /** Defines the amplitude of the function */
  4737. amplitude: number;
  4738. /**
  4739. * Instantiates a back ease easing
  4740. * @see https://easings.net/#easeInBack
  4741. * @param amplitude Defines the amplitude of the function
  4742. */
  4743. constructor(
  4744. /** Defines the amplitude of the function */
  4745. amplitude?: number);
  4746. /** @hidden */
  4747. easeInCore(gradient: number): number;
  4748. }
  4749. /**
  4750. * Easing function with a bouncing shape (see link below).
  4751. * @see https://easings.net/#easeInBounce
  4752. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4753. */
  4754. export class BounceEase extends EasingFunction implements IEasingFunction {
  4755. /** Defines the number of bounces */
  4756. bounces: number;
  4757. /** Defines the amplitude of the bounce */
  4758. bounciness: number;
  4759. /**
  4760. * Instantiates a bounce easing
  4761. * @see https://easings.net/#easeInBounce
  4762. * @param bounces Defines the number of bounces
  4763. * @param bounciness Defines the amplitude of the bounce
  4764. */
  4765. constructor(
  4766. /** Defines the number of bounces */
  4767. bounces?: number,
  4768. /** Defines the amplitude of the bounce */
  4769. bounciness?: number);
  4770. /** @hidden */
  4771. easeInCore(gradient: number): number;
  4772. }
  4773. /**
  4774. * Easing function with a power of 3 shape (see link below).
  4775. * @see https://easings.net/#easeInCubic
  4776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4777. */
  4778. export class CubicEase extends EasingFunction implements IEasingFunction {
  4779. /** @hidden */
  4780. easeInCore(gradient: number): number;
  4781. }
  4782. /**
  4783. * Easing function with an elastic shape (see link below).
  4784. * @see https://easings.net/#easeInElastic
  4785. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4786. */
  4787. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4788. /** Defines the number of oscillations*/
  4789. oscillations: number;
  4790. /** Defines the amplitude of the oscillations*/
  4791. springiness: number;
  4792. /**
  4793. * Instantiates an elastic easing function
  4794. * @see https://easings.net/#easeInElastic
  4795. * @param oscillations Defines the number of oscillations
  4796. * @param springiness Defines the amplitude of the oscillations
  4797. */
  4798. constructor(
  4799. /** Defines the number of oscillations*/
  4800. oscillations?: number,
  4801. /** Defines the amplitude of the oscillations*/
  4802. springiness?: number);
  4803. /** @hidden */
  4804. easeInCore(gradient: number): number;
  4805. }
  4806. /**
  4807. * Easing function with an exponential shape (see link below).
  4808. * @see https://easings.net/#easeInExpo
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4812. /** Defines the exponent of the function */
  4813. exponent: number;
  4814. /**
  4815. * Instantiates an exponential easing function
  4816. * @see https://easings.net/#easeInExpo
  4817. * @param exponent Defines the exponent of the function
  4818. */
  4819. constructor(
  4820. /** Defines the exponent of the function */
  4821. exponent?: number);
  4822. /** @hidden */
  4823. easeInCore(gradient: number): number;
  4824. }
  4825. /**
  4826. * Easing function with a power shape (see link below).
  4827. * @see https://easings.net/#easeInQuad
  4828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4829. */
  4830. export class PowerEase extends EasingFunction implements IEasingFunction {
  4831. /** Defines the power of the function */
  4832. power: number;
  4833. /**
  4834. * Instantiates an power base easing function
  4835. * @see https://easings.net/#easeInQuad
  4836. * @param power Defines the power of the function
  4837. */
  4838. constructor(
  4839. /** Defines the power of the function */
  4840. power?: number);
  4841. /** @hidden */
  4842. easeInCore(gradient: number): number;
  4843. }
  4844. /**
  4845. * Easing function with a power of 2 shape (see link below).
  4846. * @see https://easings.net/#easeInQuad
  4847. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4848. */
  4849. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  4850. /** @hidden */
  4851. easeInCore(gradient: number): number;
  4852. }
  4853. /**
  4854. * Easing function with a power of 4 shape (see link below).
  4855. * @see https://easings.net/#easeInQuart
  4856. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4857. */
  4858. export class QuarticEase extends EasingFunction implements IEasingFunction {
  4859. /** @hidden */
  4860. easeInCore(gradient: number): number;
  4861. }
  4862. /**
  4863. * Easing function with a power of 5 shape (see link below).
  4864. * @see https://easings.net/#easeInQuint
  4865. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4866. */
  4867. export class QuinticEase extends EasingFunction implements IEasingFunction {
  4868. /** @hidden */
  4869. easeInCore(gradient: number): number;
  4870. }
  4871. /**
  4872. * Easing function with a sin shape (see link below).
  4873. * @see https://easings.net/#easeInSine
  4874. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4875. */
  4876. export class SineEase extends EasingFunction implements IEasingFunction {
  4877. /** @hidden */
  4878. easeInCore(gradient: number): number;
  4879. }
  4880. /**
  4881. * Easing function with a bezier shape (see link below).
  4882. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4883. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4884. */
  4885. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4886. /** Defines the x component of the start tangent in the bezier curve */
  4887. x1: number;
  4888. /** Defines the y component of the start tangent in the bezier curve */
  4889. y1: number;
  4890. /** Defines the x component of the end tangent in the bezier curve */
  4891. x2: number;
  4892. /** Defines the y component of the end tangent in the bezier curve */
  4893. y2: number;
  4894. /**
  4895. * Instantiates a bezier function
  4896. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4897. * @param x1 Defines the x component of the start tangent in the bezier curve
  4898. * @param y1 Defines the y component of the start tangent in the bezier curve
  4899. * @param x2 Defines the x component of the end tangent in the bezier curve
  4900. * @param y2 Defines the y component of the end tangent in the bezier curve
  4901. */
  4902. constructor(
  4903. /** Defines the x component of the start tangent in the bezier curve */
  4904. x1?: number,
  4905. /** Defines the y component of the start tangent in the bezier curve */
  4906. y1?: number,
  4907. /** Defines the x component of the end tangent in the bezier curve */
  4908. x2?: number,
  4909. /** Defines the y component of the end tangent in the bezier curve */
  4910. y2?: number);
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. }
  4915. declare module "babylonjs/Misc/performanceMonitor" {
  4916. /**
  4917. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  4918. */
  4919. export class PerformanceMonitor {
  4920. private _enabled;
  4921. private _rollingFrameTime;
  4922. private _lastFrameTimeMs;
  4923. /**
  4924. * constructor
  4925. * @param frameSampleSize The number of samples required to saturate the sliding window
  4926. */
  4927. constructor(frameSampleSize?: number);
  4928. /**
  4929. * Samples current frame
  4930. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  4931. */
  4932. sampleFrame(timeMs?: number): void;
  4933. /**
  4934. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  4935. */
  4936. readonly averageFrameTime: number;
  4937. /**
  4938. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  4939. */
  4940. readonly averageFrameTimeVariance: number;
  4941. /**
  4942. * Returns the frame time of the most recent frame
  4943. */
  4944. readonly instantaneousFrameTime: number;
  4945. /**
  4946. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  4947. */
  4948. readonly averageFPS: number;
  4949. /**
  4950. * Returns the average framerate in frames per second using the most recent frame time
  4951. */
  4952. readonly instantaneousFPS: number;
  4953. /**
  4954. * Returns true if enough samples have been taken to completely fill the sliding window
  4955. */
  4956. readonly isSaturated: boolean;
  4957. /**
  4958. * Enables contributions to the sliding window sample set
  4959. */
  4960. enable(): void;
  4961. /**
  4962. * Disables contributions to the sliding window sample set
  4963. * Samples will not be interpolated over the disabled period
  4964. */
  4965. disable(): void;
  4966. /**
  4967. * Returns true if sampling is enabled
  4968. */
  4969. readonly isEnabled: boolean;
  4970. /**
  4971. * Resets performance monitor
  4972. */
  4973. reset(): void;
  4974. }
  4975. /**
  4976. * RollingAverage
  4977. *
  4978. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  4979. */
  4980. export class RollingAverage {
  4981. /**
  4982. * Current average
  4983. */
  4984. average: number;
  4985. /**
  4986. * Current variance
  4987. */
  4988. variance: number;
  4989. protected _samples: Array<number>;
  4990. protected _sampleCount: number;
  4991. protected _pos: number;
  4992. protected _m2: number;
  4993. /**
  4994. * constructor
  4995. * @param length The number of samples required to saturate the sliding window
  4996. */
  4997. constructor(length: number);
  4998. /**
  4999. * Adds a sample to the sample set
  5000. * @param v The sample value
  5001. */
  5002. add(v: number): void;
  5003. /**
  5004. * Returns previously added values or null if outside of history or outside the sliding window domain
  5005. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5006. * @return Value previously recorded with add() or null if outside of range
  5007. */
  5008. history(i: number): number;
  5009. /**
  5010. * Returns true if enough samples have been taken to completely fill the sliding window
  5011. * @return true if sample-set saturated
  5012. */
  5013. isSaturated(): boolean;
  5014. /**
  5015. * Resets the rolling average (equivalent to 0 samples taken so far)
  5016. */
  5017. reset(): void;
  5018. /**
  5019. * Wraps a value around the sample range boundaries
  5020. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5021. * @return Wrapped position in sample range
  5022. */
  5023. protected _wrapPosition(i: number): number;
  5024. }
  5025. }
  5026. declare module "babylonjs/Misc/stringDictionary" {
  5027. import { Nullable } from "babylonjs/types";
  5028. /**
  5029. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5030. * The underlying implementation relies on an associative array to ensure the best performances.
  5031. * The value can be anything including 'null' but except 'undefined'
  5032. */
  5033. export class StringDictionary<T> {
  5034. /**
  5035. * This will clear this dictionary and copy the content from the 'source' one.
  5036. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5037. * @param source the dictionary to take the content from and copy to this dictionary
  5038. */
  5039. copyFrom(source: StringDictionary<T>): void;
  5040. /**
  5041. * Get a value based from its key
  5042. * @param key the given key to get the matching value from
  5043. * @return the value if found, otherwise undefined is returned
  5044. */
  5045. get(key: string): T | undefined;
  5046. /**
  5047. * Get a value from its key or add it if it doesn't exist.
  5048. * This method will ensure you that a given key/data will be present in the dictionary.
  5049. * @param key the given key to get the matching value from
  5050. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5051. * The factory will only be invoked if there's no data for the given key.
  5052. * @return the value corresponding to the key.
  5053. */
  5054. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5055. /**
  5056. * Get a value from its key if present in the dictionary otherwise add it
  5057. * @param key the key to get the value from
  5058. * @param val if there's no such key/value pair in the dictionary add it with this value
  5059. * @return the value corresponding to the key
  5060. */
  5061. getOrAdd(key: string, val: T): T;
  5062. /**
  5063. * Check if there's a given key in the dictionary
  5064. * @param key the key to check for
  5065. * @return true if the key is present, false otherwise
  5066. */
  5067. contains(key: string): boolean;
  5068. /**
  5069. * Add a new key and its corresponding value
  5070. * @param key the key to add
  5071. * @param value the value corresponding to the key
  5072. * @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
  5073. */
  5074. add(key: string, value: T): boolean;
  5075. /**
  5076. * Update a specific value associated to a key
  5077. * @param key defines the key to use
  5078. * @param value defines the value to store
  5079. * @returns true if the value was updated (or false if the key was not found)
  5080. */
  5081. set(key: string, value: T): boolean;
  5082. /**
  5083. * Get the element of the given key and remove it from the dictionary
  5084. * @param key defines the key to search
  5085. * @returns the value associated with the key or null if not found
  5086. */
  5087. getAndRemove(key: string): Nullable<T>;
  5088. /**
  5089. * Remove a key/value from the dictionary.
  5090. * @param key the key to remove
  5091. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5092. */
  5093. remove(key: string): boolean;
  5094. /**
  5095. * Clear the whole content of the dictionary
  5096. */
  5097. clear(): void;
  5098. /**
  5099. * Gets the current count
  5100. */
  5101. readonly count: number;
  5102. /**
  5103. * Execute a callback on each key/val of the dictionary.
  5104. * Note that you can remove any element in this dictionary in the callback implementation
  5105. * @param callback the callback to execute on a given key/value pair
  5106. */
  5107. forEach(callback: (key: string, val: T) => void): void;
  5108. /**
  5109. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5110. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5111. * Note that you can remove any element in this dictionary in the callback implementation
  5112. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5113. * @returns the first item
  5114. */
  5115. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5116. private _count;
  5117. private _data;
  5118. }
  5119. }
  5120. declare module "babylonjs/Misc/promise" {
  5121. /**
  5122. * Helper class that provides a small promise polyfill
  5123. */
  5124. export class PromisePolyfill {
  5125. /**
  5126. * Static function used to check if the polyfill is required
  5127. * If this is the case then the function will inject the polyfill to window.Promise
  5128. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5129. */
  5130. static Apply(force?: boolean): void;
  5131. }
  5132. }
  5133. declare module "babylonjs/Maths/sphericalPolynomial" {
  5134. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5135. /**
  5136. * Class representing spherical polynomial coefficients to the 3rd degree
  5137. */
  5138. export class SphericalPolynomial {
  5139. /**
  5140. * The x coefficients of the spherical polynomial
  5141. */
  5142. x: Vector3;
  5143. /**
  5144. * The y coefficients of the spherical polynomial
  5145. */
  5146. y: Vector3;
  5147. /**
  5148. * The z coefficients of the spherical polynomial
  5149. */
  5150. z: Vector3;
  5151. /**
  5152. * The xx coefficients of the spherical polynomial
  5153. */
  5154. xx: Vector3;
  5155. /**
  5156. * The yy coefficients of the spherical polynomial
  5157. */
  5158. yy: Vector3;
  5159. /**
  5160. * The zz coefficients of the spherical polynomial
  5161. */
  5162. zz: Vector3;
  5163. /**
  5164. * The xy coefficients of the spherical polynomial
  5165. */
  5166. xy: Vector3;
  5167. /**
  5168. * The yz coefficients of the spherical polynomial
  5169. */
  5170. yz: Vector3;
  5171. /**
  5172. * The zx coefficients of the spherical polynomial
  5173. */
  5174. zx: Vector3;
  5175. /**
  5176. * Adds an ambient color to the spherical polynomial
  5177. * @param color the color to add
  5178. */
  5179. addAmbient(color: Color3): void;
  5180. /**
  5181. * Scales the spherical polynomial by the given amount
  5182. * @param scale the amount to scale
  5183. */
  5184. scale(scale: number): void;
  5185. /**
  5186. * Gets the spherical polynomial from harmonics
  5187. * @param harmonics the spherical harmonics
  5188. * @returns the spherical polynomial
  5189. */
  5190. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5191. /**
  5192. * Constructs a spherical polynomial from an array.
  5193. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5194. * @returns the spherical polynomial
  5195. */
  5196. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5197. }
  5198. /**
  5199. * Class representing spherical harmonics coefficients to the 3rd degree
  5200. */
  5201. export class SphericalHarmonics {
  5202. /**
  5203. * The l0,0 coefficients of the spherical harmonics
  5204. */
  5205. l00: Vector3;
  5206. /**
  5207. * The l1,-1 coefficients of the spherical harmonics
  5208. */
  5209. l1_1: Vector3;
  5210. /**
  5211. * The l1,0 coefficients of the spherical harmonics
  5212. */
  5213. l10: Vector3;
  5214. /**
  5215. * The l1,1 coefficients of the spherical harmonics
  5216. */
  5217. l11: Vector3;
  5218. /**
  5219. * The l2,-2 coefficients of the spherical harmonics
  5220. */
  5221. l2_2: Vector3;
  5222. /**
  5223. * The l2,-1 coefficients of the spherical harmonics
  5224. */
  5225. l2_1: Vector3;
  5226. /**
  5227. * The l2,0 coefficients of the spherical harmonics
  5228. */
  5229. l20: Vector3;
  5230. /**
  5231. * The l2,1 coefficients of the spherical harmonics
  5232. */
  5233. l21: Vector3;
  5234. /**
  5235. * The l2,2 coefficients of the spherical harmonics
  5236. */
  5237. lL22: Vector3;
  5238. /**
  5239. * Adds a light to the spherical harmonics
  5240. * @param direction the direction of the light
  5241. * @param color the color of the light
  5242. * @param deltaSolidAngle the delta solid angle of the light
  5243. */
  5244. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5245. /**
  5246. * Scales the spherical harmonics by the given amount
  5247. * @param scale the amount to scale
  5248. */
  5249. scale(scale: number): void;
  5250. /**
  5251. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5252. *
  5253. * ```
  5254. * E_lm = A_l * L_lm
  5255. * ```
  5256. *
  5257. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5258. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5259. * the scaling factors are given in equation 9.
  5260. */
  5261. convertIncidentRadianceToIrradiance(): void;
  5262. /**
  5263. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5264. *
  5265. * ```
  5266. * L = (1/pi) * E * rho
  5267. * ```
  5268. *
  5269. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5270. */
  5271. convertIrradianceToLambertianRadiance(): void;
  5272. /**
  5273. * Gets the spherical harmonics from polynomial
  5274. * @param polynomial the spherical polynomial
  5275. * @returns the spherical harmonics
  5276. */
  5277. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5278. /**
  5279. * Constructs a spherical harmonics from an array.
  5280. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5281. * @returns the spherical harmonics
  5282. */
  5283. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5284. }
  5285. }
  5286. declare module "babylonjs/Engines/constants" {
  5287. /** Defines the cross module used constants to avoid circular dependncies */
  5288. export class Constants {
  5289. /** Defines that alpha blending is disabled */
  5290. static readonly ALPHA_DISABLE: number;
  5291. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  5292. static readonly ALPHA_ADD: number;
  5293. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  5294. static readonly ALPHA_COMBINE: number;
  5295. /** Defines that alpha blending to DEST - SRC * DEST */
  5296. static readonly ALPHA_SUBTRACT: number;
  5297. /** Defines that alpha blending to SRC * DEST */
  5298. static readonly ALPHA_MULTIPLY: number;
  5299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  5300. static readonly ALPHA_MAXIMIZED: number;
  5301. /** Defines that alpha blending to SRC + DEST */
  5302. static readonly ALPHA_ONEONE: number;
  5303. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  5304. static readonly ALPHA_PREMULTIPLIED: number;
  5305. /**
  5306. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  5307. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  5308. */
  5309. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  5310. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  5311. static readonly ALPHA_INTERPOLATE: number;
  5312. /**
  5313. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  5314. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  5315. */
  5316. static readonly ALPHA_SCREENMODE: number;
  5317. /** Defines that the ressource is not delayed*/
  5318. static readonly DELAYLOADSTATE_NONE: number;
  5319. /** Defines that the ressource was successfully delay loaded */
  5320. static readonly DELAYLOADSTATE_LOADED: number;
  5321. /** Defines that the ressource is currently delay loading */
  5322. static readonly DELAYLOADSTATE_LOADING: number;
  5323. /** Defines that the ressource is delayed and has not started loading */
  5324. static readonly DELAYLOADSTATE_NOTLOADED: number;
  5325. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  5326. static readonly NEVER: number;
  5327. /** 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 */
  5328. static readonly ALWAYS: number;
  5329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  5330. static readonly LESS: number;
  5331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  5332. static readonly EQUAL: number;
  5333. /** 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 */
  5334. static readonly LEQUAL: number;
  5335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  5336. static readonly GREATER: number;
  5337. /** 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 */
  5338. static readonly GEQUAL: number;
  5339. /** 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 */
  5340. static readonly NOTEQUAL: number;
  5341. /** Passed to stencilOperation to specify that stencil value must be kept */
  5342. static readonly KEEP: number;
  5343. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5344. static readonly REPLACE: number;
  5345. /** Passed to stencilOperation to specify that stencil value must be incremented */
  5346. static readonly INCR: number;
  5347. /** Passed to stencilOperation to specify that stencil value must be decremented */
  5348. static readonly DECR: number;
  5349. /** Passed to stencilOperation to specify that stencil value must be inverted */
  5350. static readonly INVERT: number;
  5351. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  5352. static readonly INCR_WRAP: number;
  5353. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  5354. static readonly DECR_WRAP: number;
  5355. /** Texture is not repeating outside of 0..1 UVs */
  5356. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  5357. /** Texture is repeating outside of 0..1 UVs */
  5358. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  5359. /** Texture is repeating and mirrored */
  5360. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  5361. /** ALPHA */
  5362. static readonly TEXTUREFORMAT_ALPHA: number;
  5363. /** LUMINANCE */
  5364. static readonly TEXTUREFORMAT_LUMINANCE: number;
  5365. /** LUMINANCE_ALPHA */
  5366. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  5367. /** RGB */
  5368. static readonly TEXTUREFORMAT_RGB: number;
  5369. /** RGBA */
  5370. static readonly TEXTUREFORMAT_RGBA: number;
  5371. /** RED */
  5372. static readonly TEXTUREFORMAT_RED: number;
  5373. /** RED (2nd reference) */
  5374. static readonly TEXTUREFORMAT_R: number;
  5375. /** RG */
  5376. static readonly TEXTUREFORMAT_RG: number;
  5377. /** RED_INTEGER */
  5378. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  5379. /** RED_INTEGER (2nd reference) */
  5380. static readonly TEXTUREFORMAT_R_INTEGER: number;
  5381. /** RG_INTEGER */
  5382. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  5383. /** RGB_INTEGER */
  5384. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  5385. /** RGBA_INTEGER */
  5386. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  5387. /** UNSIGNED_BYTE */
  5388. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  5389. /** UNSIGNED_BYTE (2nd reference) */
  5390. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  5391. /** FLOAT */
  5392. static readonly TEXTURETYPE_FLOAT: number;
  5393. /** HALF_FLOAT */
  5394. static readonly TEXTURETYPE_HALF_FLOAT: number;
  5395. /** BYTE */
  5396. static readonly TEXTURETYPE_BYTE: number;
  5397. /** SHORT */
  5398. static readonly TEXTURETYPE_SHORT: number;
  5399. /** UNSIGNED_SHORT */
  5400. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  5401. /** INT */
  5402. static readonly TEXTURETYPE_INT: number;
  5403. /** UNSIGNED_INT */
  5404. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  5405. /** UNSIGNED_SHORT_4_4_4_4 */
  5406. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  5407. /** UNSIGNED_SHORT_5_5_5_1 */
  5408. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  5409. /** UNSIGNED_SHORT_5_6_5 */
  5410. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  5411. /** UNSIGNED_INT_2_10_10_10_REV */
  5412. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  5413. /** UNSIGNED_INT_24_8 */
  5414. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  5415. /** UNSIGNED_INT_10F_11F_11F_REV */
  5416. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  5417. /** UNSIGNED_INT_5_9_9_9_REV */
  5418. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  5419. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  5420. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  5421. /** nearest is mag = nearest and min = nearest and mip = linear */
  5422. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  5423. /** Bilinear is mag = linear and min = linear and mip = nearest */
  5424. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  5425. /** Trilinear is mag = linear and min = linear and mip = linear */
  5426. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  5427. /** nearest is mag = nearest and min = nearest and mip = linear */
  5428. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  5429. /** Bilinear is mag = linear and min = linear and mip = nearest */
  5430. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  5431. /** Trilinear is mag = linear and min = linear and mip = linear */
  5432. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  5433. /** mag = nearest and min = nearest and mip = nearest */
  5434. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  5435. /** mag = nearest and min = linear and mip = nearest */
  5436. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  5437. /** mag = nearest and min = linear and mip = linear */
  5438. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  5439. /** mag = nearest and min = linear and mip = none */
  5440. static readonly TEXTURE_NEAREST_LINEAR: number;
  5441. /** mag = nearest and min = nearest and mip = none */
  5442. static readonly TEXTURE_NEAREST_NEAREST: number;
  5443. /** mag = linear and min = nearest and mip = nearest */
  5444. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  5445. /** mag = linear and min = nearest and mip = linear */
  5446. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  5447. /** mag = linear and min = linear and mip = none */
  5448. static readonly TEXTURE_LINEAR_LINEAR: number;
  5449. /** mag = linear and min = nearest and mip = none */
  5450. static readonly TEXTURE_LINEAR_NEAREST: number;
  5451. /** Explicit coordinates mode */
  5452. static readonly TEXTURE_EXPLICIT_MODE: number;
  5453. /** Spherical coordinates mode */
  5454. static readonly TEXTURE_SPHERICAL_MODE: number;
  5455. /** Planar coordinates mode */
  5456. static readonly TEXTURE_PLANAR_MODE: number;
  5457. /** Cubic coordinates mode */
  5458. static readonly TEXTURE_CUBIC_MODE: number;
  5459. /** Projection coordinates mode */
  5460. static readonly TEXTURE_PROJECTION_MODE: number;
  5461. /** Skybox coordinates mode */
  5462. static readonly TEXTURE_SKYBOX_MODE: number;
  5463. /** Inverse Cubic coordinates mode */
  5464. static readonly TEXTURE_INVCUBIC_MODE: number;
  5465. /** Equirectangular coordinates mode */
  5466. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  5467. /** Equirectangular Fixed coordinates mode */
  5468. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  5469. /** Equirectangular Fixed Mirrored coordinates mode */
  5470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  5471. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  5472. static readonly SCALEMODE_FLOOR: number;
  5473. /** Defines that texture rescaling will look for the nearest power of 2 size */
  5474. static readonly SCALEMODE_NEAREST: number;
  5475. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  5476. static readonly SCALEMODE_CEILING: number;
  5477. /**
  5478. * The dirty texture flag value
  5479. */
  5480. static readonly MATERIAL_TextureDirtyFlag: number;
  5481. /**
  5482. * The dirty light flag value
  5483. */
  5484. static readonly MATERIAL_LightDirtyFlag: number;
  5485. /**
  5486. * The dirty fresnel flag value
  5487. */
  5488. static readonly MATERIAL_FresnelDirtyFlag: number;
  5489. /**
  5490. * The dirty attribute flag value
  5491. */
  5492. static readonly MATERIAL_AttributesDirtyFlag: number;
  5493. /**
  5494. * The dirty misc flag value
  5495. */
  5496. static readonly MATERIAL_MiscDirtyFlag: number;
  5497. /**
  5498. * The all dirty flag value
  5499. */
  5500. static readonly MATERIAL_AllDirtyFlag: number;
  5501. /**
  5502. * Nothing
  5503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5504. */
  5505. static readonly ACTION_NothingTrigger: number;
  5506. /**
  5507. * On pick
  5508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5509. */
  5510. static readonly ACTION_OnPickTrigger: number;
  5511. /**
  5512. * On left pick
  5513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5514. */
  5515. static readonly ACTION_OnLeftPickTrigger: number;
  5516. /**
  5517. * On right pick
  5518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5519. */
  5520. static readonly ACTION_OnRightPickTrigger: number;
  5521. /**
  5522. * On center pick
  5523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5524. */
  5525. static readonly ACTION_OnCenterPickTrigger: number;
  5526. /**
  5527. * On pick down
  5528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5529. */
  5530. static readonly ACTION_OnPickDownTrigger: number;
  5531. /**
  5532. * On double pick
  5533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5534. */
  5535. static readonly ACTION_OnDoublePickTrigger: number;
  5536. /**
  5537. * On pick up
  5538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5539. */
  5540. static readonly ACTION_OnPickUpTrigger: number;
  5541. /**
  5542. * On pick out.
  5543. * This trigger will only be raised if you also declared a OnPickDown
  5544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5545. */
  5546. static readonly ACTION_OnPickOutTrigger: number;
  5547. /**
  5548. * On long press
  5549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5550. */
  5551. static readonly ACTION_OnLongPressTrigger: number;
  5552. /**
  5553. * On pointer over
  5554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5555. */
  5556. static readonly ACTION_OnPointerOverTrigger: number;
  5557. /**
  5558. * On pointer out
  5559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5560. */
  5561. static readonly ACTION_OnPointerOutTrigger: number;
  5562. /**
  5563. * On every frame
  5564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5565. */
  5566. static readonly ACTION_OnEveryFrameTrigger: number;
  5567. /**
  5568. * On intersection enter
  5569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5570. */
  5571. static readonly ACTION_OnIntersectionEnterTrigger: number;
  5572. /**
  5573. * On intersection exit
  5574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5575. */
  5576. static readonly ACTION_OnIntersectionExitTrigger: number;
  5577. /**
  5578. * On key down
  5579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5580. */
  5581. static readonly ACTION_OnKeyDownTrigger: number;
  5582. /**
  5583. * On key up
  5584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5585. */
  5586. static readonly ACTION_OnKeyUpTrigger: number;
  5587. /**
  5588. * Billboard mode will only apply to Y axis
  5589. */
  5590. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  5591. /**
  5592. * Billboard mode will apply to all axes
  5593. */
  5594. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  5595. /**
  5596. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  5597. */
  5598. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  5599. }
  5600. }
  5601. declare module "babylonjs/States/alphaCullingState" {
  5602. /**
  5603. * @hidden
  5604. **/
  5605. export class _AlphaState {
  5606. private _isAlphaBlendDirty;
  5607. private _isBlendFunctionParametersDirty;
  5608. private _isBlendEquationParametersDirty;
  5609. private _isBlendConstantsDirty;
  5610. private _alphaBlend;
  5611. private _blendFunctionParameters;
  5612. private _blendEquationParameters;
  5613. private _blendConstants;
  5614. /**
  5615. * Initializes the state.
  5616. */
  5617. constructor();
  5618. readonly isDirty: boolean;
  5619. alphaBlend: boolean;
  5620. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5621. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5622. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5623. reset(): void;
  5624. apply(gl: WebGLRenderingContext): void;
  5625. }
  5626. }
  5627. declare module "babylonjs/States/depthCullingState" {
  5628. import { Nullable } from "babylonjs/types";
  5629. /**
  5630. * @hidden
  5631. **/
  5632. export class _DepthCullingState {
  5633. private _isDepthTestDirty;
  5634. private _isDepthMaskDirty;
  5635. private _isDepthFuncDirty;
  5636. private _isCullFaceDirty;
  5637. private _isCullDirty;
  5638. private _isZOffsetDirty;
  5639. private _isFrontFaceDirty;
  5640. private _depthTest;
  5641. private _depthMask;
  5642. private _depthFunc;
  5643. private _cull;
  5644. private _cullFace;
  5645. private _zOffset;
  5646. private _frontFace;
  5647. /**
  5648. * Initializes the state.
  5649. */
  5650. constructor();
  5651. readonly isDirty: boolean;
  5652. zOffset: number;
  5653. cullFace: Nullable<number>;
  5654. cull: Nullable<boolean>;
  5655. depthFunc: Nullable<number>;
  5656. depthMask: boolean;
  5657. depthTest: boolean;
  5658. frontFace: Nullable<number>;
  5659. reset(): void;
  5660. apply(gl: WebGLRenderingContext): void;
  5661. }
  5662. }
  5663. declare module "babylonjs/States/stencilState" {
  5664. /**
  5665. * @hidden
  5666. **/
  5667. export class _StencilState {
  5668. /** 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 */
  5669. static readonly ALWAYS: number;
  5670. /** Passed to stencilOperation to specify that stencil value must be kept */
  5671. static readonly KEEP: number;
  5672. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5673. static readonly REPLACE: number;
  5674. private _isStencilTestDirty;
  5675. private _isStencilMaskDirty;
  5676. private _isStencilFuncDirty;
  5677. private _isStencilOpDirty;
  5678. private _stencilTest;
  5679. private _stencilMask;
  5680. private _stencilFunc;
  5681. private _stencilFuncRef;
  5682. private _stencilFuncMask;
  5683. private _stencilOpStencilFail;
  5684. private _stencilOpDepthFail;
  5685. private _stencilOpStencilDepthPass;
  5686. readonly isDirty: boolean;
  5687. stencilFunc: number;
  5688. stencilFuncRef: number;
  5689. stencilFuncMask: number;
  5690. stencilOpStencilFail: number;
  5691. stencilOpDepthFail: number;
  5692. stencilOpStencilDepthPass: number;
  5693. stencilMask: number;
  5694. stencilTest: boolean;
  5695. constructor();
  5696. reset(): void;
  5697. apply(gl: WebGLRenderingContext): void;
  5698. }
  5699. }
  5700. declare module "babylonjs/States/index" {
  5701. export * from "babylonjs/States/alphaCullingState";
  5702. export * from "babylonjs/States/depthCullingState";
  5703. export * from "babylonjs/States/stencilState";
  5704. }
  5705. declare module "babylonjs/Instrumentation/timeToken" {
  5706. import { Nullable } from "babylonjs/types";
  5707. /**
  5708. * @hidden
  5709. **/
  5710. export class _TimeToken {
  5711. _startTimeQuery: Nullable<WebGLQuery>;
  5712. _endTimeQuery: Nullable<WebGLQuery>;
  5713. _timeElapsedQuery: Nullable<WebGLQuery>;
  5714. _timeElapsedQueryEnded: boolean;
  5715. }
  5716. }
  5717. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  5718. import { Nullable } from "babylonjs/types";
  5719. /**
  5720. * Internal interface used to track InternalTexture already bound to the GL context
  5721. */
  5722. export interface IInternalTextureTracker {
  5723. /**
  5724. * Gets or set the previous tracker in the list
  5725. */
  5726. previous: Nullable<IInternalTextureTracker>;
  5727. /**
  5728. * Gets or set the next tracker in the list
  5729. */
  5730. next: Nullable<IInternalTextureTracker>;
  5731. }
  5732. /**
  5733. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  5734. */
  5735. export class DummyInternalTextureTracker {
  5736. /**
  5737. * Gets or set the previous tracker in the list
  5738. */
  5739. previous: Nullable<IInternalTextureTracker>;
  5740. /**
  5741. * Gets or set the next tracker in the list
  5742. */
  5743. next: Nullable<IInternalTextureTracker>;
  5744. }
  5745. }
  5746. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5747. /**
  5748. * Class used to evalaute queries containing `and` and `or` operators
  5749. */
  5750. export class AndOrNotEvaluator {
  5751. /**
  5752. * Evaluate a query
  5753. * @param query defines the query to evaluate
  5754. * @param evaluateCallback defines the callback used to filter result
  5755. * @returns true if the query matches
  5756. */
  5757. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5758. private static _HandleParenthesisContent;
  5759. private static _SimplifyNegation;
  5760. }
  5761. }
  5762. declare module "babylonjs/Misc/tags" {
  5763. /**
  5764. * Class used to store custom tags
  5765. */
  5766. export class Tags {
  5767. /**
  5768. * Adds support for tags on the given object
  5769. * @param obj defines the object to use
  5770. */
  5771. static EnableFor(obj: any): void;
  5772. /**
  5773. * Removes tags support
  5774. * @param obj defines the object to use
  5775. */
  5776. static DisableFor(obj: any): void;
  5777. /**
  5778. * Gets a boolean indicating if the given object has tags
  5779. * @param obj defines the object to use
  5780. * @returns a boolean
  5781. */
  5782. static HasTags(obj: any): boolean;
  5783. /**
  5784. * Gets the tags available on a given object
  5785. * @param obj defines the object to use
  5786. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5787. * @returns the tags
  5788. */
  5789. static GetTags(obj: any, asString?: boolean): any;
  5790. /**
  5791. * Adds tags to an object
  5792. * @param obj defines the object to use
  5793. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5794. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5795. */
  5796. static AddTagsTo(obj: any, tagsString: string): void;
  5797. /**
  5798. * @hidden
  5799. */
  5800. static _AddTagTo(obj: any, tag: string): void;
  5801. /**
  5802. * Removes specific tags from a specific object
  5803. * @param obj defines the object to use
  5804. * @param tagsString defines the tags to remove
  5805. */
  5806. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5807. /**
  5808. * @hidden
  5809. */
  5810. static _RemoveTagFrom(obj: any, tag: string): void;
  5811. /**
  5812. * Defines if tags hosted on an object match a given query
  5813. * @param obj defines the object to use
  5814. * @param tagsQuery defines the tag query
  5815. * @returns a boolean
  5816. */
  5817. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5818. }
  5819. }
  5820. declare module "babylonjs/Misc/smartArray" {
  5821. /**
  5822. * Defines an array and its length.
  5823. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5824. */
  5825. export interface ISmartArrayLike<T> {
  5826. /**
  5827. * The data of the array.
  5828. */
  5829. data: Array<T>;
  5830. /**
  5831. * The active length of the array.
  5832. */
  5833. length: number;
  5834. }
  5835. /**
  5836. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5837. */
  5838. export class SmartArray<T> implements ISmartArrayLike<T> {
  5839. /**
  5840. * The full set of data from the array.
  5841. */
  5842. data: Array<T>;
  5843. /**
  5844. * The active length of the array.
  5845. */
  5846. length: number;
  5847. protected _id: number;
  5848. /**
  5849. * Instantiates a Smart Array.
  5850. * @param capacity defines the default capacity of the array.
  5851. */
  5852. constructor(capacity: number);
  5853. /**
  5854. * Pushes a value at the end of the active data.
  5855. * @param value defines the object to push in the array.
  5856. */
  5857. push(value: T): void;
  5858. /**
  5859. * Iterates over the active data and apply the lambda to them.
  5860. * @param func defines the action to apply on each value.
  5861. */
  5862. forEach(func: (content: T) => void): void;
  5863. /**
  5864. * Sorts the full sets of data.
  5865. * @param compareFn defines the comparison function to apply.
  5866. */
  5867. sort(compareFn: (a: T, b: T) => number): void;
  5868. /**
  5869. * Resets the active data to an empty array.
  5870. */
  5871. reset(): void;
  5872. /**
  5873. * Releases all the data from the array as well as the array.
  5874. */
  5875. dispose(): void;
  5876. /**
  5877. * Concats the active data with a given array.
  5878. * @param array defines the data to concatenate with.
  5879. */
  5880. concat(array: any): void;
  5881. /**
  5882. * Returns the position of a value in the active data.
  5883. * @param value defines the value to find the index for
  5884. * @returns the index if found in the active data otherwise -1
  5885. */
  5886. indexOf(value: T): number;
  5887. /**
  5888. * Returns whether an element is part of the active data.
  5889. * @param value defines the value to look for
  5890. * @returns true if found in the active data otherwise false
  5891. */
  5892. contains(value: T): boolean;
  5893. private static _GlobalId;
  5894. }
  5895. /**
  5896. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5897. * The data in this array can only be present once
  5898. */
  5899. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5900. private _duplicateId;
  5901. /**
  5902. * Pushes a value at the end of the active data.
  5903. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5904. * @param value defines the object to push in the array.
  5905. */
  5906. push(value: T): void;
  5907. /**
  5908. * Pushes a value at the end of the active data.
  5909. * If the data is already present, it won t be added again
  5910. * @param value defines the object to push in the array.
  5911. * @returns true if added false if it was already present
  5912. */
  5913. pushNoDuplicate(value: T): boolean;
  5914. /**
  5915. * Resets the active data to an empty array.
  5916. */
  5917. reset(): void;
  5918. /**
  5919. * Concats the active data with a given array.
  5920. * This ensures no dupplicate will be present in the result.
  5921. * @param array defines the data to concatenate with.
  5922. */
  5923. concatWithNoDuplicate(array: any): void;
  5924. }
  5925. }
  5926. declare module "babylonjs/Misc/logger" {
  5927. /**
  5928. * Logger used througouht the application to allow configuration of
  5929. * the log level required for the messages.
  5930. */
  5931. export class Logger {
  5932. /**
  5933. * No log
  5934. */
  5935. static readonly NoneLogLevel: number;
  5936. /**
  5937. * Only message logs
  5938. */
  5939. static readonly MessageLogLevel: number;
  5940. /**
  5941. * Only warning logs
  5942. */
  5943. static readonly WarningLogLevel: number;
  5944. /**
  5945. * Only error logs
  5946. */
  5947. static readonly ErrorLogLevel: number;
  5948. /**
  5949. * All logs
  5950. */
  5951. static readonly AllLogLevel: number;
  5952. private static _LogCache;
  5953. /**
  5954. * Gets a value indicating the number of loading errors
  5955. * @ignorenaming
  5956. */
  5957. static errorsCount: number;
  5958. /**
  5959. * Callback called when a new log is added
  5960. */
  5961. static OnNewCacheEntry: (entry: string) => void;
  5962. private static _AddLogEntry;
  5963. private static _FormatMessage;
  5964. private static _LogDisabled;
  5965. private static _LogEnabled;
  5966. private static _WarnDisabled;
  5967. private static _WarnEnabled;
  5968. private static _ErrorDisabled;
  5969. private static _ErrorEnabled;
  5970. /**
  5971. * Log a message to the console
  5972. */
  5973. static Log: (message: string) => void;
  5974. /**
  5975. * Write a warning message to the console
  5976. */
  5977. static Warn: (message: string) => void;
  5978. /**
  5979. * Write an error message to the console
  5980. */
  5981. static Error: (message: string) => void;
  5982. /**
  5983. * Gets current log cache (list of logs)
  5984. */
  5985. static readonly LogCache: string;
  5986. /**
  5987. * Clears the log cache
  5988. */
  5989. static ClearLogCache(): void;
  5990. /**
  5991. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  5992. */
  5993. static LogLevels: number;
  5994. }
  5995. }
  5996. declare module "babylonjs/Cameras/cameraInputsManager" {
  5997. import { Nullable } from "babylonjs/types";
  5998. import { Camera } from "babylonjs/Cameras/camera";
  5999. /**
  6000. * @ignore
  6001. * This is a list of all the different input types that are available in the application.
  6002. * Fo instance: ArcRotateCameraGamepadInput...
  6003. */
  6004. export var CameraInputTypes: {};
  6005. /**
  6006. * This is the contract to implement in order to create a new input class.
  6007. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6008. */
  6009. export interface ICameraInput<TCamera extends Camera> {
  6010. /**
  6011. * Defines the camera the input is attached to.
  6012. */
  6013. camera: Nullable<TCamera>;
  6014. /**
  6015. * Gets the class name of the current intput.
  6016. * @returns the class name
  6017. */
  6018. getClassName(): string;
  6019. /**
  6020. * Get the friendly name associated with the input class.
  6021. * @returns the input friendly name
  6022. */
  6023. getSimpleName(): string;
  6024. /**
  6025. * Attach the input controls to a specific dom element to get the input from.
  6026. * @param element Defines the element the controls should be listened from
  6027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6028. */
  6029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6030. /**
  6031. * Detach the current controls from the specified dom element.
  6032. * @param element Defines the element to stop listening the inputs from
  6033. */
  6034. detachControl(element: Nullable<HTMLElement>): void;
  6035. /**
  6036. * Update the current camera state depending on the inputs that have been used this frame.
  6037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6038. */
  6039. checkInputs?: () => void;
  6040. }
  6041. /**
  6042. * Represents a map of input types to input instance or input index to input instance.
  6043. */
  6044. export interface CameraInputsMap<TCamera extends Camera> {
  6045. /**
  6046. * Accessor to the input by input type.
  6047. */
  6048. [name: string]: ICameraInput<TCamera>;
  6049. /**
  6050. * Accessor to the input by input index.
  6051. */
  6052. [idx: number]: ICameraInput<TCamera>;
  6053. }
  6054. /**
  6055. * This represents the input manager used within a camera.
  6056. * It helps dealing with all the different kind of input attached to a camera.
  6057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6058. */
  6059. export class CameraInputsManager<TCamera extends Camera> {
  6060. /**
  6061. * Defines the list of inputs attahed to the camera.
  6062. */
  6063. attached: CameraInputsMap<TCamera>;
  6064. /**
  6065. * Defines the dom element the camera is collecting inputs from.
  6066. * This is null if the controls have not been attached.
  6067. */
  6068. attachedElement: Nullable<HTMLElement>;
  6069. /**
  6070. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6071. */
  6072. noPreventDefault: boolean;
  6073. /**
  6074. * Defined the camera the input manager belongs to.
  6075. */
  6076. camera: TCamera;
  6077. /**
  6078. * Update the current camera state depending on the inputs that have been used this frame.
  6079. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6080. */
  6081. checkInputs: () => void;
  6082. /**
  6083. * Instantiate a new Camera Input Manager.
  6084. * @param camera Defines the camera the input manager blongs to
  6085. */
  6086. constructor(camera: TCamera);
  6087. /**
  6088. * Add an input method to a camera
  6089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6090. * @param input camera input method
  6091. */
  6092. add(input: ICameraInput<TCamera>): void;
  6093. /**
  6094. * Remove a specific input method from a camera
  6095. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6096. * @param inputToRemove camera input method
  6097. */
  6098. remove(inputToRemove: ICameraInput<TCamera>): void;
  6099. /**
  6100. * Remove a specific input type from a camera
  6101. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6102. * @param inputType the type of the input to remove
  6103. */
  6104. removeByType(inputType: string): void;
  6105. private _addCheckInputs;
  6106. /**
  6107. * Attach the input controls to the currently attached dom element to listen the events from.
  6108. * @param input Defines the input to attach
  6109. */
  6110. attachInput(input: ICameraInput<TCamera>): void;
  6111. /**
  6112. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6113. * @param element Defines the dom element to collect the events from
  6114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6115. */
  6116. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6117. /**
  6118. * Detach the current manager inputs controls from a specific dom element.
  6119. * @param element Defines the dom element to collect the events from
  6120. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6121. */
  6122. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6123. /**
  6124. * Rebuild the dynamic inputCheck function from the current list of
  6125. * defined inputs in the manager.
  6126. */
  6127. rebuildInputCheck(): void;
  6128. /**
  6129. * Remove all attached input methods from a camera
  6130. */
  6131. clear(): void;
  6132. /**
  6133. * Serialize the current input manager attached to a camera.
  6134. * This ensures than once parsed,
  6135. * the input associated to the camera will be identical to the current ones
  6136. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6137. */
  6138. serialize(serializedCamera: any): void;
  6139. /**
  6140. * Parses an input manager serialized JSON to restore the previous list of inputs
  6141. * and states associated to a camera.
  6142. * @param parsedCamera Defines the JSON to parse
  6143. */
  6144. parse(parsedCamera: any): void;
  6145. }
  6146. }
  6147. declare module "babylonjs/Meshes/buffer" {
  6148. import { Nullable, DataArray } from "babylonjs/types";
  6149. /**
  6150. * Class used to store data that will be store in GPU memory
  6151. */
  6152. export class Buffer {
  6153. private _engine;
  6154. private _buffer;
  6155. /** @hidden */
  6156. _data: Nullable<DataArray>;
  6157. private _updatable;
  6158. private _instanced;
  6159. /**
  6160. * Gets the byte stride.
  6161. */
  6162. readonly byteStride: number;
  6163. /**
  6164. * Constructor
  6165. * @param engine the engine
  6166. * @param data the data to use for this buffer
  6167. * @param updatable whether the data is updatable
  6168. * @param stride the stride (optional)
  6169. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6170. * @param instanced whether the buffer is instanced (optional)
  6171. * @param useBytes set to true if the stride in in bytes (optional)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes
  6182. * @returns the new vertex buffer
  6183. */
  6184. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6185. /**
  6186. * Gets a boolean indicating if the Buffer is updatable?
  6187. * @returns true if the buffer is updatable
  6188. */
  6189. isUpdatable(): boolean;
  6190. /**
  6191. * Gets current buffer's data
  6192. * @returns a DataArray or null
  6193. */
  6194. getData(): Nullable<DataArray>;
  6195. /**
  6196. * Gets underlying native buffer
  6197. * @returns underlying native buffer
  6198. */
  6199. getBuffer(): Nullable<WebGLBuffer>;
  6200. /**
  6201. * Gets the stride in float32 units (i.e. byte stride / 4).
  6202. * May not be an integer if the byte stride is not divisible by 4.
  6203. * DEPRECATED. Use byteStride instead.
  6204. * @returns the stride in float32 units
  6205. */
  6206. getStrideSize(): number;
  6207. /**
  6208. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6209. * @param data defines the data to store
  6210. */
  6211. create(data?: Nullable<DataArray>): void;
  6212. /** @hidden */
  6213. _rebuild(): void;
  6214. /**
  6215. * Update current buffer data
  6216. * @param data defines the data to store
  6217. */
  6218. update(data: DataArray): void;
  6219. /**
  6220. * Updates the data directly.
  6221. * @param data the new data
  6222. * @param offset the new offset
  6223. * @param vertexCount the vertex count (optional)
  6224. * @param useBytes set to true if the offset is in bytes
  6225. */
  6226. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6227. /**
  6228. * Release all resources
  6229. */
  6230. dispose(): void;
  6231. }
  6232. /**
  6233. * Specialized buffer used to store vertex data
  6234. */
  6235. export class VertexBuffer {
  6236. /** @hidden */
  6237. _buffer: Buffer;
  6238. private _kind;
  6239. private _size;
  6240. private _ownsBuffer;
  6241. private _instanced;
  6242. private _instanceDivisor;
  6243. /**
  6244. * The byte type.
  6245. */
  6246. static readonly BYTE: number;
  6247. /**
  6248. * The unsigned byte type.
  6249. */
  6250. static readonly UNSIGNED_BYTE: number;
  6251. /**
  6252. * The short type.
  6253. */
  6254. static readonly SHORT: number;
  6255. /**
  6256. * The unsigned short type.
  6257. */
  6258. static readonly UNSIGNED_SHORT: number;
  6259. /**
  6260. * The integer type.
  6261. */
  6262. static readonly INT: number;
  6263. /**
  6264. * The unsigned integer type.
  6265. */
  6266. static readonly UNSIGNED_INT: number;
  6267. /**
  6268. * The float type.
  6269. */
  6270. static readonly FLOAT: number;
  6271. /**
  6272. * Gets or sets the instance divisor when in instanced mode
  6273. */
  6274. instanceDivisor: number;
  6275. /**
  6276. * Gets the byte stride.
  6277. */
  6278. readonly byteStride: number;
  6279. /**
  6280. * Gets the byte offset.
  6281. */
  6282. readonly byteOffset: number;
  6283. /**
  6284. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6285. */
  6286. readonly normalized: boolean;
  6287. /**
  6288. * Gets the data type of each component in the array.
  6289. */
  6290. readonly type: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this vertex buffer
  6295. * @param kind the vertex buffer kind
  6296. * @param updatable whether the data is updatable
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param stride the stride (optional)
  6299. * @param instanced whether the buffer is instanced (optional)
  6300. * @param offset the offset of the data (optional)
  6301. * @param size the number of components (optional)
  6302. * @param type the type of the component (optional)
  6303. * @param normalized whether the data contains normalized data (optional)
  6304. * @param useBytes set to true if stride and offset are in bytes (optional)
  6305. */
  6306. 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);
  6307. /** @hidden */
  6308. _rebuild(): void;
  6309. /**
  6310. * Returns the kind of the VertexBuffer (string)
  6311. * @returns a string
  6312. */
  6313. getKind(): string;
  6314. /**
  6315. * Gets a boolean indicating if the VertexBuffer is updatable?
  6316. * @returns true if the buffer is updatable
  6317. */
  6318. isUpdatable(): boolean;
  6319. /**
  6320. * Gets current buffer's data
  6321. * @returns a DataArray or null
  6322. */
  6323. getData(): Nullable<DataArray>;
  6324. /**
  6325. * Gets underlying native buffer
  6326. * @returns underlying native buffer
  6327. */
  6328. getBuffer(): Nullable<WebGLBuffer>;
  6329. /**
  6330. * Gets the stride in float32 units (i.e. byte stride / 4).
  6331. * May not be an integer if the byte stride is not divisible by 4.
  6332. * DEPRECATED. Use byteStride instead.
  6333. * @returns the stride in float32 units
  6334. */
  6335. getStrideSize(): number;
  6336. /**
  6337. * Returns the offset as a multiple of the type byte length.
  6338. * DEPRECATED. Use byteOffset instead.
  6339. * @returns the offset in bytes
  6340. */
  6341. getOffset(): number;
  6342. /**
  6343. * Returns the number of components per vertex attribute (integer)
  6344. * @returns the size in float
  6345. */
  6346. getSize(): number;
  6347. /**
  6348. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6349. * @returns true if this buffer is instanced
  6350. */
  6351. getIsInstanced(): boolean;
  6352. /**
  6353. * Returns the instancing divisor, zero for non-instanced (integer).
  6354. * @returns a number
  6355. */
  6356. getInstanceDivisor(): number;
  6357. /**
  6358. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6359. * @param data defines the data to store
  6360. */
  6361. create(data?: DataArray): void;
  6362. /**
  6363. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6364. * This function will create a new buffer if the current one is not updatable
  6365. * @param data defines the data to store
  6366. */
  6367. update(data: DataArray): void;
  6368. /**
  6369. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6370. * Returns the directly updated WebGLBuffer.
  6371. * @param data the new data
  6372. * @param offset the new offset
  6373. * @param useBytes set to true if the offset is in bytes
  6374. */
  6375. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6376. /**
  6377. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6378. */
  6379. dispose(): void;
  6380. /**
  6381. * Enumerates each value of this vertex buffer as numbers.
  6382. * @param count the number of values to enumerate
  6383. * @param callback the callback function called for each value
  6384. */
  6385. forEach(count: number, callback: (value: number, index: number) => void): void;
  6386. /**
  6387. * Positions
  6388. */
  6389. static readonly PositionKind: string;
  6390. /**
  6391. * Normals
  6392. */
  6393. static readonly NormalKind: string;
  6394. /**
  6395. * Tangents
  6396. */
  6397. static readonly TangentKind: string;
  6398. /**
  6399. * Texture coordinates
  6400. */
  6401. static readonly UVKind: string;
  6402. /**
  6403. * Texture coordinates 2
  6404. */
  6405. static readonly UV2Kind: string;
  6406. /**
  6407. * Texture coordinates 3
  6408. */
  6409. static readonly UV3Kind: string;
  6410. /**
  6411. * Texture coordinates 4
  6412. */
  6413. static readonly UV4Kind: string;
  6414. /**
  6415. * Texture coordinates 5
  6416. */
  6417. static readonly UV5Kind: string;
  6418. /**
  6419. * Texture coordinates 6
  6420. */
  6421. static readonly UV6Kind: string;
  6422. /**
  6423. * Colors
  6424. */
  6425. static readonly ColorKind: string;
  6426. /**
  6427. * Matrix indices (for bones)
  6428. */
  6429. static readonly MatricesIndicesKind: string;
  6430. /**
  6431. * Matrix weights (for bones)
  6432. */
  6433. static readonly MatricesWeightsKind: string;
  6434. /**
  6435. * Additional matrix indices (for bones)
  6436. */
  6437. static readonly MatricesIndicesExtraKind: string;
  6438. /**
  6439. * Additional matrix weights (for bones)
  6440. */
  6441. static readonly MatricesWeightsExtraKind: string;
  6442. /**
  6443. * Deduces the stride given a kind.
  6444. * @param kind The kind string to deduce
  6445. * @returns The deduced stride
  6446. */
  6447. static DeduceStride(kind: string): number;
  6448. /**
  6449. * Gets the byte length of the given type.
  6450. * @param type the type
  6451. * @returns the number of bytes
  6452. */
  6453. static GetTypeByteLength(type: number): number;
  6454. /**
  6455. * Enumerates each value of the given parameters as numbers.
  6456. * @param data the data to enumerate
  6457. * @param byteOffset the byte offset of the data
  6458. * @param byteStride the byte stride of the data
  6459. * @param componentCount the number of components per element
  6460. * @param componentType the type of the component
  6461. * @param count the total number of components
  6462. * @param normalized whether the data is normalized
  6463. * @param callback the callback function called for each value
  6464. */
  6465. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6466. private static _GetFloatValue;
  6467. }
  6468. }
  6469. declare module "babylonjs/Materials/Textures/cubeTexture" {
  6470. import { Nullable } from "babylonjs/types";
  6471. import { Scene } from "babylonjs/scene";
  6472. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  6473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6474. /**
  6475. * Class for creating a cube texture
  6476. */
  6477. export class CubeTexture extends BaseTexture {
  6478. private _delayedOnLoad;
  6479. /**
  6480. * The url of the texture
  6481. */
  6482. url: string;
  6483. /**
  6484. * Gets or sets the center of the bounding box associated with the cube texture.
  6485. * It must define where the camera used to render the texture was set
  6486. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  6487. */
  6488. boundingBoxPosition: Vector3;
  6489. private _boundingBoxSize;
  6490. /**
  6491. * Gets or sets the size of the bounding box associated with the cube texture
  6492. * When defined, the cubemap will switch to local mode
  6493. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  6494. * @example https://www.babylonjs-playground.com/#RNASML
  6495. */
  6496. /**
  6497. * Returns the bounding box size
  6498. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  6499. */
  6500. boundingBoxSize: Vector3;
  6501. protected _rotationY: number;
  6502. /**
  6503. * Sets texture matrix rotation angle around Y axis in radians.
  6504. */
  6505. /**
  6506. * Gets texture matrix rotation angle around Y axis radians.
  6507. */
  6508. rotationY: number;
  6509. /**
  6510. * Are mip maps generated for this texture or not.
  6511. */
  6512. readonly noMipmap: boolean;
  6513. private _noMipmap;
  6514. private _files;
  6515. private _extensions;
  6516. private _textureMatrix;
  6517. private _format;
  6518. private _createPolynomials;
  6519. /** @hidden */
  6520. _prefiltered: boolean;
  6521. /**
  6522. * Creates a cube texture from an array of image urls
  6523. * @param files defines an array of image urls
  6524. * @param scene defines the hosting scene
  6525. * @param noMipmap specifies if mip maps are not used
  6526. * @returns a cube texture
  6527. */
  6528. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  6529. /**
  6530. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  6531. * @param url defines the url of the prefiltered texture
  6532. * @param scene defines the scene the texture is attached to
  6533. * @param forcedExtension defines the extension of the file if different from the url
  6534. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  6535. * @return the prefiltered texture
  6536. */
  6537. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  6538. /**
  6539. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  6540. * as prefiltered data.
  6541. * @param rootUrl defines the url of the texture or the root name of the six images
  6542. * @param scene defines the scene the texture is attached to
  6543. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  6544. * @param noMipmap defines if mipmaps should be created or not
  6545. * @param files defines the six files to load for the different faces
  6546. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  6547. * @param onError defines a callback triggered in case of error during load
  6548. * @param format defines the internal format to use for the texture once loaded
  6549. * @param prefiltered defines whether or not the texture is created from prefiltered data
  6550. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  6551. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  6552. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  6553. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  6554. * @return the cube texture
  6555. */
  6556. 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);
  6557. /**
  6558. * Get the current class name of the texture useful for serialization or dynamic coding.
  6559. * @returns "CubeTexture"
  6560. */
  6561. getClassName(): string;
  6562. /**
  6563. * Update the url (and optional buffer) of this texture if url was null during construction.
  6564. * @param url the url of the texture
  6565. * @param forcedExtension defines the extension to use
  6566. * @param onLoad callback called when the texture is loaded (defaults to null)
  6567. */
  6568. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  6569. /**
  6570. * Delays loading of the cube texture
  6571. * @param forcedExtension defines the extension to use
  6572. */
  6573. delayLoad(forcedExtension?: string): void;
  6574. /**
  6575. * Returns the reflection texture matrix
  6576. * @returns the reflection texture matrix
  6577. */
  6578. getReflectionTextureMatrix(): Matrix;
  6579. /**
  6580. * Sets the reflection texture matrix
  6581. * @param value Reflection texture matrix
  6582. */
  6583. setReflectionTextureMatrix(value: Matrix): void;
  6584. /**
  6585. * Parses text to create a cube texture
  6586. * @param parsedTexture define the serialized text to read from
  6587. * @param scene defines the hosting scene
  6588. * @param rootUrl defines the root url of the cube texture
  6589. * @returns a cube texture
  6590. */
  6591. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  6592. /**
  6593. * Makes a clone, or deep copy, of the cube texture
  6594. * @returns a new cube texture
  6595. */
  6596. clone(): CubeTexture;
  6597. }
  6598. }
  6599. declare module "babylonjs/Misc/domManagement" {
  6600. /**
  6601. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  6602. * Babylon.js
  6603. */
  6604. export class DomManagement {
  6605. /**
  6606. * Checks if the window object exists
  6607. * @returns true if the window object exists
  6608. */
  6609. static IsWindowObjectExist(): boolean;
  6610. /**
  6611. * Extracts text content from a DOM element hierarchy
  6612. * @param element defines the root element
  6613. * @returns a string
  6614. */
  6615. static GetDOMTextContent(element: HTMLElement): string;
  6616. }
  6617. }
  6618. declare module "babylonjs/Shaders/postprocess.vertex" {
  6619. export var postprocessVertexShader: {
  6620. name: string;
  6621. shader: string;
  6622. };
  6623. }
  6624. declare module "babylonjs/Cameras/targetCamera" {
  6625. import { Nullable } from "babylonjs/types";
  6626. import { Camera } from "babylonjs/Cameras/camera";
  6627. import { Scene } from "babylonjs/scene";
  6628. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  6629. /**
  6630. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  6631. * This is the base of the follow, arc rotate cameras and Free camera
  6632. * @see http://doc.babylonjs.com/features/cameras
  6633. */
  6634. export class TargetCamera extends Camera {
  6635. private static _RigCamTransformMatrix;
  6636. private static _TargetTransformMatrix;
  6637. /**
  6638. * Define the current direction the camera is moving to
  6639. */
  6640. cameraDirection: Vector3;
  6641. /**
  6642. * Define the current rotation the camera is rotating to
  6643. */
  6644. cameraRotation: Vector2;
  6645. /**
  6646. * When set, the up vector of the camera will be updated by the rotation of the camera
  6647. */
  6648. updateUpVectorFromRotation: boolean;
  6649. private _tmpQuaternion;
  6650. /**
  6651. * Define the current rotation of the camera
  6652. */
  6653. rotation: Vector3;
  6654. /**
  6655. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  6656. */
  6657. rotationQuaternion: Quaternion;
  6658. /**
  6659. * Define the current speed of the camera
  6660. */
  6661. speed: number;
  6662. /**
  6663. * Add cconstraint to the camera to prevent it to move freely in all directions and
  6664. * around all axis.
  6665. */
  6666. noRotationConstraint: boolean;
  6667. /**
  6668. * Define the current target of the camera as an object or a position.
  6669. */
  6670. lockedTarget: any;
  6671. /** @hidden */
  6672. _currentTarget: Vector3;
  6673. /** @hidden */
  6674. _viewMatrix: Matrix;
  6675. /** @hidden */
  6676. _camMatrix: Matrix;
  6677. /** @hidden */
  6678. _cameraTransformMatrix: Matrix;
  6679. /** @hidden */
  6680. _cameraRotationMatrix: Matrix;
  6681. /** @hidden */
  6682. _referencePoint: Vector3;
  6683. /** @hidden */
  6684. _transformedReferencePoint: Vector3;
  6685. protected _globalCurrentTarget: Vector3;
  6686. protected _globalCurrentUpVector: Vector3;
  6687. /** @hidden */
  6688. _reset: () => void;
  6689. private _defaultUp;
  6690. /**
  6691. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  6692. * This is the base of the follow, arc rotate cameras and Free camera
  6693. * @see http://doc.babylonjs.com/features/cameras
  6694. * @param name Defines the name of the camera in the scene
  6695. * @param position Defines the start position of the camera in the scene
  6696. * @param scene Defines the scene the camera belongs to
  6697. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6698. */
  6699. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6700. /**
  6701. * Gets the position in front of the camera at a given distance.
  6702. * @param distance The distance from the camera we want the position to be
  6703. * @returns the position
  6704. */
  6705. getFrontPosition(distance: number): Vector3;
  6706. /** @hidden */
  6707. _getLockedTargetPosition(): Nullable<Vector3>;
  6708. private _storedPosition;
  6709. private _storedRotation;
  6710. private _storedRotationQuaternion;
  6711. /**
  6712. * Store current camera state of the camera (fov, position, rotation, etc..)
  6713. * @returns the camera
  6714. */
  6715. storeState(): Camera;
  6716. /**
  6717. * Restored camera state. You must call storeState() first
  6718. * @returns whether it was successful or not
  6719. * @hidden
  6720. */
  6721. _restoreStateValues(): boolean;
  6722. /** @hidden */
  6723. _initCache(): void;
  6724. /** @hidden */
  6725. _updateCache(ignoreParentClass?: boolean): void;
  6726. /** @hidden */
  6727. _isSynchronizedViewMatrix(): boolean;
  6728. /** @hidden */
  6729. _computeLocalCameraSpeed(): number;
  6730. /** @hidden */
  6731. setTarget(target: Vector3): void;
  6732. /**
  6733. * Return the current target position of the camera. This value is expressed in local space.
  6734. * @returns the target position
  6735. */
  6736. getTarget(): Vector3;
  6737. /** @hidden */
  6738. _decideIfNeedsToMove(): boolean;
  6739. /** @hidden */
  6740. _updatePosition(): void;
  6741. /** @hidden */
  6742. _checkInputs(): void;
  6743. protected _updateCameraRotationMatrix(): void;
  6744. /**
  6745. * 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)
  6746. * @returns the current camera
  6747. */
  6748. private _rotateUpVectorWithCameraRotationMatrix;
  6749. private _cachedRotationZ;
  6750. private _cachedQuaternionRotationZ;
  6751. /** @hidden */
  6752. _getViewMatrix(): Matrix;
  6753. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6754. /**
  6755. * @hidden
  6756. */
  6757. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6758. /**
  6759. * @hidden
  6760. */
  6761. _updateRigCameras(): void;
  6762. private _getRigCamPosition;
  6763. /**
  6764. * Gets the current object class name.
  6765. * @return the class name
  6766. */
  6767. getClassName(): string;
  6768. }
  6769. }
  6770. declare module "babylonjs/Events/keyboardEvents" {
  6771. /**
  6772. * Gather the list of keyboard event types as constants.
  6773. */
  6774. export class KeyboardEventTypes {
  6775. /**
  6776. * The keydown event is fired when a key becomes active (pressed).
  6777. */
  6778. static readonly KEYDOWN: number;
  6779. /**
  6780. * The keyup event is fired when a key has been released.
  6781. */
  6782. static readonly KEYUP: number;
  6783. }
  6784. /**
  6785. * This class is used to store keyboard related info for the onKeyboardObservable event.
  6786. */
  6787. export class KeyboardInfo {
  6788. /**
  6789. * Defines the type of event (KeyboardEventTypes)
  6790. */
  6791. type: number;
  6792. /**
  6793. * Defines the related dom event
  6794. */
  6795. event: KeyboardEvent;
  6796. /**
  6797. * Instantiates a new keyboard info.
  6798. * This class is used to store keyboard related info for the onKeyboardObservable event.
  6799. * @param type Defines the type of event (KeyboardEventTypes)
  6800. * @param event Defines the related dom event
  6801. */
  6802. constructor(
  6803. /**
  6804. * Defines the type of event (KeyboardEventTypes)
  6805. */
  6806. type: number,
  6807. /**
  6808. * Defines the related dom event
  6809. */
  6810. event: KeyboardEvent);
  6811. }
  6812. /**
  6813. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  6814. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  6815. */
  6816. export class KeyboardInfoPre extends KeyboardInfo {
  6817. /**
  6818. * Defines the type of event (KeyboardEventTypes)
  6819. */
  6820. type: number;
  6821. /**
  6822. * Defines the related dom event
  6823. */
  6824. event: KeyboardEvent;
  6825. /**
  6826. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  6827. */
  6828. skipOnPointerObservable: boolean;
  6829. /**
  6830. * Instantiates a new keyboard pre info.
  6831. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  6832. * @param type Defines the type of event (KeyboardEventTypes)
  6833. * @param event Defines the related dom event
  6834. */
  6835. constructor(
  6836. /**
  6837. * Defines the type of event (KeyboardEventTypes)
  6838. */
  6839. type: number,
  6840. /**
  6841. * Defines the related dom event
  6842. */
  6843. event: KeyboardEvent);
  6844. }
  6845. }
  6846. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  6847. import { Nullable } from "babylonjs/types";
  6848. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  6849. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  6850. /**
  6851. * Manage the keyboard inputs to control the movement of a free camera.
  6852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6853. */
  6854. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  6855. /**
  6856. * Defines the camera the input is attached to.
  6857. */
  6858. camera: FreeCamera;
  6859. /**
  6860. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  6861. */
  6862. keysUp: number[];
  6863. /**
  6864. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  6865. */
  6866. keysDown: number[];
  6867. /**
  6868. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  6869. */
  6870. keysLeft: number[];
  6871. /**
  6872. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  6873. */
  6874. keysRight: number[];
  6875. private _keys;
  6876. private _onCanvasBlurObserver;
  6877. private _onKeyboardObserver;
  6878. private _engine;
  6879. private _scene;
  6880. /**
  6881. * Attach the input controls to a specific dom element to get the input from.
  6882. * @param element Defines the element the controls should be listened from
  6883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6884. */
  6885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6886. /**
  6887. * Detach the current controls from the specified dom element.
  6888. * @param element Defines the element to stop listening the inputs from
  6889. */
  6890. detachControl(element: Nullable<HTMLElement>): void;
  6891. /**
  6892. * Update the current camera state depending on the inputs that have been used this frame.
  6893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6894. */
  6895. checkInputs(): void;
  6896. /**
  6897. * Gets the class name of the current intput.
  6898. * @returns the class name
  6899. */
  6900. getClassName(): string;
  6901. /** @hidden */
  6902. _onLostFocus(): void;
  6903. /**
  6904. * Get the friendly name associated with the input class.
  6905. * @returns the input friendly name
  6906. */
  6907. getSimpleName(): string;
  6908. }
  6909. }
  6910. declare module "babylonjs/Culling/boundingSphere" {
  6911. import { DeepImmutable } from "babylonjs/types";
  6912. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6913. /**
  6914. * Class used to store bounding sphere information
  6915. */
  6916. export class BoundingSphere {
  6917. /**
  6918. * Gets the center of the bounding sphere in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Radius of the bounding sphere in local space
  6923. */
  6924. radius: number;
  6925. /**
  6926. * Gets the center of the bounding sphere in world space
  6927. */
  6928. readonly centerWorld: Vector3;
  6929. /**
  6930. * Radius of the bounding sphere in world space
  6931. */
  6932. radiusWorld: number;
  6933. /**
  6934. * Gets the minimum vector in local space
  6935. */
  6936. readonly minimum: Vector3;
  6937. /**
  6938. * Gets the maximum vector in local space
  6939. */
  6940. readonly maximum: Vector3;
  6941. private _worldMatrix;
  6942. private static readonly TmpVector3;
  6943. /**
  6944. * Creates a new bounding sphere
  6945. * @param min defines the minimum vector (in local space)
  6946. * @param max defines the maximum vector (in local space)
  6947. * @param worldMatrix defines the new world matrix
  6948. */
  6949. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6950. /**
  6951. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6952. * @param min defines the new minimum vector (in local space)
  6953. * @param max defines the new maximum vector (in local space)
  6954. * @param worldMatrix defines the new world matrix
  6955. */
  6956. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6957. /**
  6958. * Scale the current bounding sphere by applying a scale factor
  6959. * @param factor defines the scale factor to apply
  6960. * @returns the current bounding box
  6961. */
  6962. scale(factor: number): BoundingSphere;
  6963. /**
  6964. * Gets the world matrix of the bounding box
  6965. * @returns a matrix
  6966. */
  6967. getWorldMatrix(): DeepImmutable<Matrix>;
  6968. /** @hidden */
  6969. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6970. /**
  6971. * Tests if the bounding sphere is intersecting the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an intersection
  6974. */
  6975. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding sphere
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding sphere
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Checks if two sphere intersct
  6984. * @param sphere0 sphere 0
  6985. * @param sphere1 sphere 1
  6986. * @returns true if the speres intersect
  6987. */
  6988. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6989. }
  6990. }
  6991. declare module "babylonjs/Culling/boundingInfo" {
  6992. import { DeepImmutable } from "babylonjs/types";
  6993. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6994. import { Collider } from "babylonjs/Collisions/collider";
  6995. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6996. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6997. /**
  6998. * Interface for cullable objects
  6999. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7000. */
  7001. export interface ICullable {
  7002. /**
  7003. * Checks if the object or part of the object is in the frustum
  7004. * @param frustumPlanes Camera near/planes
  7005. * @returns true if the object is in frustum otherwise false
  7006. */
  7007. isInFrustum(frustumPlanes: Plane[]): boolean;
  7008. /**
  7009. * Checks if a cullable object (mesh...) is in the camera frustum
  7010. * Unlike isInFrustum this cheks the full bounding box
  7011. * @param frustumPlanes Camera near/planes
  7012. * @returns true if the object is in frustum otherwise false
  7013. */
  7014. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7015. }
  7016. /**
  7017. * Info for a bounding data of a mesh
  7018. */
  7019. export class BoundingInfo implements ICullable {
  7020. /**
  7021. * Bounding box for the mesh
  7022. */
  7023. readonly boundingBox: BoundingBox;
  7024. /**
  7025. * Bounding sphere for the mesh
  7026. */
  7027. readonly boundingSphere: BoundingSphere;
  7028. private _isLocked;
  7029. private static readonly TmpVector3;
  7030. /**
  7031. * Constructs bounding info
  7032. * @param minimum min vector of the bounding box/sphere
  7033. * @param maximum max vector of the bounding box/sphere
  7034. * @param worldMatrix defines the new world matrix
  7035. */
  7036. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7037. /**
  7038. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7039. * @param min defines the new minimum vector (in local space)
  7040. * @param max defines the new maximum vector (in local space)
  7041. * @param worldMatrix defines the new world matrix
  7042. */
  7043. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7044. /**
  7045. * min vector of the bounding box/sphere
  7046. */
  7047. readonly minimum: Vector3;
  7048. /**
  7049. * max vector of the bounding box/sphere
  7050. */
  7051. readonly maximum: Vector3;
  7052. /**
  7053. * If the info is locked and won't be updated to avoid perf overhead
  7054. */
  7055. isLocked: boolean;
  7056. /**
  7057. * Updates the bounding sphere and box
  7058. * @param world world matrix to be used to update
  7059. */
  7060. update(world: DeepImmutable<Matrix>): void;
  7061. /**
  7062. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7063. * @param center New center of the bounding info
  7064. * @param extend New extend of the bounding info
  7065. * @returns the current bounding info
  7066. */
  7067. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7068. /**
  7069. * Scale the current bounding info by applying a scale factor
  7070. * @param factor defines the scale factor to apply
  7071. * @returns the current bounding info
  7072. */
  7073. scale(factor: number): BoundingInfo;
  7074. /**
  7075. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7076. * @param frustumPlanes defines the frustum to test
  7077. * @param strategy defines the strategy to use for the culling (default is Scene.CULLINGSTRATEGY_STANDARD)
  7078. * @returns true if the bounding info is in the frustum planes
  7079. */
  7080. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7081. /**
  7082. * Gets the world distance between the min and max points of the bounding box
  7083. */
  7084. readonly diagonalLength: number;
  7085. /**
  7086. * Checks if a cullable object (mesh...) is in the camera frustum
  7087. * Unlike isInFrustum this cheks the full bounding box
  7088. * @param frustumPlanes Camera near/planes
  7089. * @returns true if the object is in frustum otherwise false
  7090. */
  7091. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /** @hidden */
  7093. _checkCollision(collider: Collider): boolean;
  7094. /**
  7095. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7096. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7097. * @param point the point to check intersection with
  7098. * @returns if the point intersects
  7099. */
  7100. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7101. /**
  7102. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7103. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7104. * @param boundingInfo the bounding info to check intersection with
  7105. * @param precise if the intersection should be done using OBB
  7106. * @returns if the bounding info intersects
  7107. */
  7108. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7109. }
  7110. }
  7111. declare module "babylonjs/Culling/boundingBox" {
  7112. import { DeepImmutable } from "babylonjs/types";
  7113. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7114. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7115. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7116. /**
  7117. * Class used to store bounding box information
  7118. */
  7119. export class BoundingBox implements ICullable {
  7120. /**
  7121. * Gets the 8 vectors representing the bounding box in local space
  7122. */
  7123. readonly vectors: Vector3[];
  7124. /**
  7125. * Gets the center of the bounding box in local space
  7126. */
  7127. readonly center: Vector3;
  7128. /**
  7129. * Gets the center of the bounding box in world space
  7130. */
  7131. readonly centerWorld: Vector3;
  7132. /**
  7133. * Gets the extend size in local space
  7134. */
  7135. readonly extendSize: Vector3;
  7136. /**
  7137. * Gets the extend size in world space
  7138. */
  7139. readonly extendSizeWorld: Vector3;
  7140. /**
  7141. * Gets the OBB (object bounding box) directions
  7142. */
  7143. readonly directions: Vector3[];
  7144. /**
  7145. * Gets the 8 vectors representing the bounding box in world space
  7146. */
  7147. readonly vectorsWorld: Vector3[];
  7148. /**
  7149. * Gets the minimum vector in world space
  7150. */
  7151. readonly minimumWorld: Vector3;
  7152. /**
  7153. * Gets the maximum vector in world space
  7154. */
  7155. readonly maximumWorld: Vector3;
  7156. /**
  7157. * Gets the minimum vector in local space
  7158. */
  7159. readonly minimum: Vector3;
  7160. /**
  7161. * Gets the maximum vector in local space
  7162. */
  7163. readonly maximum: Vector3;
  7164. private _worldMatrix;
  7165. private static readonly TmpVector3;
  7166. /**
  7167. * @hidden
  7168. */
  7169. _tag: number;
  7170. /**
  7171. * Creates a new bounding box
  7172. * @param min defines the minimum vector (in local space)
  7173. * @param max defines the maximum vector (in local space)
  7174. * @param worldMatrix defines the new world matrix
  7175. */
  7176. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7177. /**
  7178. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7179. * @param min defines the new minimum vector (in local space)
  7180. * @param max defines the new maximum vector (in local space)
  7181. * @param worldMatrix defines the new world matrix
  7182. */
  7183. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7184. /**
  7185. * Scale the current bounding box by applying a scale factor
  7186. * @param factor defines the scale factor to apply
  7187. * @returns the current bounding box
  7188. */
  7189. scale(factor: number): BoundingBox;
  7190. /**
  7191. * Gets the world matrix of the bounding box
  7192. * @returns a matrix
  7193. */
  7194. getWorldMatrix(): DeepImmutable<Matrix>;
  7195. /** @hidden */
  7196. _update(world: DeepImmutable<Matrix>): void;
  7197. /**
  7198. * Tests if the bounding box is intersecting the frustum planes
  7199. * @param frustumPlanes defines the frustum planes to test
  7200. * @returns true if there is an intersection
  7201. */
  7202. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7203. /**
  7204. * Tests if the bounding box is entirely inside the frustum planes
  7205. * @param frustumPlanes defines the frustum planes to test
  7206. * @returns true if there is an inclusion
  7207. */
  7208. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7209. /**
  7210. * Tests if a point is inside the bounding box
  7211. * @param point defines the point to test
  7212. * @returns true if the point is inside the bounding box
  7213. */
  7214. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7215. /**
  7216. * Tests if the bounding box intersects with a bounding sphere
  7217. * @param sphere defines the sphere to test
  7218. * @returns true if there is an intersection
  7219. */
  7220. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7221. /**
  7222. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7223. * @param min defines the min vector to use
  7224. * @param max defines the max vector to use
  7225. * @returns true if there is an intersection
  7226. */
  7227. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7228. /**
  7229. * Tests if two bounding boxes are intersections
  7230. * @param box0 defines the first box to test
  7231. * @param box1 defines the second box to test
  7232. * @returns true if there is an intersection
  7233. */
  7234. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7235. /**
  7236. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7237. * @param minPoint defines the minimum vector of the bounding box
  7238. * @param maxPoint defines the maximum vector of the bounding box
  7239. * @param sphereCenter defines the sphere center
  7240. * @param sphereRadius defines the sphere radius
  7241. * @returns true if there is an intersection
  7242. */
  7243. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7244. /**
  7245. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7246. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7247. * @param frustumPlanes defines the frustum planes to test
  7248. * @return true if there is an inclusion
  7249. */
  7250. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7251. /**
  7252. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7253. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7254. * @param frustumPlanes defines the frustum planes to test
  7255. * @return true if there is an intersection
  7256. */
  7257. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7258. }
  7259. }
  7260. declare module "babylonjs/Culling/ray" {
  7261. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  7262. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7264. import { PickingInfo, IntersectionInfo } from "babylonjs/Collisions/pickingInfo";
  7265. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7266. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7267. /**
  7268. * Class representing a ray with position and direction
  7269. */
  7270. export class Ray {
  7271. /** origin point */
  7272. origin: Vector3;
  7273. /** direction */
  7274. direction: Vector3;
  7275. /** length of the ray */
  7276. length: number;
  7277. private static readonly TmpVector3;
  7278. private _tmpRay;
  7279. /**
  7280. * Creates a new ray
  7281. * @param origin origin point
  7282. * @param direction direction
  7283. * @param length length of the ray
  7284. */
  7285. constructor(
  7286. /** origin point */
  7287. origin: Vector3,
  7288. /** direction */
  7289. direction: Vector3,
  7290. /** length of the ray */
  7291. length?: number);
  7292. /**
  7293. * Checks if the ray intersects a box
  7294. * @param minimum bound of the box
  7295. * @param maximum bound of the box
  7296. * @param intersectionTreshold extra extend to be added to the box in all direction
  7297. * @returns if the box was hit
  7298. */
  7299. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7300. /**
  7301. * Checks if the ray intersects a box
  7302. * @param box the bounding box to check
  7303. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7304. * @returns if the box was hit
  7305. */
  7306. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7307. /**
  7308. * If the ray hits a sphere
  7309. * @param sphere the bounding sphere to check
  7310. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7311. * @returns true if it hits the sphere
  7312. */
  7313. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7314. /**
  7315. * If the ray hits a triange
  7316. * @param vertex0 triangle vertex
  7317. * @param vertex1 triangle vertex
  7318. * @param vertex2 triangle vertex
  7319. * @returns intersection information if hit
  7320. */
  7321. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7322. /**
  7323. * Checks if ray intersects a plane
  7324. * @param plane the plane to check
  7325. * @returns the distance away it was hit
  7326. */
  7327. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7328. /**
  7329. * Checks if ray intersects a mesh
  7330. * @param mesh the mesh to check
  7331. * @param fastCheck if only the bounding box should checked
  7332. * @returns picking info of the intersecton
  7333. */
  7334. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7335. /**
  7336. * Checks if ray intersects a mesh
  7337. * @param meshes the meshes to check
  7338. * @param fastCheck if only the bounding box should checked
  7339. * @param results array to store result in
  7340. * @returns Array of picking infos
  7341. */
  7342. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7343. private _comparePickingInfo;
  7344. private static smallnum;
  7345. private static rayl;
  7346. /**
  7347. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7348. * @param sega the first point of the segment to test the intersection against
  7349. * @param segb the second point of the segment to test the intersection against
  7350. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7351. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7352. */
  7353. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7354. /**
  7355. * Update the ray from viewport position
  7356. * @param x position
  7357. * @param y y position
  7358. * @param viewportWidth viewport width
  7359. * @param viewportHeight viewport height
  7360. * @param world world matrix
  7361. * @param view view matrix
  7362. * @param projection projection matrix
  7363. * @returns this ray updated
  7364. */
  7365. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7366. /**
  7367. * Creates a ray with origin and direction of 0,0,0
  7368. * @returns the new ray
  7369. */
  7370. static Zero(): Ray;
  7371. /**
  7372. * Creates a new ray from screen space and viewport
  7373. * @param x position
  7374. * @param y y position
  7375. * @param viewportWidth viewport width
  7376. * @param viewportHeight viewport height
  7377. * @param world world matrix
  7378. * @param view view matrix
  7379. * @param projection projection matrix
  7380. * @returns new ray
  7381. */
  7382. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7383. /**
  7384. * 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
  7385. * transformed to the given world matrix.
  7386. * @param origin The origin point
  7387. * @param end The end point
  7388. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7389. * @returns the new ray
  7390. */
  7391. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7392. /**
  7393. * Transforms a ray by a matrix
  7394. * @param ray ray to transform
  7395. * @param matrix matrix to apply
  7396. * @returns the resulting new ray
  7397. */
  7398. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7399. /**
  7400. * Transforms a ray by a matrix
  7401. * @param ray ray to transform
  7402. * @param matrix matrix to apply
  7403. * @param result ray to store result in
  7404. */
  7405. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7406. /**
  7407. * Unproject a ray from screen space to object space
  7408. * @param sourceX defines the screen space x coordinate to use
  7409. * @param sourceY defines the screen space y coordinate to use
  7410. * @param viewportWidth defines the current width of the viewport
  7411. * @param viewportHeight defines the current height of the viewport
  7412. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  7413. * @param view defines the view matrix to use
  7414. * @param projection defines the projection matrix to use
  7415. */
  7416. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  7417. }
  7418. }
  7419. declare module "babylonjs/Actions/actionEvent" {
  7420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7421. import { Nullable } from "babylonjs/types";
  7422. import { Sprite } from "babylonjs/Sprites/sprite";
  7423. import { Scene } from "babylonjs/scene";
  7424. import { Vector2 } from "babylonjs/Maths/math";
  7425. /**
  7426. * ActionEvent is the event being sent when an action is triggered.
  7427. */
  7428. export class ActionEvent {
  7429. /** The mesh or sprite that triggered the action */
  7430. source: any;
  7431. /** The X mouse cursor position at the time of the event */
  7432. pointerX: number;
  7433. /** The Y mouse cursor position at the time of the event */
  7434. pointerY: number;
  7435. /** The mesh that is currently pointed at (can be null) */
  7436. meshUnderPointer: Nullable<AbstractMesh>;
  7437. /** the original (browser) event that triggered the ActionEvent */
  7438. sourceEvent?: any;
  7439. /** additional data for the event */
  7440. additionalData?: any;
  7441. /**
  7442. * Creates a new ActionEvent
  7443. * @param source The mesh or sprite that triggered the action
  7444. * @param pointerX The X mouse cursor position at the time of the event
  7445. * @param pointerY The Y mouse cursor position at the time of the event
  7446. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7447. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7448. * @param additionalData additional data for the event
  7449. */
  7450. constructor(
  7451. /** The mesh or sprite that triggered the action */
  7452. source: any,
  7453. /** The X mouse cursor position at the time of the event */
  7454. pointerX: number,
  7455. /** The Y mouse cursor position at the time of the event */
  7456. pointerY: number,
  7457. /** The mesh that is currently pointed at (can be null) */
  7458. meshUnderPointer: Nullable<AbstractMesh>,
  7459. /** the original (browser) event that triggered the ActionEvent */
  7460. sourceEvent?: any,
  7461. /** additional data for the event */
  7462. additionalData?: any);
  7463. /**
  7464. * Helper function to auto-create an ActionEvent from a source mesh.
  7465. * @param source The source mesh that triggered the event
  7466. * @param evt The original (browser) event
  7467. * @param additionalData additional data for the event
  7468. * @returns the new ActionEvent
  7469. */
  7470. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7471. /**
  7472. * Helper function to auto-create an ActionEvent from a source sprite
  7473. * @param source The source sprite that triggered the event
  7474. * @param scene Scene associated with the sprite
  7475. * @param evt The original (browser) event
  7476. * @param additionalData additional data for the event
  7477. * @returns the new ActionEvent
  7478. */
  7479. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7480. /**
  7481. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7482. * @param scene the scene where the event occurred
  7483. * @param evt The original (browser) event
  7484. * @returns the new ActionEvent
  7485. */
  7486. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7487. /**
  7488. * Helper function to auto-create an ActionEvent from a primitive
  7489. * @param prim defines the target primitive
  7490. * @param pointerPos defines the pointer position
  7491. * @param evt The original (browser) event
  7492. * @param additionalData additional data for the event
  7493. * @returns the new ActionEvent
  7494. */
  7495. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7496. }
  7497. }
  7498. declare module "babylonjs/Lights/shadowLight" {
  7499. import { Camera } from "babylonjs/Cameras/camera";
  7500. import { Scene } from "babylonjs/scene";
  7501. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7503. import { Light } from "babylonjs/Lights/light";
  7504. /**
  7505. * Interface describing all the common properties and methods a shadow light needs to implement.
  7506. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7507. * as well as binding the different shadow properties to the effects.
  7508. */
  7509. export interface IShadowLight extends Light {
  7510. /**
  7511. * The light id in the scene (used in scene.findLighById for instance)
  7512. */
  7513. id: string;
  7514. /**
  7515. * The position the shdow will be casted from.
  7516. */
  7517. position: Vector3;
  7518. /**
  7519. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7520. */
  7521. direction: Vector3;
  7522. /**
  7523. * The transformed position. Position of the light in world space taking parenting in account.
  7524. */
  7525. transformedPosition: Vector3;
  7526. /**
  7527. * The transformed direction. Direction of the light in world space taking parenting in account.
  7528. */
  7529. transformedDirection: Vector3;
  7530. /**
  7531. * The friendly name of the light in the scene.
  7532. */
  7533. name: string;
  7534. /**
  7535. * Defines the shadow projection clipping minimum z value.
  7536. */
  7537. shadowMinZ: number;
  7538. /**
  7539. * Defines the shadow projection clipping maximum z value.
  7540. */
  7541. shadowMaxZ: number;
  7542. /**
  7543. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7544. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7545. */
  7546. computeTransformedInformation(): boolean;
  7547. /**
  7548. * Gets the scene the light belongs to.
  7549. * @returns The scene
  7550. */
  7551. getScene(): Scene;
  7552. /**
  7553. * Callback defining a custom Projection Matrix Builder.
  7554. * This can be used to override the default projection matrix computation.
  7555. */
  7556. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7557. /**
  7558. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7559. * @param matrix The materix to updated with the projection information
  7560. * @param viewMatrix The transform matrix of the light
  7561. * @param renderList The list of mesh to render in the map
  7562. * @returns The current light
  7563. */
  7564. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7565. /**
  7566. * Gets the current depth scale used in ESM.
  7567. * @returns The scale
  7568. */
  7569. getDepthScale(): number;
  7570. /**
  7571. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7572. * @returns true if a cube texture needs to be use
  7573. */
  7574. needCube(): boolean;
  7575. /**
  7576. * Detects if the projection matrix requires to be recomputed this frame.
  7577. * @returns true if it requires to be recomputed otherwise, false.
  7578. */
  7579. needProjectionMatrixCompute(): boolean;
  7580. /**
  7581. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7582. */
  7583. forceProjectionMatrixCompute(): void;
  7584. /**
  7585. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7586. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7587. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7588. */
  7589. getShadowDirection(faceIndex?: number): Vector3;
  7590. /**
  7591. * Gets the minZ used for shadow according to both the scene and the light.
  7592. * @param activeCamera The camera we are returning the min for
  7593. * @returns the depth min z
  7594. */
  7595. getDepthMinZ(activeCamera: Camera): number;
  7596. /**
  7597. * Gets the maxZ used for shadow according to both the scene and the light.
  7598. * @param activeCamera The camera we are returning the max for
  7599. * @returns the depth max z
  7600. */
  7601. getDepthMaxZ(activeCamera: Camera): number;
  7602. }
  7603. /**
  7604. * Base implementation IShadowLight
  7605. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7606. */
  7607. export abstract class ShadowLight extends Light implements IShadowLight {
  7608. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7609. protected _position: Vector3;
  7610. protected _setPosition(value: Vector3): void;
  7611. /**
  7612. * Sets the position the shadow will be casted from. Also use as the light position for both
  7613. * point and spot lights.
  7614. */
  7615. /**
  7616. * Sets the position the shadow will be casted from. Also use as the light position for both
  7617. * point and spot lights.
  7618. */
  7619. position: Vector3;
  7620. protected _direction: Vector3;
  7621. protected _setDirection(value: Vector3): void;
  7622. /**
  7623. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7624. * Also use as the light direction on spot and directional lights.
  7625. */
  7626. /**
  7627. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7628. * Also use as the light direction on spot and directional lights.
  7629. */
  7630. direction: Vector3;
  7631. private _shadowMinZ;
  7632. /**
  7633. * Gets the shadow projection clipping minimum z value.
  7634. */
  7635. /**
  7636. * Sets the shadow projection clipping minimum z value.
  7637. */
  7638. shadowMinZ: number;
  7639. private _shadowMaxZ;
  7640. /**
  7641. * Sets the shadow projection clipping maximum z value.
  7642. */
  7643. /**
  7644. * Gets the shadow projection clipping maximum z value.
  7645. */
  7646. shadowMaxZ: number;
  7647. /**
  7648. * Callback defining a custom Projection Matrix Builder.
  7649. * This can be used to override the default projection matrix computation.
  7650. */
  7651. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7652. /**
  7653. * The transformed position. Position of the light in world space taking parenting in account.
  7654. */
  7655. transformedPosition: Vector3;
  7656. /**
  7657. * The transformed direction. Direction of the light in world space taking parenting in account.
  7658. */
  7659. transformedDirection: Vector3;
  7660. private _needProjectionMatrixCompute;
  7661. /**
  7662. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7663. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7664. */
  7665. computeTransformedInformation(): boolean;
  7666. /**
  7667. * Return the depth scale used for the shadow map.
  7668. * @returns the depth scale.
  7669. */
  7670. getDepthScale(): number;
  7671. /**
  7672. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7673. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7674. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7675. */
  7676. getShadowDirection(faceIndex?: number): Vector3;
  7677. /**
  7678. * Returns the ShadowLight absolute position in the World.
  7679. * @returns the position vector in world space
  7680. */
  7681. getAbsolutePosition(): Vector3;
  7682. /**
  7683. * Sets the ShadowLight direction toward the passed target.
  7684. * @param target The point tot target in local space
  7685. * @returns the updated ShadowLight direction
  7686. */
  7687. setDirectionToTarget(target: Vector3): Vector3;
  7688. /**
  7689. * Returns the light rotation in euler definition.
  7690. * @returns the x y z rotation in local space.
  7691. */
  7692. getRotation(): Vector3;
  7693. /**
  7694. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7695. * @returns true if a cube texture needs to be use
  7696. */
  7697. needCube(): boolean;
  7698. /**
  7699. * Detects if the projection matrix requires to be recomputed this frame.
  7700. * @returns true if it requires to be recomputed otherwise, false.
  7701. */
  7702. needProjectionMatrixCompute(): boolean;
  7703. /**
  7704. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7705. */
  7706. forceProjectionMatrixCompute(): void;
  7707. /** @hidden */
  7708. _initCache(): void;
  7709. /** @hidden */
  7710. _isSynchronized(): boolean;
  7711. /**
  7712. * Computes the world matrix of the node
  7713. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7714. * @returns the world matrix
  7715. */
  7716. computeWorldMatrix(force?: boolean): Matrix;
  7717. /**
  7718. * Gets the minZ used for shadow according to both the scene and the light.
  7719. * @param activeCamera The camera we are returning the min for
  7720. * @returns the depth min z
  7721. */
  7722. getDepthMinZ(activeCamera: Camera): number;
  7723. /**
  7724. * Gets the maxZ used for shadow according to both the scene and the light.
  7725. * @param activeCamera The camera we are returning the max for
  7726. * @returns the depth max z
  7727. */
  7728. getDepthMaxZ(activeCamera: Camera): number;
  7729. /**
  7730. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7731. * @param matrix The materix to updated with the projection information
  7732. * @param viewMatrix The transform matrix of the light
  7733. * @param renderList The list of mesh to render in the map
  7734. * @returns The current light
  7735. */
  7736. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7737. }
  7738. }
  7739. declare module "babylonjs/sceneComponent" {
  7740. import { Scene } from "babylonjs/scene";
  7741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  7743. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  7744. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  7745. import { Nullable } from "babylonjs/types";
  7746. import { Camera } from "babylonjs/Cameras/camera";
  7747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  7748. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  7749. import { AbstractScene } from "babylonjs/abstractScene";
  7750. /**
  7751. * Groups all the scene component constants in one place to ease maintenance.
  7752. * @hidden
  7753. */
  7754. export class SceneComponentConstants {
  7755. static readonly NAME_EFFECTLAYER: string;
  7756. static readonly NAME_LAYER: string;
  7757. static readonly NAME_LENSFLARESYSTEM: string;
  7758. static readonly NAME_BOUNDINGBOXRENDERER: string;
  7759. static readonly NAME_PARTICLESYSTEM: string;
  7760. static readonly NAME_GAMEPAD: string;
  7761. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  7762. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  7763. static readonly NAME_DEPTHRENDERER: string;
  7764. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  7765. static readonly NAME_SPRITE: string;
  7766. static readonly NAME_OUTLINERENDERER: string;
  7767. static readonly NAME_PROCEDURALTEXTURE: string;
  7768. static readonly NAME_SHADOWGENERATOR: string;
  7769. static readonly NAME_OCTREE: string;
  7770. static readonly NAME_PHYSICSENGINE: string;
  7771. static readonly NAME_AUDIO: string;
  7772. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  7773. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  7774. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  7775. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  7776. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  7777. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  7778. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  7779. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  7780. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  7781. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  7782. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  7783. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  7784. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  7785. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  7786. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  7787. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  7788. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  7789. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  7790. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  7791. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  7792. static readonly STEP_AFTERRENDER_AUDIO: number;
  7793. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  7794. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  7795. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  7796. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  7797. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  7798. static readonly STEP_POINTERMOVE_SPRITE: number;
  7799. static readonly STEP_POINTERDOWN_SPRITE: number;
  7800. static readonly STEP_POINTERUP_SPRITE: number;
  7801. }
  7802. /**
  7803. * This represents a scene component.
  7804. *
  7805. * This is used to decouple the dependency the scene is having on the different workloads like
  7806. * layers, post processes...
  7807. */
  7808. export interface ISceneComponent {
  7809. /**
  7810. * The name of the component. Each component must have a unique name.
  7811. */
  7812. name: string;
  7813. /**
  7814. * The scene the component belongs to.
  7815. */
  7816. scene: Scene;
  7817. /**
  7818. * Register the component to one instance of a scene.
  7819. */
  7820. register(): void;
  7821. /**
  7822. * Rebuilds the elements related to this component in case of
  7823. * context lost for instance.
  7824. */
  7825. rebuild(): void;
  7826. /**
  7827. * Disposes the component and the associated ressources.
  7828. */
  7829. dispose(): void;
  7830. }
  7831. /**
  7832. * This represents a SERIALIZABLE scene component.
  7833. *
  7834. * This extends Scene Component to add Serialization methods on top.
  7835. */
  7836. export interface ISceneSerializableComponent extends ISceneComponent {
  7837. /**
  7838. * Adds all the element from the container to the scene
  7839. * @param container the container holding the elements
  7840. */
  7841. addFromContainer(container: AbstractScene): void;
  7842. /**
  7843. * Removes all the elements in the container from the scene
  7844. * @param container contains the elements to remove
  7845. */
  7846. removeFromContainer(container: AbstractScene): void;
  7847. /**
  7848. * Serializes the component data to the specified json object
  7849. * @param serializationObject The object to serialize to
  7850. */
  7851. serialize(serializationObject: any): void;
  7852. }
  7853. /**
  7854. * Strong typing of a Mesh related stage step action
  7855. */
  7856. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  7857. /**
  7858. * Strong typing of a Evaluate Sub Mesh related stage step action
  7859. */
  7860. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  7861. /**
  7862. * Strong typing of a Active Mesh related stage step action
  7863. */
  7864. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  7865. /**
  7866. * Strong typing of a Camera related stage step action
  7867. */
  7868. export type CameraStageAction = (camera: Camera) => void;
  7869. /**
  7870. * Strong typing of a Render Target related stage step action
  7871. */
  7872. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  7873. /**
  7874. * Strong typing of a RenderingGroup related stage step action
  7875. */
  7876. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  7877. /**
  7878. * Strong typing of a Mesh Render related stage step action
  7879. */
  7880. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  7881. /**
  7882. * Strong typing of a simple stage step action
  7883. */
  7884. export type SimpleStageAction = () => void;
  7885. /**
  7886. * Strong typing of a render target action.
  7887. */
  7888. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  7889. /**
  7890. * Strong typing of a pointer move action.
  7891. */
  7892. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  7893. /**
  7894. * Strong typing of a pointer up/down action.
  7895. */
  7896. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  7897. /**
  7898. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  7899. * @hidden
  7900. */
  7901. export class Stage<T extends Function> extends Array<{
  7902. index: number;
  7903. component: ISceneComponent;
  7904. action: T;
  7905. }> {
  7906. /**
  7907. * Hide ctor from the rest of the world.
  7908. * @param items The items to add.
  7909. */
  7910. private constructor();
  7911. /**
  7912. * Creates a new Stage.
  7913. * @returns A new instance of a Stage
  7914. */
  7915. static Create<T extends Function>(): Stage<T>;
  7916. /**
  7917. * Registers a step in an ordered way in the targeted stage.
  7918. * @param index Defines the position to register the step in
  7919. * @param component Defines the component attached to the step
  7920. * @param action Defines the action to launch during the step
  7921. */
  7922. registerStep(index: number, component: ISceneComponent, action: T): void;
  7923. /**
  7924. * Clears all the steps from the stage.
  7925. */
  7926. clear(): void;
  7927. }
  7928. }
  7929. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  7930. import { Scene } from "babylonjs/scene";
  7931. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  7932. import { AbstractScene } from "babylonjs/abstractScene";
  7933. /**
  7934. * Defines the shadow generator component responsible to manage any shadow generators
  7935. * in a given scene.
  7936. */
  7937. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  7938. /**
  7939. * The component name helpfull to identify the component in the list of scene components.
  7940. */
  7941. readonly name: string;
  7942. /**
  7943. * The scene the component belongs to.
  7944. */
  7945. scene: Scene;
  7946. /**
  7947. * Creates a new instance of the component for the given scene
  7948. * @param scene Defines the scene to register the component in
  7949. */
  7950. constructor(scene: Scene);
  7951. /**
  7952. * Registers the component in a given scene
  7953. */
  7954. register(): void;
  7955. /**
  7956. * Rebuilds the elements related to this component in case of
  7957. * context lost for instance.
  7958. */
  7959. rebuild(): void;
  7960. /**
  7961. * Serializes the component data to the specified json object
  7962. * @param serializationObject The object to serialize to
  7963. */
  7964. serialize(serializationObject: any): void;
  7965. /**
  7966. * Adds all the element from the container to the scene
  7967. * @param container the container holding the elements
  7968. */
  7969. addFromContainer(container: AbstractScene): void;
  7970. /**
  7971. * Removes all the elements in the container from the scene
  7972. * @param container contains the elements to remove
  7973. */
  7974. removeFromContainer(container: AbstractScene): void;
  7975. /**
  7976. * Rebuilds the elements related to this component in case of
  7977. * context lost for instance.
  7978. */
  7979. dispose(): void;
  7980. private _gatherRenderTargets;
  7981. }
  7982. }
  7983. declare module "babylonjs/Materials/materialDefines" {
  7984. /**
  7985. * Manages the defines for the Material
  7986. */
  7987. export class MaterialDefines {
  7988. private _keys;
  7989. private _isDirty;
  7990. /** @hidden */
  7991. _renderId: number;
  7992. /** @hidden */
  7993. _areLightsDirty: boolean;
  7994. /** @hidden */
  7995. _areAttributesDirty: boolean;
  7996. /** @hidden */
  7997. _areTexturesDirty: boolean;
  7998. /** @hidden */
  7999. _areFresnelDirty: boolean;
  8000. /** @hidden */
  8001. _areMiscDirty: boolean;
  8002. /** @hidden */
  8003. _areImageProcessingDirty: boolean;
  8004. /** @hidden */
  8005. _normals: boolean;
  8006. /** @hidden */
  8007. _uvs: boolean;
  8008. /** @hidden */
  8009. _needNormals: boolean;
  8010. /** @hidden */
  8011. _needUVs: boolean;
  8012. /**
  8013. * Specifies if the material needs to be re-calculated
  8014. */
  8015. readonly isDirty: boolean;
  8016. /**
  8017. * Marks the material to indicate that it has been re-calculated
  8018. */
  8019. markAsProcessed(): void;
  8020. /**
  8021. * Marks the material to indicate that it needs to be re-calculated
  8022. */
  8023. markAsUnprocessed(): void;
  8024. /**
  8025. * Marks the material to indicate all of its defines need to be re-calculated
  8026. */
  8027. markAllAsDirty(): void;
  8028. /**
  8029. * Marks the material to indicate that image processing needs to be re-calculated
  8030. */
  8031. markAsImageProcessingDirty(): void;
  8032. /**
  8033. * Marks the material to indicate the lights need to be re-calculated
  8034. */
  8035. markAsLightDirty(): void;
  8036. /**
  8037. * Marks the attribute state as changed
  8038. */
  8039. markAsAttributesDirty(): void;
  8040. /**
  8041. * Marks the texture state as changed
  8042. */
  8043. markAsTexturesDirty(): void;
  8044. /**
  8045. * Marks the fresnel state as changed
  8046. */
  8047. markAsFresnelDirty(): void;
  8048. /**
  8049. * Marks the misc state as changed
  8050. */
  8051. markAsMiscDirty(): void;
  8052. /**
  8053. * Rebuilds the material defines
  8054. */
  8055. rebuild(): void;
  8056. /**
  8057. * Specifies if two material defines are equal
  8058. * @param other - A material define instance to compare to
  8059. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8060. */
  8061. isEqual(other: MaterialDefines): boolean;
  8062. /**
  8063. * Clones this instance's defines to another instance
  8064. * @param other - material defines to clone values to
  8065. */
  8066. cloneTo(other: MaterialDefines): void;
  8067. /**
  8068. * Resets the material define values
  8069. */
  8070. reset(): void;
  8071. /**
  8072. * Converts the material define values to a string
  8073. * @returns - String of material define information
  8074. */
  8075. toString(): string;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/materialHelper" {
  8079. import { Nullable } from "babylonjs/types";
  8080. import { Scene } from "babylonjs/scene";
  8081. import { Engine } from "babylonjs/Engines/engine";
  8082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8083. import { Light } from "babylonjs/Lights/light";
  8084. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8085. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8087. /**
  8088. * "Static Class" containing the most commonly used helper while dealing with material for
  8089. * rendering purpose.
  8090. *
  8091. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8092. *
  8093. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8094. */
  8095. export class MaterialHelper {
  8096. /**
  8097. * Bind the current view position to an effect.
  8098. * @param effect The effect to be bound
  8099. * @param scene The scene the eyes position is used from
  8100. */
  8101. static BindEyePosition(effect: Effect, scene: Scene): void;
  8102. /**
  8103. * Helps preparing the defines values about the UVs in used in the effect.
  8104. * UVs are shared as much as we can accross channels in the shaders.
  8105. * @param texture The texture we are preparing the UVs for
  8106. * @param defines The defines to update
  8107. * @param key The channel key "diffuse", "specular"... used in the shader
  8108. */
  8109. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8110. /**
  8111. * Binds a texture matrix value to its corrsponding uniform
  8112. * @param texture The texture to bind the matrix for
  8113. * @param uniformBuffer The uniform buffer receivin the data
  8114. * @param key The channel key "diffuse", "specular"... used in the shader
  8115. */
  8116. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8117. /**
  8118. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8119. * @param mesh defines the current mesh
  8120. * @param scene defines the current scene
  8121. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8122. * @param pointsCloud defines if point cloud rendering has to be turned on
  8123. * @param fogEnabled defines if fog has to be turned on
  8124. * @param alphaTest defines if alpha testing has to be turned on
  8125. * @param defines defines the current list of defines
  8126. */
  8127. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8128. /**
  8129. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8130. * @param scene defines the current scene
  8131. * @param engine defines the current engine
  8132. * @param defines specifies the list of active defines
  8133. * @param useInstances defines if instances have to be turned on
  8134. * @param useClipPlane defines if clip plane have to be turned on
  8135. */
  8136. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8137. /**
  8138. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8139. * @param mesh The mesh containing the geometry data we will draw
  8140. * @param defines The defines to update
  8141. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8142. * @param useBones Precise whether bones should be used or not (override mesh info)
  8143. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8144. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8145. * @returns false if defines are considered not dirty and have not been checked
  8146. */
  8147. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8148. /**
  8149. * Prepares the defines related to the light information passed in parameter
  8150. * @param scene The scene we are intending to draw
  8151. * @param mesh The mesh the effect is compiling for
  8152. * @param defines The defines to update
  8153. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8154. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8155. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8156. * @returns true if normals will be required for the rest of the effect
  8157. */
  8158. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8159. /**
  8160. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  8161. * that won t be acctive due to defines being turned off.
  8162. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8163. * @param samplersList The samplers list
  8164. * @param defines The defines helping in the list generation
  8165. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8166. */
  8167. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8168. /**
  8169. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8170. * @param defines The defines to update while falling back
  8171. * @param fallbacks The authorized effect fallbacks
  8172. * @param maxSimultaneousLights The maximum number of lights allowed
  8173. * @param rank the current rank of the Effect
  8174. * @returns The newly affected rank
  8175. */
  8176. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8177. /**
  8178. * Prepares the list of attributes required for morph targets according to the effect defines.
  8179. * @param attribs The current list of supported attribs
  8180. * @param mesh The mesh to prepare the morph targets attributes for
  8181. * @param defines The current Defines of the effect
  8182. */
  8183. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8184. /**
  8185. * Prepares the list of attributes required for bones according to the effect defines.
  8186. * @param attribs The current list of supported attribs
  8187. * @param mesh The mesh to prepare the bones attributes for
  8188. * @param defines The current Defines of the effect
  8189. * @param fallbacks The current efffect fallback strategy
  8190. */
  8191. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8192. /**
  8193. * Prepares the list of attributes required for instances according to the effect defines.
  8194. * @param attribs The current list of supported attribs
  8195. * @param defines The current Defines of the effect
  8196. */
  8197. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  8198. /**
  8199. * Binds the light shadow information to the effect for the given mesh.
  8200. * @param light The light containing the generator
  8201. * @param scene The scene the lights belongs to
  8202. * @param mesh The mesh we are binding the information to render
  8203. * @param lightIndex The light index in the effect used to render the mesh
  8204. * @param effect The effect we are binding the data to
  8205. */
  8206. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8207. /**
  8208. * Binds the light information to the effect.
  8209. * @param light The light containing the generator
  8210. * @param effect The effect we are binding the data to
  8211. * @param lightIndex The light index in the effect used to render
  8212. */
  8213. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8214. /**
  8215. * Binds the lights information from the scene to the effect for the given mesh.
  8216. * @param scene The scene the lights belongs to
  8217. * @param mesh The mesh we are binding the information to render
  8218. * @param effect The effect we are binding the data to
  8219. * @param defines The generated defines for the effect
  8220. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8221. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8222. */
  8223. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8224. private static _tempFogColor;
  8225. /**
  8226. * Binds the fog information from the scene to the effect for the given mesh.
  8227. * @param scene The scene the lights belongs to
  8228. * @param mesh The mesh we are binding the information to render
  8229. * @param effect The effect we are binding the data to
  8230. * @param linearSpace Defines if the fog effect is applied in linear space
  8231. */
  8232. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8233. /**
  8234. * Binds the bones information from the mesh to the effect.
  8235. * @param mesh The mesh we are binding the information to render
  8236. * @param effect The effect we are binding the data to
  8237. */
  8238. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8239. /**
  8240. * Binds the morph targets information from the mesh to the effect.
  8241. * @param abstractMesh The mesh we are binding the information to render
  8242. * @param effect The effect we are binding the data to
  8243. */
  8244. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8245. /**
  8246. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8247. * @param defines The generated defines used in the effect
  8248. * @param effect The effect we are binding the data to
  8249. * @param scene The scene we are willing to render with logarithmic scale for
  8250. */
  8251. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8252. /**
  8253. * Binds the clip plane information from the scene to the effect.
  8254. * @param scene The scene the clip plane information are extracted from
  8255. * @param effect The effect we are binding the data to
  8256. */
  8257. static BindClipPlane(effect: Effect, scene: Scene): void;
  8258. }
  8259. }
  8260. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  8261. export var kernelBlurVaryingDeclaration: {
  8262. name: string;
  8263. shader: string;
  8264. };
  8265. }
  8266. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  8267. export var kernelBlurFragment: {
  8268. name: string;
  8269. shader: string;
  8270. };
  8271. }
  8272. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  8273. export var kernelBlurFragment2: {
  8274. name: string;
  8275. shader: string;
  8276. };
  8277. }
  8278. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  8279. import "Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  8280. import "Shaders/ShadersInclude/kernelBlurFragment";
  8281. import "Shaders/ShadersInclude/kernelBlurFragment2";
  8282. export var kernelBlurPixelShader: {
  8283. name: string;
  8284. shader: string;
  8285. };
  8286. }
  8287. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  8288. export var kernelBlurVertex: {
  8289. name: string;
  8290. shader: string;
  8291. };
  8292. }
  8293. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  8294. import "Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  8295. import "Shaders/ShadersInclude/kernelBlurVertex";
  8296. export var kernelBlurVertexShader: {
  8297. name: string;
  8298. shader: string;
  8299. };
  8300. }
  8301. declare module "babylonjs/PostProcesses/blurPostProcess" {
  8302. import { Vector2 } from "babylonjs/Maths/math";
  8303. import { Nullable } from "babylonjs/types";
  8304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  8305. import { Camera } from "babylonjs/Cameras/camera";
  8306. import { Effect } from "babylonjs/Materials/effect";
  8307. import { Engine } from "babylonjs/Engines/engine";
  8308. import "Shaders/kernelBlur.fragment";
  8309. import "Shaders/kernelBlur.vertex";
  8310. /**
  8311. * The Blur Post Process which blurs an image based on a kernel and direction.
  8312. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  8313. */
  8314. export class BlurPostProcess extends PostProcess {
  8315. /** The direction in which to blur the image. */
  8316. direction: Vector2;
  8317. private blockCompilation;
  8318. protected _kernel: number;
  8319. protected _idealKernel: number;
  8320. protected _packedFloat: boolean;
  8321. private _staticDefines;
  8322. /**
  8323. * Sets the length in pixels of the blur sample region
  8324. */
  8325. /**
  8326. * Gets the length in pixels of the blur sample region
  8327. */
  8328. kernel: number;
  8329. /**
  8330. * Sets wether or not the blur needs to unpack/repack floats
  8331. */
  8332. /**
  8333. * Gets wether or not the blur is unpacking/repacking floats
  8334. */
  8335. packedFloat: boolean;
  8336. /**
  8337. * Creates a new instance BlurPostProcess
  8338. * @param name The name of the effect.
  8339. * @param direction The direction in which to blur the image.
  8340. * @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.
  8341. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  8342. * @param camera The camera to apply the render pass to.
  8343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  8344. * @param engine The engine which the post process will be applied. (default: current engine)
  8345. * @param reusable If the post process can be reused on the same frame. (default: false)
  8346. * @param textureType Type of textures used when performing the post process. (default: 0)
  8347. * @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)
  8348. */
  8349. constructor(name: string,
  8350. /** The direction in which to blur the image. */
  8351. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  8352. /**
  8353. * Updates the effect with the current post process compile time values and recompiles the shader.
  8354. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  8355. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  8356. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  8357. * @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
  8358. * @param onCompiled Called when the shader has been compiled.
  8359. * @param onError Called if there is an error when compiling a shader.
  8360. */
  8361. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  8362. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  8363. /**
  8364. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  8365. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  8366. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  8367. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  8368. * The gaps between physical kernels are compensated for in the weighting of the samples
  8369. * @param idealKernel Ideal blur kernel.
  8370. * @return Nearest best kernel.
  8371. */
  8372. protected _nearestBestKernel(idealKernel: number): number;
  8373. /**
  8374. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  8375. * @param x The point on the Gaussian distribution to sample.
  8376. * @return the value of the Gaussian function at x.
  8377. */
  8378. protected _gaussianWeight(x: number): number;
  8379. /**
  8380. * Generates a string that can be used as a floating point number in GLSL.
  8381. * @param x Value to print.
  8382. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  8383. * @return GLSL float string.
  8384. */
  8385. protected _glslFloat(x: number, decimalFigures?: number): string;
  8386. }
  8387. }
  8388. declare module "babylonjs/Shaders/shadowMap.fragment" {
  8389. export var shadowMapPixelShader: {
  8390. name: string;
  8391. shader: string;
  8392. };
  8393. }
  8394. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  8395. export var bonesDeclaration: {
  8396. name: string;
  8397. shader: string;
  8398. };
  8399. }
  8400. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  8401. export var morphTargetsVertexGlobalDeclaration: {
  8402. name: string;
  8403. shader: string;
  8404. };
  8405. }
  8406. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  8407. export var morphTargetsVertexDeclaration: {
  8408. name: string;
  8409. shader: string;
  8410. };
  8411. }
  8412. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  8413. export var instancesDeclaration: {
  8414. name: string;
  8415. shader: string;
  8416. };
  8417. }
  8418. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  8419. export var helperFunctions: {
  8420. name: string;
  8421. shader: string;
  8422. };
  8423. }
  8424. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  8425. export var morphTargetsVertex: {
  8426. name: string;
  8427. shader: string;
  8428. };
  8429. }
  8430. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  8431. export var instancesVertex: {
  8432. name: string;
  8433. shader: string;
  8434. };
  8435. }
  8436. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  8437. export var bonesVertex: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module "babylonjs/Shaders/shadowMap.vertex" {
  8443. import "Shaders/ShadersInclude/bonesDeclaration";
  8444. import "Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  8445. import "Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  8446. import "Shaders/ShadersInclude/instancesDeclaration";
  8447. import "Shaders/ShadersInclude/helperFunctions";
  8448. import "Shaders/ShadersInclude/morphTargetsVertex";
  8449. import "Shaders/ShadersInclude/instancesVertex";
  8450. import "Shaders/ShadersInclude/bonesVertex";
  8451. export var shadowMapVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  8457. export var depthBoxBlurPixelShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  8463. import { Nullable } from "babylonjs/types";
  8464. import { Scene } from "babylonjs/scene";
  8465. import { Matrix } from "babylonjs/Maths/math";
  8466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  8467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8468. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  8469. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8470. import { Effect } from "babylonjs/Materials/effect";
  8471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  8472. import "Shaders/shadowMap.fragment";
  8473. import "Shaders/shadowMap.vertex";
  8474. import "Shaders/depthBoxBlur.fragment";
  8475. /**
  8476. * Interface to implement to create a shadow generator compatible with BJS.
  8477. */
  8478. export interface IShadowGenerator {
  8479. /**
  8480. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  8481. * @returns The render target texture if present otherwise, null
  8482. */
  8483. getShadowMap(): Nullable<RenderTargetTexture>;
  8484. /**
  8485. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  8486. * @returns The render target texture if the shadow map is present otherwise, null
  8487. */
  8488. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  8489. /**
  8490. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  8491. * @param subMesh The submesh we want to render in the shadow map
  8492. * @param useInstances Defines wether will draw in the map using instances
  8493. * @returns true if ready otherwise, false
  8494. */
  8495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8496. /**
  8497. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  8498. * @param defines Defines of the material we want to update
  8499. * @param lightIndex Index of the light in the enabled light list of the material
  8500. */
  8501. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  8502. /**
  8503. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  8504. * defined in the generator but impacting the effect).
  8505. * It implies the unifroms available on the materials are the standard BJS ones.
  8506. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  8507. * @param effect The effect we are binfing the information for
  8508. */
  8509. bindShadowLight(lightIndex: string, effect: Effect): void;
  8510. /**
  8511. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  8512. * (eq to shadow prjection matrix * light transform matrix)
  8513. * @returns The transform matrix used to create the shadow map
  8514. */
  8515. getTransformMatrix(): Matrix;
  8516. /**
  8517. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  8518. * Cube and 2D textures for instance.
  8519. */
  8520. recreateShadowMap(): void;
  8521. /**
  8522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  8523. * @param onCompiled Callback triggered at the and of the effects compilation
  8524. * @param options Sets of optional options forcing the compilation with different modes
  8525. */
  8526. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  8527. useInstances: boolean;
  8528. }>): void;
  8529. /**
  8530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  8531. * @param options Sets of optional options forcing the compilation with different modes
  8532. * @returns A promise that resolves when the compilation completes
  8533. */
  8534. forceCompilationAsync(options?: Partial<{
  8535. useInstances: boolean;
  8536. }>): Promise<void>;
  8537. /**
  8538. * Serializes the shadow generator setup to a json object.
  8539. * @returns The serialized JSON object
  8540. */
  8541. serialize(): any;
  8542. /**
  8543. * Disposes the Shadow map and related Textures and effects.
  8544. */
  8545. dispose(): void;
  8546. }
  8547. /**
  8548. * Default implementation IShadowGenerator.
  8549. * This is the main object responsible of generating shadows in the framework.
  8550. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  8551. */
  8552. export class ShadowGenerator implements IShadowGenerator {
  8553. /**
  8554. * Shadow generator mode None: no filtering applied.
  8555. */
  8556. static readonly FILTER_NONE: number;
  8557. /**
  8558. * Shadow generator mode ESM: Exponential Shadow Mapping.
  8559. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  8560. */
  8561. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  8562. /**
  8563. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  8564. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  8565. */
  8566. static readonly FILTER_POISSONSAMPLING: number;
  8567. /**
  8568. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  8569. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  8570. */
  8571. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  8572. /**
  8573. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  8574. * edge artifacts on steep falloff.
  8575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  8576. */
  8577. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  8578. /**
  8579. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  8580. * edge artifacts on steep falloff.
  8581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  8582. */
  8583. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  8584. /**
  8585. * Shadow generator mode PCF: Percentage Closer Filtering
  8586. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  8587. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  8588. */
  8589. static readonly FILTER_PCF: number;
  8590. /**
  8591. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  8592. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  8593. * Contact Hardening
  8594. */
  8595. static readonly FILTER_PCSS: number;
  8596. /**
  8597. * Reserved for PCF and PCSS
  8598. * Highest Quality.
  8599. *
  8600. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  8601. *
  8602. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  8603. */
  8604. static readonly QUALITY_HIGH: number;
  8605. /**
  8606. * Reserved for PCF and PCSS
  8607. * Good tradeoff for quality/perf cross devices
  8608. *
  8609. * Execute PCF on a 3*3 kernel.
  8610. *
  8611. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  8612. */
  8613. static readonly QUALITY_MEDIUM: number;
  8614. /**
  8615. * Reserved for PCF and PCSS
  8616. * The lowest quality but the fastest.
  8617. *
  8618. * Execute PCF on a 1*1 kernel.
  8619. *
  8620. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  8621. */
  8622. static readonly QUALITY_LOW: number;
  8623. private _bias;
  8624. /**
  8625. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  8626. */
  8627. /**
  8628. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  8629. */
  8630. bias: number;
  8631. private _normalBias;
  8632. /**
  8633. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  8634. */
  8635. /**
  8636. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  8637. */
  8638. normalBias: number;
  8639. private _blurBoxOffset;
  8640. /**
  8641. * Gets the blur box offset: offset applied during the blur pass.
  8642. * Only useful if useKernelBlur = false
  8643. */
  8644. /**
  8645. * Sets the blur box offset: offset applied during the blur pass.
  8646. * Only useful if useKernelBlur = false
  8647. */
  8648. blurBoxOffset: number;
  8649. private _blurScale;
  8650. /**
  8651. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  8652. * 2 means half of the size.
  8653. */
  8654. /**
  8655. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  8656. * 2 means half of the size.
  8657. */
  8658. blurScale: number;
  8659. private _blurKernel;
  8660. /**
  8661. * Gets the blur kernel: kernel size of the blur pass.
  8662. * Only useful if useKernelBlur = true
  8663. */
  8664. /**
  8665. * Sets the blur kernel: kernel size of the blur pass.
  8666. * Only useful if useKernelBlur = true
  8667. */
  8668. blurKernel: number;
  8669. private _useKernelBlur;
  8670. /**
  8671. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  8672. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  8673. */
  8674. /**
  8675. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  8676. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  8677. */
  8678. useKernelBlur: boolean;
  8679. private _depthScale;
  8680. /**
  8681. * Gets the depth scale used in ESM mode.
  8682. */
  8683. /**
  8684. * Sets the depth scale used in ESM mode.
  8685. * This can override the scale stored on the light.
  8686. */
  8687. depthScale: number;
  8688. private _filter;
  8689. /**
  8690. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  8691. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  8692. */
  8693. /**
  8694. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  8695. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  8696. */
  8697. filter: number;
  8698. /**
  8699. * Gets if the current filter is set to Poisson Sampling.
  8700. */
  8701. /**
  8702. * Sets the current filter to Poisson Sampling.
  8703. */
  8704. usePoissonSampling: boolean;
  8705. /**
  8706. * Gets if the current filter is set to ESM.
  8707. */
  8708. /**
  8709. * Sets the current filter is to ESM.
  8710. */
  8711. useExponentialShadowMap: boolean;
  8712. /**
  8713. * Gets if the current filter is set to filtered ESM.
  8714. */
  8715. /**
  8716. * Gets if the current filter is set to filtered ESM.
  8717. */
  8718. useBlurExponentialShadowMap: boolean;
  8719. /**
  8720. * Gets if the current filter is set to "close ESM" (using the inverse of the
  8721. * exponential to prevent steep falloff artifacts).
  8722. */
  8723. /**
  8724. * Sets the current filter to "close ESM" (using the inverse of the
  8725. * exponential to prevent steep falloff artifacts).
  8726. */
  8727. useCloseExponentialShadowMap: boolean;
  8728. /**
  8729. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  8730. * exponential to prevent steep falloff artifacts).
  8731. */
  8732. /**
  8733. * Sets the current filter to filtered "close ESM" (using the inverse of the
  8734. * exponential to prevent steep falloff artifacts).
  8735. */
  8736. useBlurCloseExponentialShadowMap: boolean;
  8737. /**
  8738. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  8739. */
  8740. /**
  8741. * Sets the current filter to "PCF" (percentage closer filtering).
  8742. */
  8743. usePercentageCloserFiltering: boolean;
  8744. private _filteringQuality;
  8745. /**
  8746. * Gets the PCF or PCSS Quality.
  8747. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  8748. */
  8749. /**
  8750. * Sets the PCF or PCSS Quality.
  8751. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  8752. */
  8753. filteringQuality: number;
  8754. /**
  8755. * Gets if the current filter is set to "PCSS" (contact hardening).
  8756. */
  8757. /**
  8758. * Sets the current filter to "PCSS" (contact hardening).
  8759. */
  8760. useContactHardeningShadow: boolean;
  8761. private _contactHardeningLightSizeUVRatio;
  8762. /**
  8763. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  8764. * Using a ratio helps keeping shape stability independently of the map size.
  8765. *
  8766. * It does not account for the light projection as it was having too much
  8767. * instability during the light setup or during light position changes.
  8768. *
  8769. * Only valid if useContactHardeningShadow is true.
  8770. */
  8771. /**
  8772. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  8773. * Using a ratio helps keeping shape stability independently of the map size.
  8774. *
  8775. * It does not account for the light projection as it was having too much
  8776. * instability during the light setup or during light position changes.
  8777. *
  8778. * Only valid if useContactHardeningShadow is true.
  8779. */
  8780. contactHardeningLightSizeUVRatio: number;
  8781. private _darkness;
  8782. /**
  8783. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  8784. * 0 means strongest and 1 would means no shadow.
  8785. * @returns the darkness.
  8786. */
  8787. getDarkness(): number;
  8788. /**
  8789. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  8790. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  8791. * @returns the shadow generator allowing fluent coding.
  8792. */
  8793. setDarkness(darkness: number): ShadowGenerator;
  8794. private _transparencyShadow;
  8795. /**
  8796. * Sets the ability to have transparent shadow (boolean).
  8797. * @param transparent True if transparent else False
  8798. * @returns the shadow generator allowing fluent coding
  8799. */
  8800. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  8801. private _shadowMap;
  8802. private _shadowMap2;
  8803. /**
  8804. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  8805. * @returns The render target texture if present otherwise, null
  8806. */
  8807. getShadowMap(): Nullable<RenderTargetTexture>;
  8808. /**
  8809. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  8810. * @returns The render target texture if the shadow map is present otherwise, null
  8811. */
  8812. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  8813. /**
  8814. * Helper function to add a mesh and its descendants to the list of shadow casters.
  8815. * @param mesh Mesh to add
  8816. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  8817. * @returns the Shadow Generator itself
  8818. */
  8819. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  8820. /**
  8821. * Helper function to remove a mesh and its descendants from the list of shadow casters
  8822. * @param mesh Mesh to remove
  8823. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  8824. * @returns the Shadow Generator itself
  8825. */
  8826. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  8827. /**
  8828. * Controls the extent to which the shadows fade out at the edge of the frustum
  8829. * Used only by directionals and spots
  8830. */
  8831. frustumEdgeFalloff: number;
  8832. private _light;
  8833. /**
  8834. * Returns the associated light object.
  8835. * @returns the light generating the shadow
  8836. */
  8837. getLight(): IShadowLight;
  8838. /**
  8839. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  8840. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  8841. * It might on the other hand introduce peter panning.
  8842. */
  8843. forceBackFacesOnly: boolean;
  8844. private _scene;
  8845. private _lightDirection;
  8846. private _effect;
  8847. private _viewMatrix;
  8848. private _projectionMatrix;
  8849. private _transformMatrix;
  8850. private _cachedPosition;
  8851. private _cachedDirection;
  8852. private _cachedDefines;
  8853. private _currentRenderID;
  8854. private _boxBlurPostprocess;
  8855. private _kernelBlurXPostprocess;
  8856. private _kernelBlurYPostprocess;
  8857. private _blurPostProcesses;
  8858. private _mapSize;
  8859. private _currentFaceIndex;
  8860. private _currentFaceIndexCache;
  8861. private _textureType;
  8862. private _defaultTextureMatrix;
  8863. /**
  8864. * Creates a ShadowGenerator object.
  8865. * A ShadowGenerator is the required tool to use the shadows.
  8866. * Each light casting shadows needs to use its own ShadowGenerator.
  8867. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  8868. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  8869. * @param light The light object generating the shadows.
  8870. * @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.
  8871. */
  8872. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  8873. private _initializeGenerator;
  8874. private _initializeShadowMap;
  8875. private _initializeBlurRTTAndPostProcesses;
  8876. private _renderForShadowMap;
  8877. private _renderSubMeshForShadowMap;
  8878. private _applyFilterValues;
  8879. /**
  8880. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  8881. * @param onCompiled Callback triggered at the and of the effects compilation
  8882. * @param options Sets of optional options forcing the compilation with different modes
  8883. */
  8884. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  8885. useInstances: boolean;
  8886. }>): void;
  8887. /**
  8888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  8889. * @param options Sets of optional options forcing the compilation with different modes
  8890. * @returns A promise that resolves when the compilation completes
  8891. */
  8892. forceCompilationAsync(options?: Partial<{
  8893. useInstances: boolean;
  8894. }>): Promise<void>;
  8895. /**
  8896. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  8897. * @param subMesh The submesh we want to render in the shadow map
  8898. * @param useInstances Defines wether will draw in the map using instances
  8899. * @returns true if ready otherwise, false
  8900. */
  8901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8902. /**
  8903. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  8904. * @param defines Defines of the material we want to update
  8905. * @param lightIndex Index of the light in the enabled light list of the material
  8906. */
  8907. prepareDefines(defines: any, lightIndex: number): void;
  8908. /**
  8909. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  8910. * defined in the generator but impacting the effect).
  8911. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  8912. * @param effect The effect we are binfing the information for
  8913. */
  8914. bindShadowLight(lightIndex: string, effect: Effect): void;
  8915. /**
  8916. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  8917. * (eq to shadow prjection matrix * light transform matrix)
  8918. * @returns The transform matrix used to create the shadow map
  8919. */
  8920. getTransformMatrix(): Matrix;
  8921. /**
  8922. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  8923. * Cube and 2D textures for instance.
  8924. */
  8925. recreateShadowMap(): void;
  8926. private _disposeBlurPostProcesses;
  8927. private _disposeRTTandPostProcesses;
  8928. /**
  8929. * Disposes the ShadowGenerator.
  8930. * Returns nothing.
  8931. */
  8932. dispose(): void;
  8933. /**
  8934. * Serializes the shadow generator setup to a json object.
  8935. * @returns The serialized JSON object
  8936. */
  8937. serialize(): any;
  8938. /**
  8939. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  8940. * @param parsedShadowGenerator The JSON object to parse
  8941. * @param scene The scene to create the shadow map for
  8942. * @returns The parsed shadow generator
  8943. */
  8944. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  8945. }
  8946. }
  8947. declare module "babylonjs/Lights/light" {
  8948. import { Nullable } from "babylonjs/types";
  8949. import { Scene } from "babylonjs/scene";
  8950. import { Vector3, Color3 } from "babylonjs/Maths/math";
  8951. import { Node } from "babylonjs/node";
  8952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8953. import { Effect } from "babylonjs/Materials/effect";
  8954. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8955. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8956. /**
  8957. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8958. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8959. * 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.
  8960. */
  8961. export abstract class Light extends Node {
  8962. /**
  8963. * Falloff Default: light is falling off following the material specification:
  8964. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8965. */
  8966. static readonly FALLOFF_DEFAULT: number;
  8967. /**
  8968. * Falloff Physical: light is falling off following the inverse squared distance law.
  8969. */
  8970. static readonly FALLOFF_PHYSICAL: number;
  8971. /**
  8972. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8973. * to enhance interoperability with other engines.
  8974. */
  8975. static readonly FALLOFF_GLTF: number;
  8976. /**
  8977. * Falloff Standard: light is falling off like in the standard material
  8978. * to enhance interoperability with other materials.
  8979. */
  8980. static readonly FALLOFF_STANDARD: number;
  8981. /**
  8982. * If every light affecting the material is in this lightmapMode,
  8983. * material.lightmapTexture adds or multiplies
  8984. * (depends on material.useLightmapAsShadowmap)
  8985. * after every other light calculations.
  8986. */
  8987. static readonly LIGHTMAP_DEFAULT: number;
  8988. /**
  8989. * material.lightmapTexture as only diffuse lighting from this light
  8990. * adds only specular lighting from this light
  8991. * adds dynamic shadows
  8992. */
  8993. static readonly LIGHTMAP_SPECULAR: number;
  8994. /**
  8995. * material.lightmapTexture as only lighting
  8996. * no light calculation from this light
  8997. * only adds dynamic shadows from this light
  8998. */
  8999. static readonly LIGHTMAP_SHADOWSONLY: number;
  9000. /**
  9001. * Each light type uses the default quantity according to its type:
  9002. * point/spot lights use luminous intensity
  9003. * directional lights use illuminance
  9004. */
  9005. static readonly INTENSITYMODE_AUTOMATIC: number;
  9006. /**
  9007. * lumen (lm)
  9008. */
  9009. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9010. /**
  9011. * candela (lm/sr)
  9012. */
  9013. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9014. /**
  9015. * lux (lm/m^2)
  9016. */
  9017. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9018. /**
  9019. * nit (cd/m^2)
  9020. */
  9021. static readonly INTENSITYMODE_LUMINANCE: number;
  9022. /**
  9023. * Light type const id of the point light.
  9024. */
  9025. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9026. /**
  9027. * Light type const id of the directional light.
  9028. */
  9029. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9030. /**
  9031. * Light type const id of the spot light.
  9032. */
  9033. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9034. /**
  9035. * Light type const id of the hemispheric light.
  9036. */
  9037. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9038. /**
  9039. * Diffuse gives the basic color to an object.
  9040. */
  9041. diffuse: Color3;
  9042. /**
  9043. * Specular produces a highlight color on an object.
  9044. * Note: This is note affecting PBR materials.
  9045. */
  9046. specular: Color3;
  9047. /**
  9048. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9049. * falling off base on range or angle.
  9050. * This can be set to any values in Light.FALLOFF_x.
  9051. *
  9052. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9053. * other types of materials.
  9054. */
  9055. falloffType: number;
  9056. /**
  9057. * Strength of the light.
  9058. * Note: By default it is define in the framework own unit.
  9059. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9060. */
  9061. intensity: number;
  9062. private _range;
  9063. protected _inverseSquaredRange: number;
  9064. /**
  9065. * Defines how far from the source the light is impacting in scene units.
  9066. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9067. */
  9068. /**
  9069. * Defines how far from the source the light is impacting in scene units.
  9070. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9071. */
  9072. range: number;
  9073. /**
  9074. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9075. * of light.
  9076. */
  9077. private _photometricScale;
  9078. private _intensityMode;
  9079. /**
  9080. * Gets the photometric scale used to interpret the intensity.
  9081. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9082. */
  9083. /**
  9084. * Sets the photometric scale used to interpret the intensity.
  9085. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9086. */
  9087. intensityMode: number;
  9088. private _radius;
  9089. /**
  9090. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9091. */
  9092. /**
  9093. * sets the light radius used by PBR Materials to simulate soft area lights.
  9094. */
  9095. radius: number;
  9096. private _renderPriority;
  9097. /**
  9098. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9099. * exceeding the number allowed of the materials.
  9100. */
  9101. renderPriority: number;
  9102. private _shadowEnabled;
  9103. /**
  9104. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9105. * the current shadow generator.
  9106. */
  9107. /**
  9108. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9109. * the current shadow generator.
  9110. */
  9111. shadowEnabled: boolean;
  9112. private _includedOnlyMeshes;
  9113. /**
  9114. * Gets the only meshes impacted by this light.
  9115. */
  9116. /**
  9117. * Sets the only meshes impacted by this light.
  9118. */
  9119. includedOnlyMeshes: AbstractMesh[];
  9120. private _excludedMeshes;
  9121. /**
  9122. * Gets the meshes not impacted by this light.
  9123. */
  9124. /**
  9125. * Sets the meshes not impacted by this light.
  9126. */
  9127. excludedMeshes: AbstractMesh[];
  9128. private _excludeWithLayerMask;
  9129. /**
  9130. * Gets the layer id use to find what meshes are not impacted by the light.
  9131. * Inactive if 0
  9132. */
  9133. /**
  9134. * Sets the layer id use to find what meshes are not impacted by the light.
  9135. * Inactive if 0
  9136. */
  9137. excludeWithLayerMask: number;
  9138. private _includeOnlyWithLayerMask;
  9139. /**
  9140. * Gets the layer id use to find what meshes are impacted by the light.
  9141. * Inactive if 0
  9142. */
  9143. /**
  9144. * Sets the layer id use to find what meshes are impacted by the light.
  9145. * Inactive if 0
  9146. */
  9147. includeOnlyWithLayerMask: number;
  9148. private _lightmapMode;
  9149. /**
  9150. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9151. */
  9152. /**
  9153. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9154. */
  9155. lightmapMode: number;
  9156. /**
  9157. * Shadow generator associted to the light.
  9158. * @hidden Internal use only.
  9159. */
  9160. _shadowGenerator: Nullable<IShadowGenerator>;
  9161. /**
  9162. * @hidden Internal use only.
  9163. */
  9164. _excludedMeshesIds: string[];
  9165. /**
  9166. * @hidden Internal use only.
  9167. */
  9168. _includedOnlyMeshesIds: string[];
  9169. /**
  9170. * The current light unifom buffer.
  9171. * @hidden Internal use only.
  9172. */
  9173. _uniformBuffer: UniformBuffer;
  9174. /**
  9175. * Creates a Light object in the scene.
  9176. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9177. * @param name The firendly name of the light
  9178. * @param scene The scene the light belongs too
  9179. */
  9180. constructor(name: string, scene: Scene);
  9181. protected abstract _buildUniformLayout(): void;
  9182. /**
  9183. * Sets the passed Effect "effect" with the Light information.
  9184. * @param effect The effect to update
  9185. * @param lightIndex The index of the light in the effect to update
  9186. * @returns The light
  9187. */
  9188. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9189. /**
  9190. * Returns the string "Light".
  9191. * @returns the class name
  9192. */
  9193. getClassName(): string;
  9194. /** @hidden */
  9195. readonly _isLight: boolean;
  9196. /**
  9197. * Converts the light information to a readable string for debug purpose.
  9198. * @param fullDetails Supports for multiple levels of logging within scene loading
  9199. * @returns the human readable light info
  9200. */
  9201. toString(fullDetails?: boolean): string;
  9202. /** @hidden */
  9203. protected _syncParentEnabledState(): void;
  9204. /**
  9205. * Set the enabled state of this node.
  9206. * @param value - the new enabled state
  9207. */
  9208. setEnabled(value: boolean): void;
  9209. /**
  9210. * Returns the Light associated shadow generator if any.
  9211. * @return the associated shadow generator.
  9212. */
  9213. getShadowGenerator(): Nullable<IShadowGenerator>;
  9214. /**
  9215. * Returns a Vector3, the absolute light position in the World.
  9216. * @returns the world space position of the light
  9217. */
  9218. getAbsolutePosition(): Vector3;
  9219. /**
  9220. * Specifies if the light will affect the passed mesh.
  9221. * @param mesh The mesh to test against the light
  9222. * @return true the mesh is affected otherwise, false.
  9223. */
  9224. canAffectMesh(mesh: AbstractMesh): boolean;
  9225. /**
  9226. * Sort function to order lights for rendering.
  9227. * @param a First Light object to compare to second.
  9228. * @param b Second Light object to compare first.
  9229. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9230. */
  9231. static CompareLightsPriority(a: Light, b: Light): number;
  9232. /**
  9233. * Releases resources associated with this node.
  9234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9236. */
  9237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9238. /**
  9239. * Returns the light type ID (integer).
  9240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9241. */
  9242. getTypeID(): number;
  9243. /**
  9244. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9245. * @returns the scaled intensity in intensity mode unit
  9246. */
  9247. getScaledIntensity(): number;
  9248. /**
  9249. * Returns a new Light object, named "name", from the current one.
  9250. * @param name The name of the cloned light
  9251. * @returns the new created light
  9252. */
  9253. clone(name: string): Nullable<Light>;
  9254. /**
  9255. * Serializes the current light into a Serialization object.
  9256. * @returns the serialized object.
  9257. */
  9258. serialize(): any;
  9259. /**
  9260. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9261. * This new light is named "name" and added to the passed scene.
  9262. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9263. * @param name The friendly name of the light
  9264. * @param scene The scene the new light will belong to
  9265. * @returns the constructor function
  9266. */
  9267. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9268. /**
  9269. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9270. * @param parsedLight The JSON representation of the light
  9271. * @param scene The scene to create the parsed light in
  9272. * @returns the created light after parsing
  9273. */
  9274. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9275. private _hookArrayForExcluded;
  9276. private _hookArrayForIncludedOnly;
  9277. private _resyncMeshes;
  9278. /**
  9279. * Forces the meshes to update their light related information in their rendering used effects
  9280. * @hidden Internal Use Only
  9281. */
  9282. _markMeshesAsLightDirty(): void;
  9283. /**
  9284. * Recomputes the cached photometric scale if needed.
  9285. */
  9286. private _computePhotometricScale;
  9287. /**
  9288. * Returns the Photometric Scale according to the light type and intensity mode.
  9289. */
  9290. private _getPhotometricScale;
  9291. /**
  9292. * Reorder the light in the scene according to their defined priority.
  9293. * @hidden Internal Use Only
  9294. */
  9295. _reorderLightsInScene(): void;
  9296. /**
  9297. * Prepares the list of defines specific to the light type.
  9298. * @param defines the list of defines
  9299. * @param lightIndex defines the index of the light for the effect
  9300. */
  9301. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9302. }
  9303. }
  9304. declare module "babylonjs/Actions/action" {
  9305. import { Observable } from "babylonjs/Misc/observable";
  9306. import { Condition } from "babylonjs/Actions/condition";
  9307. import { ActionManager } from "babylonjs/Actions/actionManager";
  9308. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9309. /**
  9310. * The action to be carried out following a trigger
  9311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9312. */
  9313. export class Action {
  9314. /** the trigger, with or without parameters, for the action */
  9315. triggerOptions: any;
  9316. /**
  9317. * Trigger for the action
  9318. */
  9319. trigger: number;
  9320. /**
  9321. * Internal only - manager for action
  9322. * @hidden
  9323. */
  9324. _actionManager: ActionManager;
  9325. private _nextActiveAction;
  9326. private _child;
  9327. private _condition?;
  9328. private _triggerParameter;
  9329. /**
  9330. * An event triggered prior to action being executed.
  9331. */
  9332. onBeforeExecuteObservable: Observable<Action>;
  9333. /**
  9334. * Creates a new Action
  9335. * @param triggerOptions the trigger, with or without parameters, for the action
  9336. * @param condition an optional determinant of action
  9337. */
  9338. constructor(
  9339. /** the trigger, with or without parameters, for the action */
  9340. triggerOptions: any, condition?: Condition);
  9341. /**
  9342. * Internal only
  9343. * @hidden
  9344. */
  9345. _prepare(): void;
  9346. /**
  9347. * Gets the trigger parameters
  9348. * @returns the trigger parameters
  9349. */
  9350. getTriggerParameter(): any;
  9351. /**
  9352. * Internal only - executes current action event
  9353. * @hidden
  9354. */
  9355. _executeCurrent(evt?: ActionEvent): void;
  9356. /**
  9357. * Execute placeholder for child classes
  9358. * @param evt optional action event
  9359. */
  9360. execute(evt?: ActionEvent): void;
  9361. /**
  9362. * Skips to next active action
  9363. */
  9364. skipToNextActiveAction(): void;
  9365. /**
  9366. * Adds action to chain of actions, may be a DoNothingAction
  9367. * @param action defines the next action to execute
  9368. * @returns The action passed in
  9369. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9370. */
  9371. then(action: Action): Action;
  9372. /**
  9373. * Internal only
  9374. * @hidden
  9375. */
  9376. _getProperty(propertyPath: string): string;
  9377. /**
  9378. * Internal only
  9379. * @hidden
  9380. */
  9381. _getEffectiveTarget(target: any, propertyPath: string): any;
  9382. /**
  9383. * Serialize placeholder for child classes
  9384. * @param parent of child
  9385. * @returns the serialized object
  9386. */
  9387. serialize(parent: any): any;
  9388. /**
  9389. * Internal only called by serialize
  9390. * @hidden
  9391. */
  9392. protected _serialize(serializedAction: any, parent?: any): any;
  9393. /**
  9394. * Internal only
  9395. * @hidden
  9396. */
  9397. static _SerializeValueAsString: (value: any) => string;
  9398. /**
  9399. * Internal only
  9400. * @hidden
  9401. */
  9402. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  9403. name: string;
  9404. targetType: string;
  9405. value: string;
  9406. };
  9407. }
  9408. }
  9409. declare module "babylonjs/Actions/condition" {
  9410. import { ActionManager } from "babylonjs/Actions/actionManager";
  9411. /**
  9412. * A Condition applied to an Action
  9413. */
  9414. export class Condition {
  9415. /**
  9416. * Internal only - manager for action
  9417. * @hidden
  9418. */
  9419. _actionManager: ActionManager;
  9420. /**
  9421. * Internal only
  9422. * @hidden
  9423. */
  9424. _evaluationId: number;
  9425. /**
  9426. * Internal only
  9427. * @hidden
  9428. */
  9429. _currentResult: boolean;
  9430. /**
  9431. * Creates a new Condition
  9432. * @param actionManager the manager of the action the condition is applied to
  9433. */
  9434. constructor(actionManager: ActionManager);
  9435. /**
  9436. * Check if the current condition is valid
  9437. * @returns a boolean
  9438. */
  9439. isValid(): boolean;
  9440. /**
  9441. * Internal only
  9442. * @hidden
  9443. */
  9444. _getProperty(propertyPath: string): string;
  9445. /**
  9446. * Internal only
  9447. * @hidden
  9448. */
  9449. _getEffectiveTarget(target: any, propertyPath: string): any;
  9450. /**
  9451. * Serialize placeholder for child classes
  9452. * @returns the serialized object
  9453. */
  9454. serialize(): any;
  9455. /**
  9456. * Internal only
  9457. * @hidden
  9458. */
  9459. protected _serialize(serializedCondition: any): any;
  9460. }
  9461. /**
  9462. * Defines specific conditional operators as extensions of Condition
  9463. */
  9464. export class ValueCondition extends Condition {
  9465. /** path to specify the property of the target the conditional operator uses */
  9466. propertyPath: string;
  9467. /** the value compared by the conditional operator against the current value of the property */
  9468. value: any;
  9469. /** the conditional operator, default ValueCondition.IsEqual */
  9470. operator: number;
  9471. /**
  9472. * Internal only
  9473. * @hidden
  9474. */
  9475. private static _IsEqual;
  9476. /**
  9477. * Internal only
  9478. * @hidden
  9479. */
  9480. private static _IsDifferent;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. private static _IsGreater;
  9486. /**
  9487. * Internal only
  9488. * @hidden
  9489. */
  9490. private static _IsLesser;
  9491. /**
  9492. * returns the number for IsEqual
  9493. */
  9494. static readonly IsEqual: number;
  9495. /**
  9496. * Returns the number for IsDifferent
  9497. */
  9498. static readonly IsDifferent: number;
  9499. /**
  9500. * Returns the number for IsGreater
  9501. */
  9502. static readonly IsGreater: number;
  9503. /**
  9504. * Returns the number for IsLesser
  9505. */
  9506. static readonly IsLesser: number;
  9507. /**
  9508. * Internal only The action manager for the condition
  9509. * @hidden
  9510. */
  9511. _actionManager: ActionManager;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. private _target;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. private _effectiveTarget;
  9522. /**
  9523. * Internal only
  9524. * @hidden
  9525. */
  9526. private _property;
  9527. /**
  9528. * Creates a new ValueCondition
  9529. * @param actionManager manager for the action the condition applies to
  9530. * @param target for the action
  9531. * @param propertyPath path to specify the property of the target the conditional operator uses
  9532. * @param value the value compared by the conditional operator against the current value of the property
  9533. * @param operator the conditional operator, default ValueCondition.IsEqual
  9534. */
  9535. constructor(actionManager: ActionManager, target: any,
  9536. /** path to specify the property of the target the conditional operator uses */
  9537. propertyPath: string,
  9538. /** the value compared by the conditional operator against the current value of the property */
  9539. value: any,
  9540. /** the conditional operator, default ValueCondition.IsEqual */
  9541. operator?: number);
  9542. /**
  9543. * Compares the given value with the property value for the specified conditional operator
  9544. * @returns the result of the comparison
  9545. */
  9546. isValid(): boolean;
  9547. /**
  9548. * Serialize the ValueCondition into a JSON compatible object
  9549. * @returns serialization object
  9550. */
  9551. serialize(): any;
  9552. /**
  9553. * Gets the name of the conditional operator for the ValueCondition
  9554. * @param operator the conditional operator
  9555. * @returns the name
  9556. */
  9557. static GetOperatorName(operator: number): string;
  9558. }
  9559. /**
  9560. * Defines a predicate condition as an extension of Condition
  9561. */
  9562. export class PredicateCondition extends Condition {
  9563. /** defines the predicate function used to validate the condition */
  9564. predicate: () => boolean;
  9565. /**
  9566. * Internal only - manager for action
  9567. * @hidden
  9568. */
  9569. _actionManager: ActionManager;
  9570. /**
  9571. * Creates a new PredicateCondition
  9572. * @param actionManager manager for the action the condition applies to
  9573. * @param predicate defines the predicate function used to validate the condition
  9574. */
  9575. constructor(actionManager: ActionManager,
  9576. /** defines the predicate function used to validate the condition */
  9577. predicate: () => boolean);
  9578. /**
  9579. * @returns the validity of the predicate condition
  9580. */
  9581. isValid(): boolean;
  9582. }
  9583. /**
  9584. * Defines a state condition as an extension of Condition
  9585. */
  9586. export class StateCondition extends Condition {
  9587. /** Value to compare with target state */
  9588. value: string;
  9589. /**
  9590. * Internal only - manager for action
  9591. * @hidden
  9592. */
  9593. _actionManager: ActionManager;
  9594. /**
  9595. * Internal only
  9596. * @hidden
  9597. */
  9598. private _target;
  9599. /**
  9600. * Creates a new StateCondition
  9601. * @param actionManager manager for the action the condition applies to
  9602. * @param target of the condition
  9603. * @param value to compare with target state
  9604. */
  9605. constructor(actionManager: ActionManager, target: any,
  9606. /** Value to compare with target state */
  9607. value: string);
  9608. /**
  9609. * Gets a boolean indicating if the current condition is met
  9610. * @returns the validity of the state
  9611. */
  9612. isValid(): boolean;
  9613. /**
  9614. * Serialize the StateCondition into a JSON compatible object
  9615. * @returns serialization object
  9616. */
  9617. serialize(): any;
  9618. }
  9619. }
  9620. declare module "babylonjs/Actions/directActions" {
  9621. import { Action } from "babylonjs/Actions/action";
  9622. import { Condition } from "babylonjs/Actions/condition";
  9623. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9624. /**
  9625. * This defines an action responsible to toggle a boolean once triggered.
  9626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9627. */
  9628. export class SwitchBooleanAction extends Action {
  9629. /**
  9630. * The path to the boolean property in the target object
  9631. */
  9632. propertyPath: string;
  9633. private _target;
  9634. private _effectiveTarget;
  9635. private _property;
  9636. /**
  9637. * Instantiate the action
  9638. * @param triggerOptions defines the trigger options
  9639. * @param target defines the object containing the boolean
  9640. * @param propertyPath defines the path to the boolean property in the target object
  9641. * @param condition defines the trigger related conditions
  9642. */
  9643. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9644. /** @hidden */
  9645. _prepare(): void;
  9646. /**
  9647. * Execute the action toggle the boolean value.
  9648. */
  9649. execute(): void;
  9650. /**
  9651. * Serializes the actions and its related information.
  9652. * @param parent defines the object to serialize in
  9653. * @returns the serialized object
  9654. */
  9655. serialize(parent: any): any;
  9656. }
  9657. /**
  9658. * This defines an action responsible to set a the state field of the target
  9659. * to a desired value once triggered.
  9660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9661. */
  9662. export class SetStateAction extends Action {
  9663. /**
  9664. * The value to store in the state field.
  9665. */
  9666. value: string;
  9667. private _target;
  9668. /**
  9669. * Instantiate the action
  9670. * @param triggerOptions defines the trigger options
  9671. * @param target defines the object containing the state property
  9672. * @param value defines the value to store in the state field
  9673. * @param condition defines the trigger related conditions
  9674. */
  9675. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9676. /**
  9677. * Execute the action and store the value on the target state property.
  9678. */
  9679. execute(): void;
  9680. /**
  9681. * Serializes the actions and its related information.
  9682. * @param parent defines the object to serialize in
  9683. * @returns the serialized object
  9684. */
  9685. serialize(parent: any): any;
  9686. }
  9687. /**
  9688. * This defines an action responsible to set a property of the target
  9689. * to a desired value once triggered.
  9690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9691. */
  9692. export class SetValueAction extends Action {
  9693. /**
  9694. * The path of the property to set in the target.
  9695. */
  9696. propertyPath: string;
  9697. /**
  9698. * The value to set in the property
  9699. */
  9700. value: any;
  9701. private _target;
  9702. private _effectiveTarget;
  9703. private _property;
  9704. /**
  9705. * Instantiate the action
  9706. * @param triggerOptions defines the trigger options
  9707. * @param target defines the object containing the property
  9708. * @param propertyPath defines the path of the property to set in the target
  9709. * @param value defines the value to set in the property
  9710. * @param condition defines the trigger related conditions
  9711. */
  9712. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9713. /** @hidden */
  9714. _prepare(): void;
  9715. /**
  9716. * Execute the action and set the targetted property to the desired value.
  9717. */
  9718. execute(): void;
  9719. /**
  9720. * Serializes the actions and its related information.
  9721. * @param parent defines the object to serialize in
  9722. * @returns the serialized object
  9723. */
  9724. serialize(parent: any): any;
  9725. }
  9726. /**
  9727. * This defines an action responsible to increment the target value
  9728. * to a desired value once triggered.
  9729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9730. */
  9731. export class IncrementValueAction extends Action {
  9732. /**
  9733. * The path of the property to increment in the target.
  9734. */
  9735. propertyPath: string;
  9736. /**
  9737. * The value we should increment the property by.
  9738. */
  9739. value: any;
  9740. private _target;
  9741. private _effectiveTarget;
  9742. private _property;
  9743. /**
  9744. * Instantiate the action
  9745. * @param triggerOptions defines the trigger options
  9746. * @param target defines the object containing the property
  9747. * @param propertyPath defines the path of the property to increment in the target
  9748. * @param value defines the value value we should increment the property by
  9749. * @param condition defines the trigger related conditions
  9750. */
  9751. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9752. /** @hidden */
  9753. _prepare(): void;
  9754. /**
  9755. * Execute the action and increment the target of the value amount.
  9756. */
  9757. execute(): void;
  9758. /**
  9759. * Serializes the actions and its related information.
  9760. * @param parent defines the object to serialize in
  9761. * @returns the serialized object
  9762. */
  9763. serialize(parent: any): any;
  9764. }
  9765. /**
  9766. * This defines an action responsible to start an animation once triggered.
  9767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9768. */
  9769. export class PlayAnimationAction extends Action {
  9770. /**
  9771. * Where the animation should start (animation frame)
  9772. */
  9773. from: number;
  9774. /**
  9775. * Where the animation should stop (animation frame)
  9776. */
  9777. to: number;
  9778. /**
  9779. * Define if the animation should loop or stop after the first play.
  9780. */
  9781. loop?: boolean;
  9782. private _target;
  9783. /**
  9784. * Instantiate the action
  9785. * @param triggerOptions defines the trigger options
  9786. * @param target defines the target animation or animation name
  9787. * @param from defines from where the animation should start (animation frame)
  9788. * @param end defines where the animation should stop (animation frame)
  9789. * @param loop defines if the animation should loop or stop after the first play
  9790. * @param condition defines the trigger related conditions
  9791. */
  9792. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9793. /** @hidden */
  9794. _prepare(): void;
  9795. /**
  9796. * Execute the action and play the animation.
  9797. */
  9798. execute(): void;
  9799. /**
  9800. * Serializes the actions and its related information.
  9801. * @param parent defines the object to serialize in
  9802. * @returns the serialized object
  9803. */
  9804. serialize(parent: any): any;
  9805. }
  9806. /**
  9807. * This defines an action responsible to stop an animation once triggered.
  9808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9809. */
  9810. export class StopAnimationAction extends Action {
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param condition defines the trigger related conditions
  9817. */
  9818. constructor(triggerOptions: any, target: any, condition?: Condition);
  9819. /** @hidden */
  9820. _prepare(): void;
  9821. /**
  9822. * Execute the action and stop the animation.
  9823. */
  9824. execute(): void;
  9825. /**
  9826. * Serializes the actions and its related information.
  9827. * @param parent defines the object to serialize in
  9828. * @returns the serialized object
  9829. */
  9830. serialize(parent: any): any;
  9831. }
  9832. /**
  9833. * This defines an action responsible that does nothing once triggered.
  9834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9835. */
  9836. export class DoNothingAction extends Action {
  9837. /**
  9838. * Instantiate the action
  9839. * @param triggerOptions defines the trigger options
  9840. * @param condition defines the trigger related conditions
  9841. */
  9842. constructor(triggerOptions?: any, condition?: Condition);
  9843. /**
  9844. * Execute the action and do nothing.
  9845. */
  9846. execute(): void;
  9847. /**
  9848. * Serializes the actions and its related information.
  9849. * @param parent defines the object to serialize in
  9850. * @returns the serialized object
  9851. */
  9852. serialize(parent: any): any;
  9853. }
  9854. /**
  9855. * This defines an action responsible to trigger several actions once triggered.
  9856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9857. */
  9858. export class CombineAction extends Action {
  9859. /**
  9860. * The list of aggregated animations to run.
  9861. */
  9862. children: Action[];
  9863. /**
  9864. * Instantiate the action
  9865. * @param triggerOptions defines the trigger options
  9866. * @param children defines the list of aggregated animations to run
  9867. * @param condition defines the trigger related conditions
  9868. */
  9869. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9870. /** @hidden */
  9871. _prepare(): void;
  9872. /**
  9873. * Execute the action and executes all the aggregated actions.
  9874. */
  9875. execute(evt: ActionEvent): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to run code (external event) once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class ExecuteCodeAction extends Action {
  9888. /**
  9889. * The callback function to run.
  9890. */
  9891. func: (evt: ActionEvent) => void;
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param func defines the callback function to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9899. /**
  9900. * Execute the action and run the attached code.
  9901. */
  9902. execute(evt: ActionEvent): void;
  9903. }
  9904. /**
  9905. * This defines an action responsible to set the parent property of the target once triggered.
  9906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9907. */
  9908. export class SetParentAction extends Action {
  9909. private _parent;
  9910. private _target;
  9911. /**
  9912. * Instantiate the action
  9913. * @param triggerOptions defines the trigger options
  9914. * @param target defines the target containing the parent property
  9915. * @param parent defines from where the animation should start (animation frame)
  9916. * @param condition defines the trigger related conditions
  9917. */
  9918. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9919. /** @hidden */
  9920. _prepare(): void;
  9921. /**
  9922. * Execute the action and set the parent property.
  9923. */
  9924. execute(): void;
  9925. /**
  9926. * Serializes the actions and its related information.
  9927. * @param parent defines the object to serialize in
  9928. * @returns the serialized object
  9929. */
  9930. serialize(parent: any): any;
  9931. }
  9932. }
  9933. declare module "babylonjs/Actions/actionManager" {
  9934. import { Nullable } from "babylonjs/types";
  9935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9936. import { Scene } from "babylonjs/scene";
  9937. import { Action } from "babylonjs/Actions/action";
  9938. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9939. /**
  9940. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9941. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9943. */
  9944. export class ActionManager {
  9945. /**
  9946. * Nothing
  9947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9948. */
  9949. static readonly NothingTrigger: number;
  9950. /**
  9951. * On pick
  9952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9953. */
  9954. static readonly OnPickTrigger: number;
  9955. /**
  9956. * On left pick
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9958. */
  9959. static readonly OnLeftPickTrigger: number;
  9960. /**
  9961. * On right pick
  9962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9963. */
  9964. static readonly OnRightPickTrigger: number;
  9965. /**
  9966. * On center pick
  9967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9968. */
  9969. static readonly OnCenterPickTrigger: number;
  9970. /**
  9971. * On pick down
  9972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9973. */
  9974. static readonly OnPickDownTrigger: number;
  9975. /**
  9976. * On double pick
  9977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9978. */
  9979. static readonly OnDoublePickTrigger: number;
  9980. /**
  9981. * On pick up
  9982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9983. */
  9984. static readonly OnPickUpTrigger: number;
  9985. /**
  9986. * On pick out.
  9987. * This trigger will only be raised if you also declared a OnPickDown
  9988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9989. */
  9990. static readonly OnPickOutTrigger: number;
  9991. /**
  9992. * On long press
  9993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9994. */
  9995. static readonly OnLongPressTrigger: number;
  9996. /**
  9997. * On pointer over
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9999. */
  10000. static readonly OnPointerOverTrigger: number;
  10001. /**
  10002. * On pointer out
  10003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10004. */
  10005. static readonly OnPointerOutTrigger: number;
  10006. /**
  10007. * On every frame
  10008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10009. */
  10010. static readonly OnEveryFrameTrigger: number;
  10011. /**
  10012. * On intersection enter
  10013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10014. */
  10015. static readonly OnIntersectionEnterTrigger: number;
  10016. /**
  10017. * On intersection exit
  10018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10019. */
  10020. static readonly OnIntersectionExitTrigger: number;
  10021. /**
  10022. * On key down
  10023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10024. */
  10025. static readonly OnKeyDownTrigger: number;
  10026. /**
  10027. * On key up
  10028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10029. */
  10030. static readonly OnKeyUpTrigger: number;
  10031. /** Gets the list of active triggers */
  10032. static Triggers: {
  10033. [key: string]: number;
  10034. };
  10035. /** Gets the list of actions */
  10036. actions: Action[];
  10037. /** Gets the cursor to use when hovering items */
  10038. hoverCursor: string;
  10039. private _scene;
  10040. /**
  10041. * Creates a new action manager
  10042. * @param scene defines the hosting scene
  10043. */
  10044. constructor(scene: Scene);
  10045. /**
  10046. * Releases all associated resources
  10047. */
  10048. dispose(): void;
  10049. /**
  10050. * Gets hosting scene
  10051. * @returns the hosting scene
  10052. */
  10053. getScene(): Scene;
  10054. /**
  10055. * Does this action manager handles actions of any of the given triggers
  10056. * @param triggers defines the triggers to be tested
  10057. * @return a boolean indicating whether one (or more) of the triggers is handled
  10058. */
  10059. hasSpecificTriggers(triggers: number[]): boolean;
  10060. /**
  10061. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10062. * speed.
  10063. * @param triggerA defines the trigger to be tested
  10064. * @param triggerB defines the trigger to be tested
  10065. * @return a boolean indicating whether one (or more) of the triggers is handled
  10066. */
  10067. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10068. /**
  10069. * Does this action manager handles actions of a given trigger
  10070. * @param trigger defines the trigger to be tested
  10071. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10072. * @return whether the trigger is handled
  10073. */
  10074. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10075. /**
  10076. * Does this action manager has pointer triggers
  10077. */
  10078. readonly hasPointerTriggers: boolean;
  10079. /**
  10080. * Does this action manager has pick triggers
  10081. */
  10082. readonly hasPickTriggers: boolean;
  10083. /**
  10084. * Does exist one action manager with at least one trigger
  10085. **/
  10086. static readonly HasTriggers: boolean;
  10087. /**
  10088. * Does exist one action manager with at least one pick trigger
  10089. **/
  10090. static readonly HasPickTriggers: boolean;
  10091. /**
  10092. * Does exist one action manager that handles actions of a given trigger
  10093. * @param trigger defines the trigger to be tested
  10094. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10095. **/
  10096. static HasSpecificTrigger(trigger: number): boolean;
  10097. /**
  10098. * Registers an action to this action manager
  10099. * @param action defines the action to be registered
  10100. * @return the action amended (prepared) after registration
  10101. */
  10102. registerAction(action: Action): Nullable<Action>;
  10103. /**
  10104. * Unregisters an action to this action manager
  10105. * @param action defines the action to be unregistered
  10106. * @return a boolean indicating whether the action has been unregistered
  10107. */
  10108. unregisterAction(action: Action): Boolean;
  10109. /**
  10110. * Process a specific trigger
  10111. * @param trigger defines the trigger to process
  10112. * @param evt defines the event details to be processed
  10113. */
  10114. processTrigger(trigger: number, evt?: ActionEvent): void;
  10115. /** @hidden */
  10116. _getEffectiveTarget(target: any, propertyPath: string): any;
  10117. /** @hidden */
  10118. _getProperty(propertyPath: string): string;
  10119. /**
  10120. * Serialize this manager to a JSON object
  10121. * @param name defines the property name to store this manager
  10122. * @returns a JSON representation of this manager
  10123. */
  10124. serialize(name: string): any;
  10125. /**
  10126. * Creates a new ActionManager from a JSON data
  10127. * @param parsedActions defines the JSON data to read from
  10128. * @param object defines the hosting mesh
  10129. * @param scene defines the hosting scene
  10130. */
  10131. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10132. /**
  10133. * Get a trigger name by index
  10134. * @param trigger defines the trigger index
  10135. * @returns a trigger name
  10136. */
  10137. static GetTriggerName(trigger: number): string;
  10138. }
  10139. }
  10140. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10141. import { Nullable } from "babylonjs/types";
  10142. import { Observable } from "babylonjs/Misc/observable";
  10143. import { Scene } from "babylonjs/scene";
  10144. import { Sprite } from "babylonjs/Sprites/sprite";
  10145. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10146. import { Ray } from "babylonjs/Culling/ray";
  10147. import { Camera } from "babylonjs/Cameras/camera";
  10148. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10149. import { ISceneComponent } from "babylonjs/sceneComponent";
  10150. module "babylonjs/scene" {
  10151. interface Scene {
  10152. /** @hidden */
  10153. _pointerOverSprite: Nullable<Sprite>;
  10154. /** @hidden */
  10155. _pickedDownSprite: Nullable<Sprite>;
  10156. /** @hidden */
  10157. _tempSpritePickingRay: Nullable<Ray>;
  10158. /**
  10159. * All of the sprite managers added to this scene
  10160. * @see http://doc.babylonjs.com/babylon101/sprites
  10161. */
  10162. spriteManagers: Array<ISpriteManager>;
  10163. /**
  10164. * An event triggered when sprites rendering is about to start
  10165. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10166. */
  10167. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10168. /**
  10169. * An event triggered when sprites rendering is done
  10170. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10171. */
  10172. onAfterSpritesRenderingObservable: Observable<Scene>;
  10173. /** @hidden */
  10174. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10175. /** Launch a ray to try to pick a sprite in the scene
  10176. * @param x position on screen
  10177. * @param y position on screen
  10178. * @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
  10179. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10180. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10181. * @returns a PickingInfo
  10182. */
  10183. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10184. /** Use the given ray to pick a sprite in the scene
  10185. * @param ray The ray (in world space) to use to pick meshes
  10186. * @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
  10187. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10188. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10189. * @returns a PickingInfo
  10190. */
  10191. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10192. /**
  10193. * Force the sprite under the pointer
  10194. * @param sprite defines the sprite to use
  10195. */
  10196. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10197. /**
  10198. * Gets the sprite under the pointer
  10199. * @returns a Sprite or null if no sprite is under the pointer
  10200. */
  10201. getPointerOverSprite(): Nullable<Sprite>;
  10202. }
  10203. }
  10204. /**
  10205. * Defines the sprite scene component responsible to manage sprites
  10206. * in a given scene.
  10207. */
  10208. export class SpriteSceneComponent implements ISceneComponent {
  10209. /**
  10210. * The component name helpfull to identify the component in the list of scene components.
  10211. */
  10212. readonly name: string;
  10213. /**
  10214. * The scene the component belongs to.
  10215. */
  10216. scene: Scene;
  10217. /** @hidden */
  10218. private _spritePredicate;
  10219. /**
  10220. * Creates a new instance of the component for the given scene
  10221. * @param scene Defines the scene to register the component in
  10222. */
  10223. constructor(scene: Scene);
  10224. /**
  10225. * Registers the component in a given scene
  10226. */
  10227. register(): void;
  10228. /**
  10229. * Rebuilds the elements related to this component in case of
  10230. * context lost for instance.
  10231. */
  10232. rebuild(): void;
  10233. /**
  10234. * Disposes the component and the associated ressources.
  10235. */
  10236. dispose(): void;
  10237. private _pickSpriteButKeepRay;
  10238. private _pointerMove;
  10239. private _pointerDown;
  10240. private _pointerUp;
  10241. }
  10242. }
  10243. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10244. export var fogFragmentDeclaration: {
  10245. name: string;
  10246. shader: string;
  10247. };
  10248. }
  10249. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10250. export var fogFragment: {
  10251. name: string;
  10252. shader: string;
  10253. };
  10254. }
  10255. declare module "babylonjs/Shaders/sprites.fragment" {
  10256. import "Shaders/ShadersInclude/fogFragmentDeclaration";
  10257. import "Shaders/ShadersInclude/fogFragment";
  10258. export var spritesPixelShader: {
  10259. name: string;
  10260. shader: string;
  10261. };
  10262. }
  10263. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10264. export var fogVertexDeclaration: {
  10265. name: string;
  10266. shader: string;
  10267. };
  10268. }
  10269. declare module "babylonjs/Shaders/sprites.vertex" {
  10270. import "Shaders/ShadersInclude/fogVertexDeclaration";
  10271. export var spritesVertexShader: {
  10272. name: string;
  10273. shader: string;
  10274. };
  10275. }
  10276. declare module "babylonjs/Sprites/spriteManager" {
  10277. import { IDisposable, Scene } from "babylonjs/scene";
  10278. import { Nullable } from "babylonjs/types";
  10279. import { Observable } from "babylonjs/Misc/observable";
  10280. import { Sprite } from "babylonjs/Sprites/sprite";
  10281. import { Ray } from "babylonjs/Culling/ray";
  10282. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10283. import { Camera } from "babylonjs/Cameras/camera";
  10284. import { Texture } from "babylonjs/Materials/Textures/texture";
  10285. import "Shaders/sprites.fragment";
  10286. import "Shaders/sprites.vertex";
  10287. /**
  10288. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10289. */
  10290. export interface ISpriteManager extends IDisposable {
  10291. /**
  10292. * Restricts the camera to viewing objects with the same layerMask.
  10293. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10294. */
  10295. layerMask: number;
  10296. /**
  10297. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10298. */
  10299. isPickable: boolean;
  10300. /**
  10301. * Specifies the rendering group id for this mesh (0 by default)
  10302. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10303. */
  10304. renderingGroupId: number;
  10305. /**
  10306. * Defines the list of sprites managed by the manager.
  10307. */
  10308. sprites: Array<Sprite>;
  10309. /**
  10310. * Tests the intersection of a sprite with a specific ray.
  10311. * @param ray The ray we are sending to test the collision
  10312. * @param camera The camera space we are sending rays in
  10313. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10314. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10315. * @returns picking info or null.
  10316. */
  10317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10318. /**
  10319. * Renders the list of sprites on screen.
  10320. */
  10321. render(): void;
  10322. }
  10323. /**
  10324. * Class used to manage multiple sprites on the same spritesheet
  10325. * @see http://doc.babylonjs.com/babylon101/sprites
  10326. */
  10327. export class SpriteManager implements ISpriteManager {
  10328. /** defines the manager's name */
  10329. name: string;
  10330. /** Gets the list of sprites */
  10331. sprites: Sprite[];
  10332. /** Gets or sets the rendering group id (0 by default) */
  10333. renderingGroupId: number;
  10334. /** Gets or sets camera layer mask */
  10335. layerMask: number;
  10336. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10337. fogEnabled: boolean;
  10338. /** Gets or sets a boolean indicating if the sprites are pickable */
  10339. isPickable: boolean;
  10340. /** Defines the default width of a cell in the spritesheet */
  10341. cellWidth: number;
  10342. /** Defines the default height of a cell in the spritesheet */
  10343. cellHeight: number;
  10344. /**
  10345. * An event triggered when the manager is disposed.
  10346. */
  10347. onDisposeObservable: Observable<SpriteManager>;
  10348. private _onDisposeObserver;
  10349. /**
  10350. * Callback called when the manager is disposed
  10351. */
  10352. onDispose: () => void;
  10353. private _capacity;
  10354. private _spriteTexture;
  10355. private _epsilon;
  10356. private _scene;
  10357. private _vertexData;
  10358. private _buffer;
  10359. private _vertexBuffers;
  10360. private _indexBuffer;
  10361. private _effectBase;
  10362. private _effectFog;
  10363. /**
  10364. * Gets or sets the spritesheet texture
  10365. */
  10366. texture: Texture;
  10367. /**
  10368. * Creates a new sprite manager
  10369. * @param name defines the manager's name
  10370. * @param imgUrl defines the sprite sheet url
  10371. * @param capacity defines the maximum allowed number of sprites
  10372. * @param cellSize defines the size of a sprite cell
  10373. * @param scene defines the hosting scene
  10374. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10375. * @param samplingMode defines the smapling mode to use with spritesheet
  10376. */
  10377. constructor(
  10378. /** defines the manager's name */
  10379. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  10380. private _appendSpriteVertex;
  10381. /**
  10382. * Intersects the sprites with a ray
  10383. * @param ray defines the ray to intersect with
  10384. * @param camera defines the current active camera
  10385. * @param predicate defines a predicate used to select candidate sprites
  10386. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10387. * @returns null if no hit or a PickingInfo
  10388. */
  10389. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10390. /**
  10391. * Render all child sprites
  10392. */
  10393. render(): void;
  10394. /**
  10395. * Release associated resources
  10396. */
  10397. dispose(): void;
  10398. }
  10399. }
  10400. declare module "babylonjs/Sprites/sprite" {
  10401. import { Vector3, Color4 } from "babylonjs/Maths/math";
  10402. import { Nullable } from "babylonjs/types";
  10403. import { ActionManager } from "babylonjs/Actions/actionManager";
  10404. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10405. /**
  10406. * Class used to represent a sprite
  10407. * @see http://doc.babylonjs.com/babylon101/sprites
  10408. */
  10409. export class Sprite {
  10410. /** defines the name */
  10411. name: string;
  10412. /** Gets or sets the current world position */
  10413. position: Vector3;
  10414. /** Gets or sets the main color */
  10415. color: Color4;
  10416. /** Gets or sets the width */
  10417. width: number;
  10418. /** Gets or sets the height */
  10419. height: number;
  10420. /** Gets or sets rotation angle */
  10421. angle: number;
  10422. /** Gets or sets the cell index in the sprite sheet */
  10423. cellIndex: number;
  10424. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10425. invertU: number;
  10426. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10427. invertV: number;
  10428. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10429. disposeWhenFinishedAnimating: boolean;
  10430. /** Gets the list of attached animations */
  10431. animations: Animation[];
  10432. /** Gets or sets a boolean indicating if the sprite can be picked */
  10433. isPickable: boolean;
  10434. /**
  10435. * Gets or sets the associated action manager
  10436. */
  10437. actionManager: Nullable<ActionManager>;
  10438. private _animationStarted;
  10439. private _loopAnimation;
  10440. private _fromIndex;
  10441. private _toIndex;
  10442. private _delay;
  10443. private _direction;
  10444. private _manager;
  10445. private _time;
  10446. private _onAnimationEnd;
  10447. /**
  10448. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10449. */
  10450. isVisible: boolean;
  10451. /**
  10452. * Gets or sets the sprite size
  10453. */
  10454. size: number;
  10455. /**
  10456. * Creates a new Sprite
  10457. * @param name defines the name
  10458. * @param manager defines the manager
  10459. */
  10460. constructor(
  10461. /** defines the name */
  10462. name: string, manager: ISpriteManager);
  10463. /**
  10464. * Starts an animation
  10465. * @param from defines the initial key
  10466. * @param to defines the end key
  10467. * @param loop defines if the animation must loop
  10468. * @param delay defines the start delay (in ms)
  10469. * @param onAnimationEnd defines a callback to call when animation ends
  10470. */
  10471. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  10472. /** Stops current animation (if any) */
  10473. stopAnimation(): void;
  10474. /** @hidden */
  10475. _animate(deltaTime: number): void;
  10476. /** Release associated resources */
  10477. dispose(): void;
  10478. }
  10479. }
  10480. declare module "babylonjs/Collisions/pickingInfo" {
  10481. import { Nullable } from "babylonjs/types";
  10482. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  10483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10484. import { Ray } from "babylonjs/Culling/ray";
  10485. import { Sprite } from "babylonjs/Sprites/sprite";
  10486. /**
  10487. * @hidden
  10488. */
  10489. export class IntersectionInfo {
  10490. bu: Nullable<number>;
  10491. bv: Nullable<number>;
  10492. distance: number;
  10493. faceId: number;
  10494. subMeshId: number;
  10495. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  10496. }
  10497. /**
  10498. * Information about the result of picking within a scene
  10499. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10500. */
  10501. export class PickingInfo {
  10502. /**
  10503. * If the pick collided with an object
  10504. */
  10505. hit: boolean;
  10506. /**
  10507. * Distance away where the pick collided
  10508. */
  10509. distance: number;
  10510. /**
  10511. * The location of pick collision
  10512. */
  10513. pickedPoint: Nullable<Vector3>;
  10514. /**
  10515. * The mesh corresponding the the pick collision
  10516. */
  10517. pickedMesh: Nullable<AbstractMesh>;
  10518. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  10519. bu: number;
  10520. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  10521. bv: number;
  10522. /** The id of the face on the mesh that was picked */
  10523. faceId: number;
  10524. /** Id of the the submesh that was picked */
  10525. subMeshId: number;
  10526. /** If a sprite was picked, this will be the sprite the pick collided with */
  10527. pickedSprite: Nullable<Sprite>;
  10528. /**
  10529. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10530. */
  10531. originMesh: Nullable<AbstractMesh>;
  10532. /**
  10533. * The ray that was used to perform the picking.
  10534. */
  10535. ray: Nullable<Ray>;
  10536. /**
  10537. * Gets the normal correspodning to the face the pick collided with
  10538. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10539. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10540. * @returns The normal correspodning to the face the pick collided with
  10541. */
  10542. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10543. /**
  10544. * Gets the texture coordinates of where the pick occured
  10545. * @returns the vector containing the coordnates of the texture
  10546. */
  10547. getTextureCoordinates(): Nullable<Vector2>;
  10548. }
  10549. }
  10550. declare module "babylonjs/Events/pointerEvents" {
  10551. import { Nullable } from "babylonjs/types";
  10552. import { Vector2 } from "babylonjs/Maths/math";
  10553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10554. import { Ray } from "babylonjs/Culling/ray";
  10555. /**
  10556. * Gather the list of pointer event types as constants.
  10557. */
  10558. export class PointerEventTypes {
  10559. /**
  10560. * 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.
  10561. */
  10562. static readonly POINTERDOWN: number;
  10563. /**
  10564. * The pointerup event is fired when a pointer is no longer active.
  10565. */
  10566. static readonly POINTERUP: number;
  10567. /**
  10568. * The pointermove event is fired when a pointer changes coordinates.
  10569. */
  10570. static readonly POINTERMOVE: number;
  10571. /**
  10572. * The pointerwheel event is fired when a mouse wheel has been rotated.
  10573. */
  10574. static readonly POINTERWHEEL: number;
  10575. /**
  10576. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  10577. */
  10578. static readonly POINTERPICK: number;
  10579. /**
  10580. * The pointertap event is fired when a the object has been touched and released without drag.
  10581. */
  10582. static readonly POINTERTAP: number;
  10583. /**
  10584. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  10585. */
  10586. static readonly POINTERDOUBLETAP: number;
  10587. }
  10588. /**
  10589. * Base class of pointer info types.
  10590. */
  10591. export class PointerInfoBase {
  10592. /**
  10593. * Defines the type of event (PointerEventTypes)
  10594. */
  10595. type: number;
  10596. /**
  10597. * Defines the related dom event
  10598. */
  10599. event: PointerEvent | MouseWheelEvent;
  10600. /**
  10601. * Instantiates the base class of pointers info.
  10602. * @param type Defines the type of event (PointerEventTypes)
  10603. * @param event Defines the related dom event
  10604. */
  10605. constructor(
  10606. /**
  10607. * Defines the type of event (PointerEventTypes)
  10608. */
  10609. type: number,
  10610. /**
  10611. * Defines the related dom event
  10612. */
  10613. event: PointerEvent | MouseWheelEvent);
  10614. }
  10615. /**
  10616. * This class is used to store pointer related info for the onPrePointerObservable event.
  10617. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  10618. */
  10619. export class PointerInfoPre extends PointerInfoBase {
  10620. /**
  10621. * Ray from a pointer if availible (eg. 6dof controller)
  10622. */
  10623. ray: Nullable<Ray>;
  10624. /**
  10625. * Defines the local position of the pointer on the canvas.
  10626. */
  10627. localPosition: Vector2;
  10628. /**
  10629. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  10630. */
  10631. skipOnPointerObservable: boolean;
  10632. /**
  10633. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  10634. * @param type Defines the type of event (PointerEventTypes)
  10635. * @param event Defines the related dom event
  10636. * @param localX Defines the local x coordinates of the pointer when the event occured
  10637. * @param localY Defines the local y coordinates of the pointer when the event occured
  10638. */
  10639. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  10640. }
  10641. /**
  10642. * This type contains all the data related to a pointer event in Babylon.js.
  10643. * 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.
  10644. */
  10645. export class PointerInfo extends PointerInfoBase {
  10646. /**
  10647. * Defines the picking info associated to the info (if any)\
  10648. */
  10649. pickInfo: Nullable<PickingInfo>;
  10650. /**
  10651. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  10652. * @param type Defines the type of event (PointerEventTypes)
  10653. * @param event Defines the related dom event
  10654. * @param pickInfo Defines the picking info associated to the info (if any)\
  10655. */
  10656. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  10657. /**
  10658. * Defines the picking info associated to the info (if any)\
  10659. */
  10660. pickInfo: Nullable<PickingInfo>);
  10661. }
  10662. }
  10663. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  10664. import { Nullable } from "babylonjs/types";
  10665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10667. /**
  10668. * Manage the mouse inputs to control the movement of a free camera.
  10669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10670. */
  10671. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  10672. /**
  10673. * Define if touch is enabled in the mouse input
  10674. */
  10675. touchEnabled: boolean;
  10676. /**
  10677. * Defines the camera the input is attached to.
  10678. */
  10679. camera: FreeCamera;
  10680. /**
  10681. * Defines the buttons associated with the input to handle camera move.
  10682. */
  10683. buttons: number[];
  10684. /**
  10685. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  10686. */
  10687. angularSensibility: number;
  10688. private _pointerInput;
  10689. private _onMouseMove;
  10690. private _observer;
  10691. private previousPosition;
  10692. /**
  10693. * Manage the mouse inputs to control the movement of a free camera.
  10694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10695. * @param touchEnabled Defines if touch is enabled or not
  10696. */
  10697. constructor(
  10698. /**
  10699. * Define if touch is enabled in the mouse input
  10700. */
  10701. touchEnabled?: boolean);
  10702. /**
  10703. * Attach the input controls to a specific dom element to get the input from.
  10704. * @param element Defines the element the controls should be listened from
  10705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10706. */
  10707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  10708. /**
  10709. * Detach the current controls from the specified dom element.
  10710. * @param element Defines the element to stop listening the inputs from
  10711. */
  10712. detachControl(element: Nullable<HTMLElement>): void;
  10713. /**
  10714. * Gets the class name of the current intput.
  10715. * @returns the class name
  10716. */
  10717. getClassName(): string;
  10718. /**
  10719. * Get the friendly name associated with the input class.
  10720. * @returns the input friendly name
  10721. */
  10722. getSimpleName(): string;
  10723. }
  10724. }
  10725. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  10726. import { Nullable } from "babylonjs/types";
  10727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10729. /**
  10730. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  10731. * Screen rotation is taken into account.
  10732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10733. */
  10734. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  10735. private _camera;
  10736. private _screenOrientationAngle;
  10737. private _constantTranform;
  10738. private _screenQuaternion;
  10739. private _alpha;
  10740. private _beta;
  10741. private _gamma;
  10742. /**
  10743. * Instantiates a new input
  10744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10745. */
  10746. constructor();
  10747. /**
  10748. * Define the camera controlled by the input.
  10749. */
  10750. camera: FreeCamera;
  10751. /**
  10752. * Attach the input controls to a specific dom element to get the input from.
  10753. * @param element Defines the element the controls should be listened from
  10754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10755. */
  10756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  10757. private _orientationChanged;
  10758. private _deviceOrientation;
  10759. /**
  10760. * Detach the current controls from the specified dom element.
  10761. * @param element Defines the element to stop listening the inputs from
  10762. */
  10763. detachControl(element: Nullable<HTMLElement>): void;
  10764. /**
  10765. * Update the current camera state depending on the inputs that have been used this frame.
  10766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10767. */
  10768. checkInputs(): void;
  10769. /**
  10770. * Gets the class name of the current intput.
  10771. * @returns the class name
  10772. */
  10773. getClassName(): string;
  10774. /**
  10775. * Get the friendly name associated with the input class.
  10776. * @returns the input friendly name
  10777. */
  10778. getSimpleName(): string;
  10779. }
  10780. }
  10781. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  10782. import { Nullable } from "babylonjs/types";
  10783. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10784. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10785. /**
  10786. * Manage the touch inputs to control the movement of a free camera.
  10787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10788. */
  10789. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  10790. /**
  10791. * Defines the camera the input is attached to.
  10792. */
  10793. camera: FreeCamera;
  10794. /**
  10795. * Defines the touch sensibility for rotation.
  10796. * The higher the faster.
  10797. */
  10798. touchAngularSensibility: number;
  10799. /**
  10800. * Defines the touch sensibility for move.
  10801. * The higher the faster.
  10802. */
  10803. touchMoveSensibility: number;
  10804. private _offsetX;
  10805. private _offsetY;
  10806. private _pointerPressed;
  10807. private _pointerInput;
  10808. private _observer;
  10809. private _onLostFocus;
  10810. /**
  10811. * Attach the input controls to a specific dom element to get the input from.
  10812. * @param element Defines the element the controls should be listened from
  10813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10814. */
  10815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  10816. /**
  10817. * Detach the current controls from the specified dom element.
  10818. * @param element Defines the element to stop listening the inputs from
  10819. */
  10820. detachControl(element: Nullable<HTMLElement>): void;
  10821. /**
  10822. * Update the current camera state depending on the inputs that have been used this frame.
  10823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10824. */
  10825. checkInputs(): void;
  10826. /**
  10827. * Gets the class name of the current intput.
  10828. * @returns the class name
  10829. */
  10830. getClassName(): string;
  10831. /**
  10832. * Get the friendly name associated with the input class.
  10833. * @returns the input friendly name
  10834. */
  10835. getSimpleName(): string;
  10836. }
  10837. }
  10838. declare module "babylonjs/Misc/virtualJoystick" {
  10839. import { Nullable } from "babylonjs/types";
  10840. import { Vector3 } from "babylonjs/Maths/math";
  10841. /**
  10842. * Defines the potential axis of a Joystick
  10843. */
  10844. export enum JoystickAxis {
  10845. /** X axis */
  10846. X = 0,
  10847. /** Y axis */
  10848. Y = 1,
  10849. /** Z axis */
  10850. Z = 2
  10851. }
  10852. /**
  10853. * Class used to define virtual joystick (used in touch mode)
  10854. */
  10855. export class VirtualJoystick {
  10856. /**
  10857. * Gets or sets a boolean indicating that left and right values must be inverted
  10858. */
  10859. reverseLeftRight: boolean;
  10860. /**
  10861. * Gets or sets a boolean indicating that up and down values must be inverted
  10862. */
  10863. reverseUpDown: boolean;
  10864. /**
  10865. * Gets the offset value for the position (ie. the change of the position value)
  10866. */
  10867. deltaPosition: Vector3;
  10868. /**
  10869. * Gets a boolean indicating if the virtual joystick was pressed
  10870. */
  10871. pressed: boolean;
  10872. /**
  10873. * Canvas the virtual joystick will render onto, default z-index of this is 5
  10874. */
  10875. static Canvas: Nullable<HTMLCanvasElement>;
  10876. private static _globalJoystickIndex;
  10877. private static vjCanvasContext;
  10878. private static vjCanvasWidth;
  10879. private static vjCanvasHeight;
  10880. private static halfWidth;
  10881. private _action;
  10882. private _axisTargetedByLeftAndRight;
  10883. private _axisTargetedByUpAndDown;
  10884. private _joystickSensibility;
  10885. private _inversedSensibility;
  10886. private _joystickPointerID;
  10887. private _joystickColor;
  10888. private _joystickPointerPos;
  10889. private _joystickPreviousPointerPos;
  10890. private _joystickPointerStartPos;
  10891. private _deltaJoystickVector;
  10892. private _leftJoystick;
  10893. private _touches;
  10894. private _onPointerDownHandlerRef;
  10895. private _onPointerMoveHandlerRef;
  10896. private _onPointerUpHandlerRef;
  10897. private _onResize;
  10898. /**
  10899. * Creates a new virtual joystick
  10900. * @param leftJoystick defines that the joystick is for left hand (false by default)
  10901. */
  10902. constructor(leftJoystick?: boolean);
  10903. /**
  10904. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  10905. * @param newJoystickSensibility defines the new sensibility
  10906. */
  10907. setJoystickSensibility(newJoystickSensibility: number): void;
  10908. private _onPointerDown;
  10909. private _onPointerMove;
  10910. private _onPointerUp;
  10911. /**
  10912. * Change the color of the virtual joystick
  10913. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  10914. */
  10915. setJoystickColor(newColor: string): void;
  10916. /**
  10917. * Defines a callback to call when the joystick is touched
  10918. * @param action defines the callback
  10919. */
  10920. setActionOnTouch(action: () => any): void;
  10921. /**
  10922. * Defines which axis you'd like to control for left & right
  10923. * @param axis defines the axis to use
  10924. */
  10925. setAxisForLeftRight(axis: JoystickAxis): void;
  10926. /**
  10927. * Defines which axis you'd like to control for up & down
  10928. * @param axis defines the axis to use
  10929. */
  10930. setAxisForUpDown(axis: JoystickAxis): void;
  10931. private _drawVirtualJoystick;
  10932. /**
  10933. * Release internal HTML canvas
  10934. */
  10935. releaseCanvas(): void;
  10936. }
  10937. }
  10938. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  10939. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  10940. import { Nullable } from "babylonjs/types";
  10941. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10942. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10943. /**
  10944. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  10945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10946. */
  10947. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  10948. /**
  10949. * Defines the camera the input is attached to.
  10950. */
  10951. camera: FreeCamera;
  10952. private _leftjoystick;
  10953. private _rightjoystick;
  10954. /**
  10955. * Gets the left stick of the virtual joystick.
  10956. * @returns The virtual Joystick
  10957. */
  10958. getLeftJoystick(): VirtualJoystick;
  10959. /**
  10960. * Gets the right stick of the virtual joystick.
  10961. * @returns The virtual Joystick
  10962. */
  10963. getRightJoystick(): VirtualJoystick;
  10964. /**
  10965. * Update the current camera state depending on the inputs that have been used this frame.
  10966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10967. */
  10968. checkInputs(): void;
  10969. /**
  10970. * Attach the input controls to a specific dom element to get the input from.
  10971. * @param element Defines the element the controls should be listened from
  10972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10973. */
  10974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  10975. /**
  10976. * Detach the current controls from the specified dom element.
  10977. * @param element Defines the element to stop listening the inputs from
  10978. */
  10979. detachControl(element: Nullable<HTMLElement>): void;
  10980. /**
  10981. * Gets the class name of the current intput.
  10982. * @returns the class name
  10983. */
  10984. getClassName(): string;
  10985. /**
  10986. * Get the friendly name associated with the input class.
  10987. * @returns the input friendly name
  10988. */
  10989. getSimpleName(): string;
  10990. }
  10991. }
  10992. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  10993. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10994. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  10995. /**
  10996. * Default Inputs manager for the FreeCamera.
  10997. * It groups all the default supported inputs for ease of use.
  10998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  10999. */
  11000. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11001. /**
  11002. * Instantiates a new FreeCameraInputsManager.
  11003. * @param camera Defines the camera the inputs belong to
  11004. */
  11005. constructor(camera: FreeCamera);
  11006. /**
  11007. * Add keyboard input support to the input manager.
  11008. * @returns the current input manager
  11009. */
  11010. addKeyboard(): FreeCameraInputsManager;
  11011. /**
  11012. * Add mouse input support to the input manager.
  11013. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11014. * @returns the current input manager
  11015. */
  11016. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11017. /**
  11018. * Add orientation input support to the input manager.
  11019. * @returns the current input manager
  11020. */
  11021. addDeviceOrientation(): FreeCameraInputsManager;
  11022. /**
  11023. * Add touch input support to the input manager.
  11024. * @returns the current input manager
  11025. */
  11026. addTouch(): FreeCameraInputsManager;
  11027. /**
  11028. * Add virtual joystick input support to the input manager.
  11029. * @returns the current input manager
  11030. */
  11031. addVirtualJoystick(): FreeCameraInputsManager;
  11032. }
  11033. }
  11034. declare module "babylonjs/Cameras/freeCamera" {
  11035. import { Vector3 } from "babylonjs/Maths/math";
  11036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11037. import { Scene } from "babylonjs/scene";
  11038. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  11039. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  11040. /**
  11041. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11042. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11043. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11044. */
  11045. export class FreeCamera extends TargetCamera {
  11046. /**
  11047. * Define the collision ellipsoid of the camera.
  11048. * This is helpful to simulate a camera body like the player body around the camera
  11049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11050. */
  11051. ellipsoid: Vector3;
  11052. /**
  11053. * Define an offset for the position of the ellipsoid around the camera.
  11054. * This can be helpful to determine the center of the body near the gravity center of the body
  11055. * instead of its head.
  11056. */
  11057. ellipsoidOffset: Vector3;
  11058. /**
  11059. * Enable or disable collisions of the camera with the rest of the scene objects.
  11060. */
  11061. checkCollisions: boolean;
  11062. /**
  11063. * Enable or disable gravity on the camera.
  11064. */
  11065. applyGravity: boolean;
  11066. /**
  11067. * Define the input manager associated to the camera.
  11068. */
  11069. inputs: FreeCameraInputsManager;
  11070. /**
  11071. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11072. * Higher values reduce sensitivity.
  11073. */
  11074. /**
  11075. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11076. * Higher values reduce sensitivity.
  11077. */
  11078. angularSensibility: number;
  11079. /**
  11080. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11081. */
  11082. keysUp: number[];
  11083. /**
  11084. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11085. */
  11086. keysDown: number[];
  11087. /**
  11088. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11089. */
  11090. keysLeft: number[];
  11091. /**
  11092. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11093. */
  11094. keysRight: number[];
  11095. /**
  11096. * Event raised when the camera collide with a mesh in the scene.
  11097. */
  11098. onCollide: (collidedMesh: AbstractMesh) => void;
  11099. private _collider;
  11100. private _needMoveForGravity;
  11101. private _oldPosition;
  11102. private _diffPosition;
  11103. private _newPosition;
  11104. /** @hidden */
  11105. _localDirection: Vector3;
  11106. /** @hidden */
  11107. _transformedDirection: Vector3;
  11108. /**
  11109. * Instantiates a Free Camera.
  11110. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11111. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11112. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11113. * @param name Define the name of the camera in the scene
  11114. * @param position Define the start position of the camera in the scene
  11115. * @param scene Define the scene the camera belongs to
  11116. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11117. */
  11118. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11119. /**
  11120. * Attached controls to the current camera.
  11121. * @param element Defines the element the controls should be listened from
  11122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11123. */
  11124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11125. /**
  11126. * Detach the current controls from the camera.
  11127. * The camera will stop reacting to inputs.
  11128. * @param element Defines the element to stop listening the inputs from
  11129. */
  11130. detachControl(element: HTMLElement): void;
  11131. private _collisionMask;
  11132. /**
  11133. * Define a collision mask to limit the list of object the camera can collide with
  11134. */
  11135. collisionMask: number;
  11136. /** @hidden */
  11137. _collideWithWorld(displacement: Vector3): void;
  11138. private _onCollisionPositionChange;
  11139. /** @hidden */
  11140. _checkInputs(): void;
  11141. /** @hidden */
  11142. _decideIfNeedsToMove(): boolean;
  11143. /** @hidden */
  11144. _updatePosition(): void;
  11145. /**
  11146. * Destroy the camera and release the current resources hold by it.
  11147. */
  11148. dispose(): void;
  11149. /**
  11150. * Gets the current object class name.
  11151. * @return the class name
  11152. */
  11153. getClassName(): string;
  11154. }
  11155. }
  11156. declare module "babylonjs/Gamepads/gamepad" {
  11157. import { Observable } from "babylonjs/Misc/observable";
  11158. /**
  11159. * Represents a gamepad control stick position
  11160. */
  11161. export class StickValues {
  11162. /**
  11163. * The x component of the control stick
  11164. */
  11165. x: number;
  11166. /**
  11167. * The y component of the control stick
  11168. */
  11169. y: number;
  11170. /**
  11171. * Initializes the gamepad x and y control stick values
  11172. * @param x The x component of the gamepad control stick value
  11173. * @param y The y component of the gamepad control stick value
  11174. */
  11175. constructor(
  11176. /**
  11177. * The x component of the control stick
  11178. */
  11179. x: number,
  11180. /**
  11181. * The y component of the control stick
  11182. */
  11183. y: number);
  11184. }
  11185. /**
  11186. * An interface which manages callbacks for gamepad button changes
  11187. */
  11188. export interface GamepadButtonChanges {
  11189. /**
  11190. * Called when a gamepad has been changed
  11191. */
  11192. changed: boolean;
  11193. /**
  11194. * Called when a gamepad press event has been triggered
  11195. */
  11196. pressChanged: boolean;
  11197. /**
  11198. * Called when a touch event has been triggered
  11199. */
  11200. touchChanged: boolean;
  11201. /**
  11202. * Called when a value has changed
  11203. */
  11204. valueChanged: boolean;
  11205. }
  11206. /**
  11207. * Represents a gamepad
  11208. */
  11209. export class Gamepad {
  11210. /**
  11211. * The id of the gamepad
  11212. */
  11213. id: string;
  11214. /**
  11215. * The index of the gamepad
  11216. */
  11217. index: number;
  11218. /**
  11219. * The browser gamepad
  11220. */
  11221. browserGamepad: any;
  11222. /**
  11223. * Specifies what type of gamepad this represents
  11224. */
  11225. type: number;
  11226. private _leftStick;
  11227. private _rightStick;
  11228. /** @hidden */
  11229. _isConnected: boolean;
  11230. private _leftStickAxisX;
  11231. private _leftStickAxisY;
  11232. private _rightStickAxisX;
  11233. private _rightStickAxisY;
  11234. /**
  11235. * Triggered when the left control stick has been changed
  11236. */
  11237. private _onleftstickchanged;
  11238. /**
  11239. * Triggered when the right control stick has been changed
  11240. */
  11241. private _onrightstickchanged;
  11242. /**
  11243. * Represents a gamepad controller
  11244. */
  11245. static GAMEPAD: number;
  11246. /**
  11247. * Represents a generic controller
  11248. */
  11249. static GENERIC: number;
  11250. /**
  11251. * Represents an XBox controller
  11252. */
  11253. static XBOX: number;
  11254. /**
  11255. * Represents a pose-enabled controller
  11256. */
  11257. static POSE_ENABLED: number;
  11258. /**
  11259. * Specifies whether the left control stick should be Y-inverted
  11260. */
  11261. protected _invertLeftStickY: boolean;
  11262. /**
  11263. * Specifies if the gamepad has been connected
  11264. */
  11265. readonly isConnected: boolean;
  11266. /**
  11267. * Initializes the gamepad
  11268. * @param id The id of the gamepad
  11269. * @param index The index of the gamepad
  11270. * @param browserGamepad The browser gamepad
  11271. * @param leftStickX The x component of the left joystick
  11272. * @param leftStickY The y component of the left joystick
  11273. * @param rightStickX The x component of the right joystick
  11274. * @param rightStickY The y component of the right joystick
  11275. */
  11276. constructor(
  11277. /**
  11278. * The id of the gamepad
  11279. */
  11280. id: string,
  11281. /**
  11282. * The index of the gamepad
  11283. */
  11284. index: number,
  11285. /**
  11286. * The browser gamepad
  11287. */
  11288. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11289. /**
  11290. * Callback triggered when the left joystick has changed
  11291. * @param callback
  11292. */
  11293. onleftstickchanged(callback: (values: StickValues) => void): void;
  11294. /**
  11295. * Callback triggered when the right joystick has changed
  11296. * @param callback
  11297. */
  11298. onrightstickchanged(callback: (values: StickValues) => void): void;
  11299. /**
  11300. * Gets the left joystick
  11301. */
  11302. /**
  11303. * Sets the left joystick values
  11304. */
  11305. leftStick: StickValues;
  11306. /**
  11307. * Gets the right joystick
  11308. */
  11309. /**
  11310. * Sets the right joystick value
  11311. */
  11312. rightStick: StickValues;
  11313. /**
  11314. * Updates the gamepad joystick positions
  11315. */
  11316. update(): void;
  11317. /**
  11318. * Disposes the gamepad
  11319. */
  11320. dispose(): void;
  11321. }
  11322. /**
  11323. * Represents a generic gamepad
  11324. */
  11325. export class GenericPad extends Gamepad {
  11326. private _buttons;
  11327. private _onbuttondown;
  11328. private _onbuttonup;
  11329. /**
  11330. * Observable triggered when a button has been pressed
  11331. */
  11332. onButtonDownObservable: Observable<number>;
  11333. /**
  11334. * Observable triggered when a button has been released
  11335. */
  11336. onButtonUpObservable: Observable<number>;
  11337. /**
  11338. * Callback triggered when a button has been pressed
  11339. * @param callback Called when a button has been pressed
  11340. */
  11341. onbuttondown(callback: (buttonPressed: number) => void): void;
  11342. /**
  11343. * Callback triggered when a button has been released
  11344. * @param callback Called when a button has been released
  11345. */
  11346. onbuttonup(callback: (buttonReleased: number) => void): void;
  11347. /**
  11348. * Initializes the generic gamepad
  11349. * @param id The id of the generic gamepad
  11350. * @param index The index of the generic gamepad
  11351. * @param browserGamepad The browser gamepad
  11352. */
  11353. constructor(id: string, index: number, browserGamepad: any);
  11354. private _setButtonValue;
  11355. /**
  11356. * Updates the generic gamepad
  11357. */
  11358. update(): void;
  11359. /**
  11360. * Disposes the generic gamepad
  11361. */
  11362. dispose(): void;
  11363. }
  11364. }
  11365. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  11366. import { Observable } from "babylonjs/Misc/observable";
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  11369. import { TransformNode } from "babylonjs/Meshes/transformNode";
  11370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11371. import { Ray } from "babylonjs/Culling/ray";
  11372. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  11373. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  11374. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  11375. /**
  11376. * Defines the types of pose enabled controllers that are supported
  11377. */
  11378. export enum PoseEnabledControllerType {
  11379. /**
  11380. * HTC Vive
  11381. */
  11382. VIVE = 0,
  11383. /**
  11384. * Oculus Rift
  11385. */
  11386. OCULUS = 1,
  11387. /**
  11388. * Windows mixed reality
  11389. */
  11390. WINDOWS = 2,
  11391. /**
  11392. * Samsung gear VR
  11393. */
  11394. GEAR_VR = 3,
  11395. /**
  11396. * Google Daydream
  11397. */
  11398. DAYDREAM = 4,
  11399. /**
  11400. * Generic
  11401. */
  11402. GENERIC = 5
  11403. }
  11404. /**
  11405. * Defines the MutableGamepadButton interface for the state of a gamepad button
  11406. */
  11407. export interface MutableGamepadButton {
  11408. /**
  11409. * Value of the button/trigger
  11410. */
  11411. value: number;
  11412. /**
  11413. * If the button/trigger is currently touched
  11414. */
  11415. touched: boolean;
  11416. /**
  11417. * If the button/trigger is currently pressed
  11418. */
  11419. pressed: boolean;
  11420. }
  11421. /**
  11422. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  11423. * @hidden
  11424. */
  11425. export interface ExtendedGamepadButton extends GamepadButton {
  11426. /**
  11427. * If the button/trigger is currently pressed
  11428. */
  11429. readonly pressed: boolean;
  11430. /**
  11431. * If the button/trigger is currently touched
  11432. */
  11433. readonly touched: boolean;
  11434. /**
  11435. * Value of the button/trigger
  11436. */
  11437. readonly value: number;
  11438. }
  11439. /** @hidden */
  11440. export interface _GamePadFactory {
  11441. /**
  11442. * Returns wether or not the current gamepad can be created for this type of controller.
  11443. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  11444. * @returns true if it can be created, otherwise false
  11445. */
  11446. canCreate(gamepadInfo: any): boolean;
  11447. /**
  11448. * Creates a new instance of the Gamepad.
  11449. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  11450. * @returns the new gamepad instance
  11451. */
  11452. create(gamepadInfo: any): Gamepad;
  11453. }
  11454. /**
  11455. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  11456. */
  11457. export class PoseEnabledControllerHelper {
  11458. /** @hidden */
  11459. static _ControllerFactories: _GamePadFactory[];
  11460. /** @hidden */
  11461. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  11462. /**
  11463. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  11464. * @param vrGamepad the gamepad to initialized
  11465. * @returns a vr controller of the type the gamepad identified as
  11466. */
  11467. static InitiateController(vrGamepad: any): Gamepad;
  11468. }
  11469. /**
  11470. * Defines the PoseEnabledController object that contains state of a vr capable controller
  11471. */
  11472. export class PoseEnabledController extends Gamepad implements PoseControlled {
  11473. private _deviceRoomPosition;
  11474. private _deviceRoomRotationQuaternion;
  11475. /**
  11476. * The device position in babylon space
  11477. */
  11478. devicePosition: Vector3;
  11479. /**
  11480. * The device rotation in babylon space
  11481. */
  11482. deviceRotationQuaternion: Quaternion;
  11483. /**
  11484. * The scale factor of the device in babylon space
  11485. */
  11486. deviceScaleFactor: number;
  11487. /**
  11488. * (Likely devicePosition should be used instead) The device position in its room space
  11489. */
  11490. position: Vector3;
  11491. /**
  11492. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  11493. */
  11494. rotationQuaternion: Quaternion;
  11495. /**
  11496. * The type of controller (Eg. Windows mixed reality)
  11497. */
  11498. controllerType: PoseEnabledControllerType;
  11499. protected _calculatedPosition: Vector3;
  11500. private _calculatedRotation;
  11501. /**
  11502. * The raw pose from the device
  11503. */
  11504. rawPose: DevicePose;
  11505. private _trackPosition;
  11506. private _maxRotationDistFromHeadset;
  11507. private _draggedRoomRotation;
  11508. /**
  11509. * @hidden
  11510. */
  11511. _disableTrackPosition(fixedPosition: Vector3): void;
  11512. /**
  11513. * Internal, the mesh attached to the controller
  11514. * @hidden
  11515. */
  11516. _mesh: Nullable<AbstractMesh>;
  11517. private _poseControlledCamera;
  11518. private _leftHandSystemQuaternion;
  11519. /**
  11520. * Internal, matrix used to convert room space to babylon space
  11521. * @hidden
  11522. */
  11523. _deviceToWorld: Matrix;
  11524. /**
  11525. * Node to be used when casting a ray from the controller
  11526. * @hidden
  11527. */
  11528. _pointingPoseNode: Nullable<TransformNode>;
  11529. /**
  11530. * Name of the child mesh that can be used to cast a ray from the controller
  11531. */
  11532. static readonly POINTING_POSE: string;
  11533. /**
  11534. * Creates a new PoseEnabledController from a gamepad
  11535. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  11536. */
  11537. constructor(browserGamepad: any);
  11538. private _workingMatrix;
  11539. /**
  11540. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  11541. */
  11542. update(): void;
  11543. /**
  11544. * Updates only the pose device and mesh without doing any button event checking
  11545. */
  11546. protected _updatePoseAndMesh(): void;
  11547. /**
  11548. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  11549. * @param poseData raw pose fromthe device
  11550. */
  11551. updateFromDevice(poseData: DevicePose): void;
  11552. /**
  11553. * @hidden
  11554. */
  11555. _meshAttachedObservable: Observable<AbstractMesh>;
  11556. /**
  11557. * Attaches a mesh to the controller
  11558. * @param mesh the mesh to be attached
  11559. */
  11560. attachToMesh(mesh: AbstractMesh): void;
  11561. /**
  11562. * Attaches the controllers mesh to a camera
  11563. * @param camera the camera the mesh should be attached to
  11564. */
  11565. attachToPoseControlledCamera(camera: TargetCamera): void;
  11566. /**
  11567. * Disposes of the controller
  11568. */
  11569. dispose(): void;
  11570. /**
  11571. * The mesh that is attached to the controller
  11572. */
  11573. readonly mesh: Nullable<AbstractMesh>;
  11574. /**
  11575. * Gets the ray of the controller in the direction the controller is pointing
  11576. * @param length the length the resulting ray should be
  11577. * @returns a ray in the direction the controller is pointing
  11578. */
  11579. getForwardRay(length?: number): Ray;
  11580. }
  11581. }
  11582. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  11583. import { Observable } from "babylonjs/Misc/observable";
  11584. import { Scene } from "babylonjs/scene";
  11585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11586. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  11587. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  11588. /**
  11589. * Defines the WebVRController object that represents controllers tracked in 3D space
  11590. */
  11591. export abstract class WebVRController extends PoseEnabledController {
  11592. /**
  11593. * Internal, the default controller model for the controller
  11594. */
  11595. protected _defaultModel: AbstractMesh;
  11596. /**
  11597. * Fired when the trigger state has changed
  11598. */
  11599. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  11600. /**
  11601. * Fired when the main button state has changed
  11602. */
  11603. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  11604. /**
  11605. * Fired when the secondary button state has changed
  11606. */
  11607. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  11608. /**
  11609. * Fired when the pad state has changed
  11610. */
  11611. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  11612. /**
  11613. * Fired when controllers stick values have changed
  11614. */
  11615. onPadValuesChangedObservable: Observable<StickValues>;
  11616. /**
  11617. * Array of button availible on the controller
  11618. */
  11619. protected _buttons: Array<MutableGamepadButton>;
  11620. private _onButtonStateChange;
  11621. /**
  11622. * Fired when a controller button's state has changed
  11623. * @param callback the callback containing the button that was modified
  11624. */
  11625. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  11626. /**
  11627. * X and Y axis corrisponding to the controllers joystick
  11628. */
  11629. pad: StickValues;
  11630. /**
  11631. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  11632. */
  11633. hand: string;
  11634. /**
  11635. * The default controller model for the controller
  11636. */
  11637. readonly defaultModel: AbstractMesh;
  11638. /**
  11639. * Creates a new WebVRController from a gamepad
  11640. * @param vrGamepad the gamepad that the WebVRController should be created from
  11641. */
  11642. constructor(vrGamepad: any);
  11643. /**
  11644. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  11645. */
  11646. update(): void;
  11647. /**
  11648. * Function to be called when a button is modified
  11649. */
  11650. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  11651. /**
  11652. * Loads a mesh and attaches it to the controller
  11653. * @param scene the scene the mesh should be added to
  11654. * @param meshLoaded callback for when the mesh has been loaded
  11655. */
  11656. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  11657. private _setButtonValue;
  11658. private _changes;
  11659. private _checkChanges;
  11660. /**
  11661. * Disposes of th webVRCOntroller
  11662. */
  11663. dispose(): void;
  11664. }
  11665. }
  11666. declare module "babylonjs/Lights/hemisphericLight" {
  11667. import { Nullable } from "babylonjs/types";
  11668. import { Scene } from "babylonjs/scene";
  11669. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  11670. import { Effect } from "babylonjs/Materials/effect";
  11671. import { Light } from "babylonjs/Lights/light";
  11672. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11673. /**
  11674. * The HemisphericLight simulates the ambient environment light,
  11675. * so the passed direction is the light reflection direction, not the incoming direction.
  11676. */
  11677. export class HemisphericLight extends Light {
  11678. /**
  11679. * The groundColor is the light in the opposite direction to the one specified during creation.
  11680. * 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.
  11681. */
  11682. groundColor: Color3;
  11683. /**
  11684. * The light reflection direction, not the incoming direction.
  11685. */
  11686. direction: Vector3;
  11687. /**
  11688. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11689. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11690. * The HemisphericLight can't cast shadows.
  11691. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11692. * @param name The friendly name of the light
  11693. * @param direction The direction of the light reflection
  11694. * @param scene The scene the light belongs to
  11695. */
  11696. constructor(name: string, direction: Vector3, scene: Scene);
  11697. protected _buildUniformLayout(): void;
  11698. /**
  11699. * Returns the string "HemisphericLight".
  11700. * @return The class name
  11701. */
  11702. getClassName(): string;
  11703. /**
  11704. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11705. * Returns the updated direction.
  11706. * @param target The target the direction should point to
  11707. * @return The computed direction
  11708. */
  11709. setDirectionToTarget(target: Vector3): Vector3;
  11710. /**
  11711. * Returns the shadow generator associated to the light.
  11712. * @returns Always null for hemispheric lights because it does not support shadows.
  11713. */
  11714. getShadowGenerator(): Nullable<IShadowGenerator>;
  11715. /**
  11716. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11717. * @param effect The effect to update
  11718. * @param lightIndex The index of the light in the effect to update
  11719. * @returns The hemispheric light
  11720. */
  11721. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11722. /**
  11723. * Computes the world matrix of the node
  11724. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11725. * @param useWasUpdatedFlag defines a reserved property
  11726. * @returns the world matrix
  11727. */
  11728. computeWorldMatrix(): Matrix;
  11729. /**
  11730. * Returns the integer 3.
  11731. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11732. */
  11733. getTypeID(): number;
  11734. /**
  11735. * Prepares the list of defines specific to the light type.
  11736. * @param defines the list of defines
  11737. * @param lightIndex defines the index of the light for the effect
  11738. */
  11739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11740. }
  11741. }
  11742. declare module "babylonjs/Cameras/VR/webVRCamera" {
  11743. import { Nullable } from "babylonjs/types";
  11744. import { Observable } from "babylonjs/Misc/observable";
  11745. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11746. import { Scene } from "babylonjs/scene";
  11747. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  11748. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  11749. import { Node } from "babylonjs/node";
  11750. import { Ray } from "babylonjs/Culling/ray";
  11751. /**
  11752. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11753. * IMPORTANT!! The data is right-hand data.
  11754. * @export
  11755. * @interface DevicePose
  11756. */
  11757. export interface DevicePose {
  11758. /**
  11759. * The position of the device, values in array are [x,y,z].
  11760. */
  11761. readonly position: Nullable<Float32Array>;
  11762. /**
  11763. * The linearVelocity of the device, values in array are [x,y,z].
  11764. */
  11765. readonly linearVelocity: Nullable<Float32Array>;
  11766. /**
  11767. * The linearAcceleration of the device, values in array are [x,y,z].
  11768. */
  11769. readonly linearAcceleration: Nullable<Float32Array>;
  11770. /**
  11771. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11772. */
  11773. readonly orientation: Nullable<Float32Array>;
  11774. /**
  11775. * The angularVelocity of the device, values in array are [x,y,z].
  11776. */
  11777. readonly angularVelocity: Nullable<Float32Array>;
  11778. /**
  11779. * The angularAcceleration of the device, values in array are [x,y,z].
  11780. */
  11781. readonly angularAcceleration: Nullable<Float32Array>;
  11782. }
  11783. /**
  11784. * Interface representing a pose controlled object in Babylon.
  11785. * A pose controlled object has both regular pose values as well as pose values
  11786. * from an external device such as a VR head mounted display
  11787. */
  11788. export interface PoseControlled {
  11789. /**
  11790. * The position of the object in babylon space.
  11791. */
  11792. position: Vector3;
  11793. /**
  11794. * The rotation quaternion of the object in babylon space.
  11795. */
  11796. rotationQuaternion: Quaternion;
  11797. /**
  11798. * The position of the device in babylon space.
  11799. */
  11800. devicePosition?: Vector3;
  11801. /**
  11802. * The rotation quaternion of the device in babylon space.
  11803. */
  11804. deviceRotationQuaternion: Quaternion;
  11805. /**
  11806. * The raw pose coming from the device.
  11807. */
  11808. rawPose: Nullable<DevicePose>;
  11809. /**
  11810. * The scale of the device to be used when translating from device space to babylon space.
  11811. */
  11812. deviceScaleFactor: number;
  11813. /**
  11814. * Updates the poseControlled values based on the input device pose.
  11815. * @param poseData the pose data to update the object with
  11816. */
  11817. updateFromDevice(poseData: DevicePose): void;
  11818. }
  11819. /**
  11820. * Set of options to customize the webVRCamera
  11821. */
  11822. export interface WebVROptions {
  11823. /**
  11824. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11825. */
  11826. trackPosition?: boolean;
  11827. /**
  11828. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11829. */
  11830. positionScale?: number;
  11831. /**
  11832. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11833. */
  11834. displayName?: string;
  11835. /**
  11836. * Should the native controller meshes be initialized. (default: true)
  11837. */
  11838. controllerMeshes?: boolean;
  11839. /**
  11840. * Creating a default HemiLight only on controllers. (default: true)
  11841. */
  11842. defaultLightingOnControllers?: boolean;
  11843. /**
  11844. * If you don't want to use the default VR button of the helper. (default: false)
  11845. */
  11846. useCustomVRButton?: boolean;
  11847. /**
  11848. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11849. */
  11850. customVRButton?: HTMLButtonElement;
  11851. /**
  11852. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11853. */
  11854. rayLength?: number;
  11855. /**
  11856. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11857. */
  11858. defaultHeight?: number;
  11859. }
  11860. /**
  11861. * This represents a WebVR camera.
  11862. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11863. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11864. */
  11865. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11866. private webVROptions;
  11867. /**
  11868. * @hidden
  11869. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11870. */
  11871. _vrDevice: any;
  11872. /**
  11873. * The rawPose of the vrDevice.
  11874. */
  11875. rawPose: Nullable<DevicePose>;
  11876. private _onVREnabled;
  11877. private _specsVersion;
  11878. private _attached;
  11879. private _frameData;
  11880. protected _descendants: Array<Node>;
  11881. private _deviceRoomPosition;
  11882. /** @hidden */
  11883. _deviceRoomRotationQuaternion: Quaternion;
  11884. private _standingMatrix;
  11885. /**
  11886. * Represents device position in babylon space.
  11887. */
  11888. devicePosition: Vector3;
  11889. /**
  11890. * Represents device rotation in babylon space.
  11891. */
  11892. deviceRotationQuaternion: Quaternion;
  11893. /**
  11894. * The scale of the device to be used when translating from device space to babylon space.
  11895. */
  11896. deviceScaleFactor: number;
  11897. private _deviceToWorld;
  11898. private _worldToDevice;
  11899. /**
  11900. * References to the webVR controllers for the vrDevice.
  11901. */
  11902. controllers: Array<WebVRController>;
  11903. /**
  11904. * Emits an event when a controller is attached.
  11905. */
  11906. onControllersAttachedObservable: Observable<WebVRController[]>;
  11907. /**
  11908. * Emits an event when a controller's mesh has been loaded;
  11909. */
  11910. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11911. /**
  11912. * Emits an event when the HMD's pose has been updated.
  11913. */
  11914. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11915. private _poseSet;
  11916. /**
  11917. * If the rig cameras be used as parent instead of this camera.
  11918. */
  11919. rigParenting: boolean;
  11920. private _lightOnControllers;
  11921. private _defaultHeight?;
  11922. /**
  11923. * Instantiates a WebVRFreeCamera.
  11924. * @param name The name of the WebVRFreeCamera
  11925. * @param position The starting anchor position for the camera
  11926. * @param scene The scene the camera belongs to
  11927. * @param webVROptions a set of customizable options for the webVRCamera
  11928. */
  11929. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11930. /**
  11931. * Gets the device distance from the ground in meters.
  11932. * @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.
  11933. */
  11934. deviceDistanceToRoomGround(): number;
  11935. /**
  11936. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11937. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11938. */
  11939. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11940. /**
  11941. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11942. * @returns A promise with a boolean set to if the standing matrix is supported.
  11943. */
  11944. useStandingMatrixAsync(): Promise<boolean>;
  11945. /**
  11946. * Disposes the camera
  11947. */
  11948. dispose(): void;
  11949. /**
  11950. * Gets a vrController by name.
  11951. * @param name The name of the controller to retreive
  11952. * @returns the controller matching the name specified or null if not found
  11953. */
  11954. getControllerByName(name: string): Nullable<WebVRController>;
  11955. private _leftController;
  11956. /**
  11957. * The controller corrisponding to the users left hand.
  11958. */
  11959. readonly leftController: Nullable<WebVRController>;
  11960. private _rightController;
  11961. /**
  11962. * The controller corrisponding to the users right hand.
  11963. */
  11964. readonly rightController: Nullable<WebVRController>;
  11965. /**
  11966. * Casts a ray forward from the vrCamera's gaze.
  11967. * @param length Length of the ray (default: 100)
  11968. * @returns the ray corrisponding to the gaze
  11969. */
  11970. getForwardRay(length?: number): Ray;
  11971. /**
  11972. * @hidden
  11973. * Updates the camera based on device's frame data
  11974. */
  11975. _checkInputs(): void;
  11976. /**
  11977. * Updates the poseControlled values based on the input device pose.
  11978. * @param poseData Pose coming from the device
  11979. */
  11980. updateFromDevice(poseData: DevicePose): void;
  11981. private _htmlElementAttached;
  11982. private _detachIfAttached;
  11983. /**
  11984. * WebVR's attach control will start broadcasting frames to the device.
  11985. * Note that in certain browsers (chrome for example) this function must be called
  11986. * within a user-interaction callback. Example:
  11987. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11988. *
  11989. * @param element html element to attach the vrDevice to
  11990. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11991. */
  11992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11993. /**
  11994. * Detaches the camera from the html element and disables VR
  11995. *
  11996. * @param element html element to detach from
  11997. */
  11998. detachControl(element: HTMLElement): void;
  11999. /**
  12000. * @returns the name of this class
  12001. */
  12002. getClassName(): string;
  12003. /**
  12004. * Calls resetPose on the vrDisplay
  12005. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  12006. */
  12007. resetToCurrentRotation(): void;
  12008. /**
  12009. * @hidden
  12010. * Updates the rig cameras (left and right eye)
  12011. */
  12012. _updateRigCameras(): void;
  12013. private _workingVector;
  12014. private _oneVector;
  12015. private _workingMatrix;
  12016. private updateCacheCalled;
  12017. private _correctPositionIfNotTrackPosition;
  12018. /**
  12019. * @hidden
  12020. * Updates the cached values of the camera
  12021. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  12022. */
  12023. _updateCache(ignoreParentClass?: boolean): void;
  12024. /**
  12025. * @hidden
  12026. * Get current device position in babylon world
  12027. */
  12028. _computeDevicePosition(): void;
  12029. /**
  12030. * Updates the current device position and rotation in the babylon world
  12031. */
  12032. update(): void;
  12033. /**
  12034. * @hidden
  12035. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12036. * @returns an identity matrix
  12037. */
  12038. _getViewMatrix(): Matrix;
  12039. private _tmpMatrix;
  12040. /**
  12041. * This function is called by the two RIG cameras.
  12042. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12043. */
  12044. protected _getWebVRViewMatrix(): Matrix;
  12045. protected _getWebVRProjectionMatrix(): Matrix;
  12046. private _onGamepadConnectedObserver;
  12047. private _onGamepadDisconnectedObserver;
  12048. private _updateCacheWhenTrackingDisabledObserver;
  12049. /**
  12050. * Initializes the controllers and their meshes
  12051. */
  12052. initControllers(): void;
  12053. }
  12054. }
  12055. declare module "babylonjs/PostProcesses/postProcess" {
  12056. import { Nullable } from "babylonjs/types";
  12057. import { SmartArray } from "babylonjs/Misc/smartArray";
  12058. import { Observable } from "babylonjs/Misc/observable";
  12059. import { Color4, Vector2 } from "babylonjs/Maths/math";
  12060. import { Camera } from "babylonjs/Cameras/camera";
  12061. import { Effect } from "babylonjs/Materials/effect";
  12062. import { Animation } from "babylonjs/Animations/animation";
  12063. import "Shaders/postprocess.vertex";
  12064. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12065. import { Engine } from "babylonjs/Engines/engine";
  12066. /**
  12067. * Size options for a post process
  12068. */
  12069. export type PostProcessOptions = {
  12070. width: number;
  12071. height: number;
  12072. };
  12073. /**
  12074. * PostProcess can be used to apply a shader to a texture after it has been rendered
  12075. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12076. */
  12077. export class PostProcess {
  12078. /** Name of the PostProcess. */
  12079. name: string;
  12080. /**
  12081. * Width of the texture to apply the post process on
  12082. */
  12083. width: number;
  12084. /**
  12085. * Height of the texture to apply the post process on
  12086. */
  12087. height: number;
  12088. /**
  12089. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  12090. * @hidden
  12091. */
  12092. _outputTexture: Nullable<InternalTexture>;
  12093. /**
  12094. * Sampling mode used by the shader
  12095. * See https://doc.babylonjs.com/classes/3.1/texture
  12096. */
  12097. renderTargetSamplingMode: number;
  12098. /**
  12099. * Clear color to use when screen clearing
  12100. */
  12101. clearColor: Color4;
  12102. /**
  12103. * If the buffer needs to be cleared before applying the post process. (default: true)
  12104. * Should be set to false if shader will overwrite all previous pixels.
  12105. */
  12106. autoClear: boolean;
  12107. /**
  12108. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  12109. */
  12110. alphaMode: number;
  12111. /**
  12112. * Sets the setAlphaBlendConstants of the babylon engine
  12113. */
  12114. alphaConstants: Color4;
  12115. /**
  12116. * Animations to be used for the post processing
  12117. */
  12118. animations: Animation[];
  12119. /**
  12120. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  12121. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  12122. */
  12123. enablePixelPerfectMode: boolean;
  12124. /**
  12125. * Force the postprocess to be applied without taking in account viewport
  12126. */
  12127. forceFullscreenViewport: boolean;
  12128. /**
  12129. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  12130. *
  12131. * | Value | Type | Description |
  12132. * | ----- | ----------------------------------- | ----------- |
  12133. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  12134. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  12135. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  12136. *
  12137. */
  12138. scaleMode: number;
  12139. /**
  12140. * Force textures to be a power of two (default: false)
  12141. */
  12142. alwaysForcePOT: boolean;
  12143. private _samples;
  12144. /**
  12145. * Number of sample textures (default: 1)
  12146. */
  12147. samples: number;
  12148. /**
  12149. * Modify the scale of the post process to be the same as the viewport (default: false)
  12150. */
  12151. adaptScaleToCurrentViewport: boolean;
  12152. private _camera;
  12153. private _scene;
  12154. private _engine;
  12155. private _options;
  12156. private _reusable;
  12157. private _textureType;
  12158. /**
  12159. * Smart array of input and output textures for the post process.
  12160. * @hidden
  12161. */
  12162. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  12163. /**
  12164. * The index in _textures that corresponds to the output texture.
  12165. * @hidden
  12166. */
  12167. _currentRenderTextureInd: number;
  12168. private _effect;
  12169. private _samplers;
  12170. private _fragmentUrl;
  12171. private _vertexUrl;
  12172. private _parameters;
  12173. private _scaleRatio;
  12174. protected _indexParameters: any;
  12175. private _shareOutputWithPostProcess;
  12176. private _texelSize;
  12177. private _forcedOutputTexture;
  12178. /**
  12179. * An event triggered when the postprocess is activated.
  12180. */
  12181. onActivateObservable: Observable<Camera>;
  12182. private _onActivateObserver;
  12183. /**
  12184. * A function that is added to the onActivateObservable
  12185. */
  12186. onActivate: Nullable<(camera: Camera) => void>;
  12187. /**
  12188. * An event triggered when the postprocess changes its size.
  12189. */
  12190. onSizeChangedObservable: Observable<PostProcess>;
  12191. private _onSizeChangedObserver;
  12192. /**
  12193. * A function that is added to the onSizeChangedObservable
  12194. */
  12195. onSizeChanged: (postProcess: PostProcess) => void;
  12196. /**
  12197. * An event triggered when the postprocess applies its effect.
  12198. */
  12199. onApplyObservable: Observable<Effect>;
  12200. private _onApplyObserver;
  12201. /**
  12202. * A function that is added to the onApplyObservable
  12203. */
  12204. onApply: (effect: Effect) => void;
  12205. /**
  12206. * An event triggered before rendering the postprocess
  12207. */
  12208. onBeforeRenderObservable: Observable<Effect>;
  12209. private _onBeforeRenderObserver;
  12210. /**
  12211. * A function that is added to the onBeforeRenderObservable
  12212. */
  12213. onBeforeRender: (effect: Effect) => void;
  12214. /**
  12215. * An event triggered after rendering the postprocess
  12216. */
  12217. onAfterRenderObservable: Observable<Effect>;
  12218. private _onAfterRenderObserver;
  12219. /**
  12220. * A function that is added to the onAfterRenderObservable
  12221. */
  12222. onAfterRender: (efect: Effect) => void;
  12223. /**
  12224. * 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
  12225. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12226. */
  12227. inputTexture: InternalTexture;
  12228. /**
  12229. * Gets the camera which post process is applied to.
  12230. * @returns The camera the post process is applied to.
  12231. */
  12232. getCamera(): Camera;
  12233. /**
  12234. * Gets the texel size of the postprocess.
  12235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12236. */
  12237. readonly texelSize: Vector2;
  12238. /**
  12239. * Creates a new instance PostProcess
  12240. * @param name The name of the PostProcess.
  12241. * @param fragmentUrl The url of the fragment shader to be used.
  12242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12245. * @param camera The camera to apply the render pass to.
  12246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12247. * @param engine The engine which the post process will be applied. (default: current engine)
  12248. * @param reusable If the post process can be reused on the same frame. (default: false)
  12249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12250. * @param textureType Type of textures used when performing the post process. (default: 0)
  12251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12252. * @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
  12253. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12254. */
  12255. constructor(
  12256. /** Name of the PostProcess. */
  12257. 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);
  12258. /**
  12259. * Gets the engine which this post process belongs to.
  12260. * @returns The engine the post process was enabled with.
  12261. */
  12262. getEngine(): Engine;
  12263. /**
  12264. * The effect that is created when initializing the post process.
  12265. * @returns The created effect corrisponding the the postprocess.
  12266. */
  12267. getEffect(): Effect;
  12268. /**
  12269. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12270. * @param postProcess The post process to share the output with.
  12271. * @returns This post process.
  12272. */
  12273. shareOutputWith(postProcess: PostProcess): PostProcess;
  12274. /**
  12275. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12276. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12277. */
  12278. useOwnOutput(): void;
  12279. /**
  12280. * Updates the effect with the current post process compile time values and recompiles the shader.
  12281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12284. * @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
  12285. * @param onCompiled Called when the shader has been compiled.
  12286. * @param onError Called if there is an error when compiling a shader.
  12287. */
  12288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12289. /**
  12290. * The post process is reusable if it can be used multiple times within one frame.
  12291. * @returns If the post process is reusable
  12292. */
  12293. isReusable(): boolean;
  12294. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12295. markTextureDirty(): void;
  12296. /**
  12297. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12298. * 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.
  12299. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12300. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12301. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12302. * @returns The target texture that was bound to be written to.
  12303. */
  12304. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12305. /**
  12306. * If the post process is supported.
  12307. */
  12308. readonly isSupported: boolean;
  12309. /**
  12310. * The aspect ratio of the output texture.
  12311. */
  12312. readonly aspectRatio: number;
  12313. /**
  12314. * Get a value indicating if the post-process is ready to be used
  12315. * @returns true if the post-process is ready (shader is compiled)
  12316. */
  12317. isReady(): boolean;
  12318. /**
  12319. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12320. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12321. */
  12322. apply(): Nullable<Effect>;
  12323. private _disposeTextures;
  12324. /**
  12325. * Disposes the post process.
  12326. * @param camera The camera to dispose the post process on.
  12327. */
  12328. dispose(camera?: Camera): void;
  12329. }
  12330. }
  12331. declare module "babylonjs/Materials/effect" {
  12332. import { Observable } from "babylonjs/Misc/observable";
  12333. import { Nullable } from "babylonjs/types";
  12334. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12335. import { Engine } from "babylonjs/Engines/engine";
  12336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12337. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12339. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  12340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12341. /**
  12342. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12343. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12344. */
  12345. export class EffectFallbacks {
  12346. private _defines;
  12347. private _currentRank;
  12348. private _maxRank;
  12349. private _mesh;
  12350. /**
  12351. * Removes the fallback from the bound mesh.
  12352. */
  12353. unBindMesh(): void;
  12354. /**
  12355. * Adds a fallback on the specified property.
  12356. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12357. * @param define The name of the define in the shader
  12358. */
  12359. addFallback(rank: number, define: string): void;
  12360. /**
  12361. * Sets the mesh to use CPU skinning when needing to fallback.
  12362. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12363. * @param mesh The mesh to use the fallbacks.
  12364. */
  12365. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12366. /**
  12367. * Checks to see if more fallbacks are still availible.
  12368. */
  12369. readonly isMoreFallbacks: boolean;
  12370. /**
  12371. * Removes the defines that shoould be removed when falling back.
  12372. * @param currentDefines defines the current define statements for the shader.
  12373. * @param effect defines the current effect we try to compile
  12374. * @returns The resulting defines with defines of the current rank removed.
  12375. */
  12376. reduce(currentDefines: string, effect: Effect): string;
  12377. }
  12378. /**
  12379. * Options to be used when creating an effect.
  12380. */
  12381. export class EffectCreationOptions {
  12382. /**
  12383. * Atrributes that will be used in the shader.
  12384. */
  12385. attributes: string[];
  12386. /**
  12387. * Uniform varible names that will be set in the shader.
  12388. */
  12389. uniformsNames: string[];
  12390. /**
  12391. * Uniform buffer varible names that will be set in the shader.
  12392. */
  12393. uniformBuffersNames: string[];
  12394. /**
  12395. * Sampler texture variable names that will be set in the shader.
  12396. */
  12397. samplers: string[];
  12398. /**
  12399. * Define statements that will be set in the shader.
  12400. */
  12401. defines: any;
  12402. /**
  12403. * Possible fallbacks for this effect to improve performance when needed.
  12404. */
  12405. fallbacks: Nullable<EffectFallbacks>;
  12406. /**
  12407. * Callback that will be called when the shader is compiled.
  12408. */
  12409. onCompiled: Nullable<(effect: Effect) => void>;
  12410. /**
  12411. * Callback that will be called if an error occurs during shader compilation.
  12412. */
  12413. onError: Nullable<(effect: Effect, errors: string) => void>;
  12414. /**
  12415. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12416. */
  12417. indexParameters: any;
  12418. /**
  12419. * Max number of lights that can be used in the shader.
  12420. */
  12421. maxSimultaneousLights: number;
  12422. /**
  12423. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12424. */
  12425. transformFeedbackVaryings: Nullable<string[]>;
  12426. }
  12427. /**
  12428. * Effect containing vertex and fragment shader that can be executed on an object.
  12429. */
  12430. export class Effect {
  12431. /**
  12432. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  12433. */
  12434. static ShadersRepository: string;
  12435. /**
  12436. * Name of the effect.
  12437. */
  12438. name: any;
  12439. /**
  12440. * String container all the define statements that should be set on the shader.
  12441. */
  12442. defines: string;
  12443. /**
  12444. * Callback that will be called when the shader is compiled.
  12445. */
  12446. onCompiled: Nullable<(effect: Effect) => void>;
  12447. /**
  12448. * Callback that will be called if an error occurs during shader compilation.
  12449. */
  12450. onError: Nullable<(effect: Effect, errors: string) => void>;
  12451. /**
  12452. * Callback that will be called when effect is bound.
  12453. */
  12454. onBind: Nullable<(effect: Effect) => void>;
  12455. /**
  12456. * Unique ID of the effect.
  12457. */
  12458. uniqueId: number;
  12459. /**
  12460. * Observable that will be called when the shader is compiled.
  12461. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  12462. */
  12463. onCompileObservable: Observable<Effect>;
  12464. /**
  12465. * Observable that will be called if an error occurs during shader compilation.
  12466. */
  12467. onErrorObservable: Observable<Effect>;
  12468. /** @hidden */
  12469. _onBindObservable: Nullable<Observable<Effect>>;
  12470. /**
  12471. * Observable that will be called when effect is bound.
  12472. */
  12473. readonly onBindObservable: Observable<Effect>;
  12474. /** @hidden */
  12475. _bonesComputationForcedToCPU: boolean;
  12476. private static _uniqueIdSeed;
  12477. private _engine;
  12478. private _uniformBuffersNames;
  12479. private _uniformsNames;
  12480. private _samplers;
  12481. private _isReady;
  12482. private _compilationError;
  12483. private _attributesNames;
  12484. private _attributes;
  12485. private _uniforms;
  12486. /**
  12487. * Key for the effect.
  12488. * @hidden
  12489. */
  12490. _key: string;
  12491. private _indexParameters;
  12492. private _fallbacks;
  12493. private _vertexSourceCode;
  12494. private _fragmentSourceCode;
  12495. private _vertexSourceCodeOverride;
  12496. private _fragmentSourceCodeOverride;
  12497. private _transformFeedbackVaryings;
  12498. /**
  12499. * Compiled shader to webGL program.
  12500. * @hidden
  12501. */
  12502. _program: WebGLProgram;
  12503. private _valueCache;
  12504. private static _baseCache;
  12505. /**
  12506. * Instantiates an effect.
  12507. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12508. * @param baseName Name of the effect.
  12509. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12510. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12511. * @param samplers List of sampler variables that will be passed to the shader.
  12512. * @param engine Engine to be used to render the effect
  12513. * @param defines Define statements to be added to the shader.
  12514. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12515. * @param onCompiled Callback that will be called when the shader is compiled.
  12516. * @param onError Callback that will be called if an error occurs during shader compilation.
  12517. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12518. */
  12519. 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);
  12520. /**
  12521. * Unique key for this effect
  12522. */
  12523. readonly key: string;
  12524. /**
  12525. * If the effect has been compiled and prepared.
  12526. * @returns if the effect is compiled and prepared.
  12527. */
  12528. isReady(): boolean;
  12529. /**
  12530. * The engine the effect was initialized with.
  12531. * @returns the engine.
  12532. */
  12533. getEngine(): Engine;
  12534. /**
  12535. * The compiled webGL program for the effect
  12536. * @returns the webGL program.
  12537. */
  12538. getProgram(): WebGLProgram;
  12539. /**
  12540. * The set of names of attribute variables for the shader.
  12541. * @returns An array of attribute names.
  12542. */
  12543. getAttributesNames(): string[];
  12544. /**
  12545. * Returns the attribute at the given index.
  12546. * @param index The index of the attribute.
  12547. * @returns The location of the attribute.
  12548. */
  12549. getAttributeLocation(index: number): number;
  12550. /**
  12551. * Returns the attribute based on the name of the variable.
  12552. * @param name of the attribute to look up.
  12553. * @returns the attribute location.
  12554. */
  12555. getAttributeLocationByName(name: string): number;
  12556. /**
  12557. * The number of attributes.
  12558. * @returns the numnber of attributes.
  12559. */
  12560. getAttributesCount(): number;
  12561. /**
  12562. * Gets the index of a uniform variable.
  12563. * @param uniformName of the uniform to look up.
  12564. * @returns the index.
  12565. */
  12566. getUniformIndex(uniformName: string): number;
  12567. /**
  12568. * Returns the attribute based on the name of the variable.
  12569. * @param uniformName of the uniform to look up.
  12570. * @returns the location of the uniform.
  12571. */
  12572. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12573. /**
  12574. * Returns an array of sampler variable names
  12575. * @returns The array of sampler variable neames.
  12576. */
  12577. getSamplers(): string[];
  12578. /**
  12579. * The error from the last compilation.
  12580. * @returns the error string.
  12581. */
  12582. getCompilationError(): string;
  12583. /**
  12584. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12585. * @param func The callback to be used.
  12586. */
  12587. executeWhenCompiled(func: (effect: Effect) => void): void;
  12588. private _checkIsReady;
  12589. /** @hidden */
  12590. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12591. /** @hidden */
  12592. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12593. /** @hidden */
  12594. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  12595. private _processShaderConversion;
  12596. private _processIncludes;
  12597. private _processPrecision;
  12598. /**
  12599. * Recompiles the webGL program
  12600. * @param vertexSourceCode The source code for the vertex shader.
  12601. * @param fragmentSourceCode The source code for the fragment shader.
  12602. * @param onCompiled Callback called when completed.
  12603. * @param onError Callback called on error.
  12604. * @hidden
  12605. */
  12606. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12607. /**
  12608. * Gets the uniform locations of the the specified variable names
  12609. * @param names THe names of the variables to lookup.
  12610. * @returns Array of locations in the same order as variable names.
  12611. */
  12612. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12613. /**
  12614. * Prepares the effect
  12615. * @hidden
  12616. */
  12617. _prepareEffect(): void;
  12618. /**
  12619. * Checks if the effect is supported. (Must be called after compilation)
  12620. */
  12621. readonly isSupported: boolean;
  12622. /**
  12623. * Binds a texture to the engine to be used as output of the shader.
  12624. * @param channel Name of the output variable.
  12625. * @param texture Texture to bind.
  12626. * @hidden
  12627. */
  12628. _bindTexture(channel: string, texture: InternalTexture): void;
  12629. /**
  12630. * Sets a texture on the engine to be used in the shader.
  12631. * @param channel Name of the sampler variable.
  12632. * @param texture Texture to set.
  12633. */
  12634. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12635. /**
  12636. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12637. * @param channel Name of the sampler variable.
  12638. * @param texture Texture to set.
  12639. */
  12640. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12641. /**
  12642. * Sets an array of textures on the engine to be used in the shader.
  12643. * @param channel Name of the variable.
  12644. * @param textures Textures to set.
  12645. */
  12646. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12647. /**
  12648. * 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)
  12649. * @param channel Name of the sampler variable.
  12650. * @param postProcess Post process to get the input texture from.
  12651. */
  12652. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12653. /**
  12654. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12655. * 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)
  12656. * @param channel Name of the sampler variable.
  12657. * @param postProcess Post process to get the output texture from.
  12658. */
  12659. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12660. /** @hidden */
  12661. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12662. /** @hidden */
  12663. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12664. /** @hidden */
  12665. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12666. /** @hidden */
  12667. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12668. /**
  12669. * Binds a buffer to a uniform.
  12670. * @param buffer Buffer to bind.
  12671. * @param name Name of the uniform variable to bind to.
  12672. */
  12673. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12674. /**
  12675. * Binds block to a uniform.
  12676. * @param blockName Name of the block to bind.
  12677. * @param index Index to bind.
  12678. */
  12679. bindUniformBlock(blockName: string, index: number): void;
  12680. /**
  12681. * Sets an interger value on a uniform variable.
  12682. * @param uniformName Name of the variable.
  12683. * @param value Value to be set.
  12684. * @returns this effect.
  12685. */
  12686. setInt(uniformName: string, value: number): Effect;
  12687. /**
  12688. * Sets an int array on a uniform variable.
  12689. * @param uniformName Name of the variable.
  12690. * @param array array to be set.
  12691. * @returns this effect.
  12692. */
  12693. setIntArray(uniformName: string, array: Int32Array): Effect;
  12694. /**
  12695. * 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)
  12696. * @param uniformName Name of the variable.
  12697. * @param array array to be set.
  12698. * @returns this effect.
  12699. */
  12700. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12701. /**
  12702. * 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)
  12703. * @param uniformName Name of the variable.
  12704. * @param array array to be set.
  12705. * @returns this effect.
  12706. */
  12707. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12708. /**
  12709. * 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)
  12710. * @param uniformName Name of the variable.
  12711. * @param array array to be set.
  12712. * @returns this effect.
  12713. */
  12714. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12715. /**
  12716. * Sets an float array on a uniform variable.
  12717. * @param uniformName Name of the variable.
  12718. * @param array array to be set.
  12719. * @returns this effect.
  12720. */
  12721. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12722. /**
  12723. * 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)
  12724. * @param uniformName Name of the variable.
  12725. * @param array array to be set.
  12726. * @returns this effect.
  12727. */
  12728. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12729. /**
  12730. * 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)
  12731. * @param uniformName Name of the variable.
  12732. * @param array array to be set.
  12733. * @returns this effect.
  12734. */
  12735. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12736. /**
  12737. * 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)
  12738. * @param uniformName Name of the variable.
  12739. * @param array array to be set.
  12740. * @returns this effect.
  12741. */
  12742. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12743. /**
  12744. * Sets an array on a uniform variable.
  12745. * @param uniformName Name of the variable.
  12746. * @param array array to be set.
  12747. * @returns this effect.
  12748. */
  12749. setArray(uniformName: string, array: number[]): Effect;
  12750. /**
  12751. * 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)
  12752. * @param uniformName Name of the variable.
  12753. * @param array array to be set.
  12754. * @returns this effect.
  12755. */
  12756. setArray2(uniformName: string, array: number[]): Effect;
  12757. /**
  12758. * 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)
  12759. * @param uniformName Name of the variable.
  12760. * @param array array to be set.
  12761. * @returns this effect.
  12762. */
  12763. setArray3(uniformName: string, array: number[]): Effect;
  12764. /**
  12765. * 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)
  12766. * @param uniformName Name of the variable.
  12767. * @param array array to be set.
  12768. * @returns this effect.
  12769. */
  12770. setArray4(uniformName: string, array: number[]): Effect;
  12771. /**
  12772. * Sets matrices on a uniform variable.
  12773. * @param uniformName Name of the variable.
  12774. * @param matrices matrices to be set.
  12775. * @returns this effect.
  12776. */
  12777. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12778. /**
  12779. * Sets matrix on a uniform variable.
  12780. * @param uniformName Name of the variable.
  12781. * @param matrix matrix to be set.
  12782. * @returns this effect.
  12783. */
  12784. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12785. /**
  12786. * 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)
  12787. * @param uniformName Name of the variable.
  12788. * @param matrix matrix to be set.
  12789. * @returns this effect.
  12790. */
  12791. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12792. /**
  12793. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12794. * @param uniformName Name of the variable.
  12795. * @param matrix matrix to be set.
  12796. * @returns this effect.
  12797. */
  12798. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12799. /**
  12800. * Sets a float on a uniform variable.
  12801. * @param uniformName Name of the variable.
  12802. * @param value value to be set.
  12803. * @returns this effect.
  12804. */
  12805. setFloat(uniformName: string, value: number): Effect;
  12806. /**
  12807. * Sets a boolean on a uniform variable.
  12808. * @param uniformName Name of the variable.
  12809. * @param bool value to be set.
  12810. * @returns this effect.
  12811. */
  12812. setBool(uniformName: string, bool: boolean): Effect;
  12813. /**
  12814. * Sets a Vector2 on a uniform variable.
  12815. * @param uniformName Name of the variable.
  12816. * @param vector2 vector2 to be set.
  12817. * @returns this effect.
  12818. */
  12819. setVector2(uniformName: string, vector2: Vector2): Effect;
  12820. /**
  12821. * Sets a float2 on a uniform variable.
  12822. * @param uniformName Name of the variable.
  12823. * @param x First float in float2.
  12824. * @param y Second float in float2.
  12825. * @returns this effect.
  12826. */
  12827. setFloat2(uniformName: string, x: number, y: number): Effect;
  12828. /**
  12829. * Sets a Vector3 on a uniform variable.
  12830. * @param uniformName Name of the variable.
  12831. * @param vector3 Value to be set.
  12832. * @returns this effect.
  12833. */
  12834. setVector3(uniformName: string, vector3: Vector3): Effect;
  12835. /**
  12836. * Sets a float3 on a uniform variable.
  12837. * @param uniformName Name of the variable.
  12838. * @param x First float in float3.
  12839. * @param y Second float in float3.
  12840. * @param z Third float in float3.
  12841. * @returns this effect.
  12842. */
  12843. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12844. /**
  12845. * Sets a Vector4 on a uniform variable.
  12846. * @param uniformName Name of the variable.
  12847. * @param vector4 Value to be set.
  12848. * @returns this effect.
  12849. */
  12850. setVector4(uniformName: string, vector4: Vector4): Effect;
  12851. /**
  12852. * Sets a float4 on a uniform variable.
  12853. * @param uniformName Name of the variable.
  12854. * @param x First float in float4.
  12855. * @param y Second float in float4.
  12856. * @param z Third float in float4.
  12857. * @param w Fourth float in float4.
  12858. * @returns this effect.
  12859. */
  12860. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12861. /**
  12862. * Sets a Color3 on a uniform variable.
  12863. * @param uniformName Name of the variable.
  12864. * @param color3 Value to be set.
  12865. * @returns this effect.
  12866. */
  12867. setColor3(uniformName: string, color3: Color3): Effect;
  12868. /**
  12869. * Sets a Color4 on a uniform variable.
  12870. * @param uniformName Name of the variable.
  12871. * @param color3 Value to be set.
  12872. * @param alpha Alpha value to be set.
  12873. * @returns this effect.
  12874. */
  12875. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12876. /**
  12877. * Sets a Color4 on a uniform variable
  12878. * @param uniformName defines the name of the variable
  12879. * @param color4 defines the value to be set
  12880. * @returns this effect.
  12881. */
  12882. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12883. /**
  12884. * This function will add a new shader to the shader store
  12885. * @param name the name of the shader
  12886. * @param pixelShader optional pixel shader content
  12887. * @param vertexShader optional vertex shader content
  12888. */
  12889. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  12890. /**
  12891. * Store of each shader (The can be looked up using effect.key)
  12892. */
  12893. static ShadersStore: {
  12894. [key: string]: string;
  12895. };
  12896. /**
  12897. * Store of each included file for a shader (The can be looked up using effect.key)
  12898. */
  12899. static IncludesShadersStore: {
  12900. [key: string]: string;
  12901. };
  12902. /**
  12903. * Resets the cache of effects.
  12904. */
  12905. static ResetCache(): void;
  12906. }
  12907. }
  12908. declare module "babylonjs/Materials/uniformBuffer" {
  12909. import { Nullable, FloatArray } from "babylonjs/types";
  12910. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  12911. import { Engine } from "babylonjs/Engines/engine";
  12912. import { Effect } from "babylonjs/Materials/effect";
  12913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12914. /**
  12915. * Uniform buffer objects.
  12916. *
  12917. * Handles blocks of uniform on the GPU.
  12918. *
  12919. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  12920. *
  12921. * For more information, please refer to :
  12922. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  12923. */
  12924. export class UniformBuffer {
  12925. private _engine;
  12926. private _buffer;
  12927. private _data;
  12928. private _bufferData;
  12929. private _dynamic?;
  12930. private _uniformLocations;
  12931. private _uniformSizes;
  12932. private _uniformLocationPointer;
  12933. private _needSync;
  12934. private _noUBO;
  12935. private _currentEffect;
  12936. private static _MAX_UNIFORM_SIZE;
  12937. private static _tempBuffer;
  12938. /**
  12939. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  12940. * This is dynamic to allow compat with webgl 1 and 2.
  12941. * You will need to pass the name of the uniform as well as the value.
  12942. */
  12943. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  12944. /**
  12945. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  12946. * This is dynamic to allow compat with webgl 1 and 2.
  12947. * You will need to pass the name of the uniform as well as the value.
  12948. */
  12949. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  12950. /**
  12951. * Lambda to Update a single float in a uniform buffer.
  12952. * This is dynamic to allow compat with webgl 1 and 2.
  12953. * You will need to pass the name of the uniform as well as the value.
  12954. */
  12955. updateFloat: (name: string, x: number) => void;
  12956. /**
  12957. * Lambda to Update a vec2 of float in a uniform buffer.
  12958. * This is dynamic to allow compat with webgl 1 and 2.
  12959. * You will need to pass the name of the uniform as well as the value.
  12960. */
  12961. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  12962. /**
  12963. * Lambda to Update a vec3 of float in a uniform buffer.
  12964. * This is dynamic to allow compat with webgl 1 and 2.
  12965. * You will need to pass the name of the uniform as well as the value.
  12966. */
  12967. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  12968. /**
  12969. * Lambda to Update a vec4 of float in a uniform buffer.
  12970. * This is dynamic to allow compat with webgl 1 and 2.
  12971. * You will need to pass the name of the uniform as well as the value.
  12972. */
  12973. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  12974. /**
  12975. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  12976. * This is dynamic to allow compat with webgl 1 and 2.
  12977. * You will need to pass the name of the uniform as well as the value.
  12978. */
  12979. updateMatrix: (name: string, mat: Matrix) => void;
  12980. /**
  12981. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  12982. * This is dynamic to allow compat with webgl 1 and 2.
  12983. * You will need to pass the name of the uniform as well as the value.
  12984. */
  12985. updateVector3: (name: string, vector: Vector3) => void;
  12986. /**
  12987. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  12988. * This is dynamic to allow compat with webgl 1 and 2.
  12989. * You will need to pass the name of the uniform as well as the value.
  12990. */
  12991. updateVector4: (name: string, vector: Vector4) => void;
  12992. /**
  12993. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  12994. * This is dynamic to allow compat with webgl 1 and 2.
  12995. * You will need to pass the name of the uniform as well as the value.
  12996. */
  12997. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  12998. /**
  12999. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  13000. * This is dynamic to allow compat with webgl 1 and 2.
  13001. * You will need to pass the name of the uniform as well as the value.
  13002. */
  13003. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  13004. /**
  13005. * Instantiates a new Uniform buffer objects.
  13006. *
  13007. * Handles blocks of uniform on the GPU.
  13008. *
  13009. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  13010. *
  13011. * For more information, please refer to :
  13012. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  13013. * @param engine Define the engine the buffer is associated with
  13014. * @param data Define the data contained in the buffer
  13015. * @param dynamic Define if the buffer is updatable
  13016. */
  13017. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  13018. /**
  13019. * Indicates if the buffer is using the WebGL2 UBO implementation,
  13020. * or just falling back on setUniformXXX calls.
  13021. */
  13022. readonly useUbo: boolean;
  13023. /**
  13024. * Indicates if the WebGL underlying uniform buffer is in sync
  13025. * with the javascript cache data.
  13026. */
  13027. readonly isSync: boolean;
  13028. /**
  13029. * Indicates if the WebGL underlying uniform buffer is dynamic.
  13030. * Also, a dynamic UniformBuffer will disable cache verification and always
  13031. * update the underlying WebGL uniform buffer to the GPU.
  13032. * @returns if Dynamic, otherwise false
  13033. */
  13034. isDynamic(): boolean;
  13035. /**
  13036. * The data cache on JS side.
  13037. * @returns the underlying data as a float array
  13038. */
  13039. getData(): Float32Array;
  13040. /**
  13041. * The underlying WebGL Uniform buffer.
  13042. * @returns the webgl buffer
  13043. */
  13044. getBuffer(): Nullable<WebGLBuffer>;
  13045. /**
  13046. * std140 layout specifies how to align data within an UBO structure.
  13047. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  13048. * for specs.
  13049. */
  13050. private _fillAlignment;
  13051. /**
  13052. * Adds an uniform in the buffer.
  13053. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  13054. * for the layout to be correct !
  13055. * @param name Name of the uniform, as used in the uniform block in the shader.
  13056. * @param size Data size, or data directly.
  13057. */
  13058. addUniform(name: string, size: number | number[]): void;
  13059. /**
  13060. * Adds a Matrix 4x4 to the uniform buffer.
  13061. * @param name Name of the uniform, as used in the uniform block in the shader.
  13062. * @param mat A 4x4 matrix.
  13063. */
  13064. addMatrix(name: string, mat: Matrix): void;
  13065. /**
  13066. * Adds a vec2 to the uniform buffer.
  13067. * @param name Name of the uniform, as used in the uniform block in the shader.
  13068. * @param x Define the x component value of the vec2
  13069. * @param y Define the y component value of the vec2
  13070. */
  13071. addFloat2(name: string, x: number, y: number): void;
  13072. /**
  13073. * Adds a vec3 to the uniform buffer.
  13074. * @param name Name of the uniform, as used in the uniform block in the shader.
  13075. * @param x Define the x component value of the vec3
  13076. * @param y Define the y component value of the vec3
  13077. * @param z Define the z component value of the vec3
  13078. */
  13079. addFloat3(name: string, x: number, y: number, z: number): void;
  13080. /**
  13081. * Adds a vec3 to the uniform buffer.
  13082. * @param name Name of the uniform, as used in the uniform block in the shader.
  13083. * @param color Define the vec3 from a Color
  13084. */
  13085. addColor3(name: string, color: Color3): void;
  13086. /**
  13087. * Adds a vec4 to the uniform buffer.
  13088. * @param name Name of the uniform, as used in the uniform block in the shader.
  13089. * @param color Define the rgb components from a Color
  13090. * @param alpha Define the a component of the vec4
  13091. */
  13092. addColor4(name: string, color: Color3, alpha: number): void;
  13093. /**
  13094. * Adds a vec3 to the uniform buffer.
  13095. * @param name Name of the uniform, as used in the uniform block in the shader.
  13096. * @param vector Define the vec3 components from a Vector
  13097. */
  13098. addVector3(name: string, vector: Vector3): void;
  13099. /**
  13100. * Adds a Matrix 3x3 to the uniform buffer.
  13101. * @param name Name of the uniform, as used in the uniform block in the shader.
  13102. */
  13103. addMatrix3x3(name: string): void;
  13104. /**
  13105. * Adds a Matrix 2x2 to the uniform buffer.
  13106. * @param name Name of the uniform, as used in the uniform block in the shader.
  13107. */
  13108. addMatrix2x2(name: string): void;
  13109. /**
  13110. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  13111. */
  13112. create(): void;
  13113. /** @hidden */
  13114. _rebuild(): void;
  13115. /**
  13116. * Updates the WebGL Uniform Buffer on the GPU.
  13117. * If the `dynamic` flag is set to true, no cache comparison is done.
  13118. * Otherwise, the buffer will be updated only if the cache differs.
  13119. */
  13120. update(): void;
  13121. /**
  13122. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  13123. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  13124. * @param data Define the flattened data
  13125. * @param size Define the size of the data.
  13126. */
  13127. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  13128. private _updateMatrix3x3ForUniform;
  13129. private _updateMatrix3x3ForEffect;
  13130. private _updateMatrix2x2ForEffect;
  13131. private _updateMatrix2x2ForUniform;
  13132. private _updateFloatForEffect;
  13133. private _updateFloatForUniform;
  13134. private _updateFloat2ForEffect;
  13135. private _updateFloat2ForUniform;
  13136. private _updateFloat3ForEffect;
  13137. private _updateFloat3ForUniform;
  13138. private _updateFloat4ForEffect;
  13139. private _updateFloat4ForUniform;
  13140. private _updateMatrixForEffect;
  13141. private _updateMatrixForUniform;
  13142. private _updateVector3ForEffect;
  13143. private _updateVector3ForUniform;
  13144. private _updateVector4ForEffect;
  13145. private _updateVector4ForUniform;
  13146. private _updateColor3ForEffect;
  13147. private _updateColor3ForUniform;
  13148. private _updateColor4ForEffect;
  13149. private _updateColor4ForUniform;
  13150. /**
  13151. * Sets a sampler uniform on the effect.
  13152. * @param name Define the name of the sampler.
  13153. * @param texture Define the texture to set in the sampler
  13154. */
  13155. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  13156. /**
  13157. * Directly updates the value of the uniform in the cache AND on the GPU.
  13158. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  13159. * @param data Define the flattened data
  13160. */
  13161. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  13162. /**
  13163. * Binds this uniform buffer to an effect.
  13164. * @param effect Define the effect to bind the buffer to
  13165. * @param name Name of the uniform block in the shader.
  13166. */
  13167. bindToEffect(effect: Effect, name: string): void;
  13168. /**
  13169. * Disposes the uniform buffer.
  13170. */
  13171. dispose(): void;
  13172. }
  13173. }
  13174. declare module "babylonjs/Materials/material" {
  13175. import { IAnimatable } from "babylonjs/Misc/tools";
  13176. import { SmartArray } from "babylonjs/Misc/smartArray";
  13177. import { Observable } from "babylonjs/Misc/observable";
  13178. import { Nullable } from "babylonjs/types";
  13179. import { Scene } from "babylonjs/scene";
  13180. import { Matrix } from "babylonjs/Maths/math";
  13181. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  13182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13183. import { Mesh } from "babylonjs/Meshes/mesh";
  13184. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13185. import { Effect } from "babylonjs/Materials/effect";
  13186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13187. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13188. import { Animation } from "babylonjs/Animations/animation";
  13189. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  13190. /**
  13191. * Base class for the main features of a material in Babylon.js
  13192. */
  13193. export class Material implements IAnimatable {
  13194. private static _TriangleFillMode;
  13195. private static _WireFrameFillMode;
  13196. private static _PointFillMode;
  13197. private static _PointListDrawMode;
  13198. private static _LineListDrawMode;
  13199. private static _LineLoopDrawMode;
  13200. private static _LineStripDrawMode;
  13201. private static _TriangleStripDrawMode;
  13202. private static _TriangleFanDrawMode;
  13203. /**
  13204. * Returns the triangle fill mode
  13205. */
  13206. static readonly TriangleFillMode: number;
  13207. /**
  13208. * Returns the wireframe mode
  13209. */
  13210. static readonly WireFrameFillMode: number;
  13211. /**
  13212. * Returns the point fill mode
  13213. */
  13214. static readonly PointFillMode: number;
  13215. /**
  13216. * Returns the point list draw mode
  13217. */
  13218. static readonly PointListDrawMode: number;
  13219. /**
  13220. * Returns the line list draw mode
  13221. */
  13222. static readonly LineListDrawMode: number;
  13223. /**
  13224. * Returns the line loop draw mode
  13225. */
  13226. static readonly LineLoopDrawMode: number;
  13227. /**
  13228. * Returns the line strip draw mode
  13229. */
  13230. static readonly LineStripDrawMode: number;
  13231. /**
  13232. * Returns the triangle strip draw mode
  13233. */
  13234. static readonly TriangleStripDrawMode: number;
  13235. /**
  13236. * Returns the triangle fan draw mode
  13237. */
  13238. static readonly TriangleFanDrawMode: number;
  13239. /**
  13240. * Stores the clock-wise side orientation
  13241. */
  13242. private static _ClockWiseSideOrientation;
  13243. /**
  13244. * Stores the counter clock-wise side orientation
  13245. */
  13246. private static _CounterClockWiseSideOrientation;
  13247. /**
  13248. * Returns the clock-wise side orientation
  13249. */
  13250. static readonly ClockWiseSideOrientation: number;
  13251. /**
  13252. * Returns the counter clock-wise side orientation
  13253. */
  13254. static readonly CounterClockWiseSideOrientation: number;
  13255. /**
  13256. * The dirty texture flag value
  13257. */
  13258. static readonly TextureDirtyFlag: number;
  13259. /**
  13260. * The dirty light flag value
  13261. */
  13262. static readonly LightDirtyFlag: number;
  13263. /**
  13264. * The dirty fresnel flag value
  13265. */
  13266. static readonly FresnelDirtyFlag: number;
  13267. /**
  13268. * The dirty attribute flag value
  13269. */
  13270. static readonly AttributesDirtyFlag: number;
  13271. /**
  13272. * The dirty misc flag value
  13273. */
  13274. static readonly MiscDirtyFlag: number;
  13275. /**
  13276. * The all dirty flag value
  13277. */
  13278. static readonly AllDirtyFlag: number;
  13279. /**
  13280. * The ID of the material
  13281. */
  13282. id: string;
  13283. /**
  13284. * Gets or sets the unique id of the material
  13285. */
  13286. uniqueId: number;
  13287. /**
  13288. * The name of the material
  13289. */
  13290. name: string;
  13291. /**
  13292. * Gets or sets user defined metadata
  13293. */
  13294. metadata: any;
  13295. /**
  13296. * Specifies if the ready state should be checked on each call
  13297. */
  13298. checkReadyOnEveryCall: boolean;
  13299. /**
  13300. * Specifies if the ready state should be checked once
  13301. */
  13302. checkReadyOnlyOnce: boolean;
  13303. /**
  13304. * The state of the material
  13305. */
  13306. state: string;
  13307. /**
  13308. * The alpha value of the material
  13309. */
  13310. protected _alpha: number;
  13311. /**
  13312. * Sets the alpha value of the material
  13313. */
  13314. /**
  13315. * Gets the alpha value of the material
  13316. */
  13317. alpha: number;
  13318. /**
  13319. * Specifies if back face culling is enabled
  13320. */
  13321. protected _backFaceCulling: boolean;
  13322. /**
  13323. * Sets the back-face culling state
  13324. */
  13325. /**
  13326. * Gets the back-face culling state
  13327. */
  13328. backFaceCulling: boolean;
  13329. /**
  13330. * Stores the value for side orientation
  13331. */
  13332. sideOrientation: number;
  13333. /**
  13334. * Callback triggered when the material is compiled
  13335. */
  13336. onCompiled: (effect: Effect) => void;
  13337. /**
  13338. * Callback triggered when an error occurs
  13339. */
  13340. onError: (effect: Effect, errors: string) => void;
  13341. /**
  13342. * Callback triggered to get the render target textures
  13343. */
  13344. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13345. /**
  13346. * Gets a boolean indicating that current material needs to register RTT
  13347. */
  13348. readonly hasRenderTargetTextures: boolean;
  13349. /**
  13350. * Specifies if the material should be serialized
  13351. */
  13352. doNotSerialize: boolean;
  13353. /**
  13354. * @hidden
  13355. */
  13356. _storeEffectOnSubMeshes: boolean;
  13357. /**
  13358. * Stores the animations for the material
  13359. */
  13360. animations: Array<Animation>;
  13361. /**
  13362. * An event triggered when the material is disposed
  13363. */
  13364. onDisposeObservable: Observable<Material>;
  13365. /**
  13366. * An observer which watches for dispose events
  13367. */
  13368. private _onDisposeObserver;
  13369. private _onUnBindObservable;
  13370. /**
  13371. * Called during a dispose event
  13372. */
  13373. onDispose: () => void;
  13374. private _onBindObservable;
  13375. /**
  13376. * An event triggered when the material is bound
  13377. */
  13378. readonly onBindObservable: Observable<AbstractMesh>;
  13379. /**
  13380. * An observer which watches for bind events
  13381. */
  13382. private _onBindObserver;
  13383. /**
  13384. * Called during a bind event
  13385. */
  13386. onBind: (Mesh: AbstractMesh) => void;
  13387. /**
  13388. * An event triggered when the material is unbound
  13389. */
  13390. readonly onUnBindObservable: Observable<Material>;
  13391. /**
  13392. * Stores the value of the alpha mode
  13393. */
  13394. private _alphaMode;
  13395. /**
  13396. * Sets the value of the alpha mode.
  13397. *
  13398. * | Value | Type | Description |
  13399. * | --- | --- | --- |
  13400. * | 0 | ALPHA_DISABLE | |
  13401. * | 1 | ALPHA_ADD | |
  13402. * | 2 | ALPHA_COMBINE | |
  13403. * | 3 | ALPHA_SUBTRACT | |
  13404. * | 4 | ALPHA_MULTIPLY | |
  13405. * | 5 | ALPHA_MAXIMIZED | |
  13406. * | 6 | ALPHA_ONEONE | |
  13407. * | 7 | ALPHA_PREMULTIPLIED | |
  13408. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13409. * | 9 | ALPHA_INTERPOLATE | |
  13410. * | 10 | ALPHA_SCREENMODE | |
  13411. *
  13412. */
  13413. /**
  13414. * Gets the value of the alpha mode
  13415. */
  13416. alphaMode: number;
  13417. /**
  13418. * Stores the state of the need depth pre-pass value
  13419. */
  13420. private _needDepthPrePass;
  13421. /**
  13422. * Sets the need depth pre-pass value
  13423. */
  13424. /**
  13425. * Gets the depth pre-pass value
  13426. */
  13427. needDepthPrePass: boolean;
  13428. /**
  13429. * Specifies if depth writing should be disabled
  13430. */
  13431. disableDepthWrite: boolean;
  13432. /**
  13433. * Specifies if depth writing should be forced
  13434. */
  13435. forceDepthWrite: boolean;
  13436. /**
  13437. * Specifies if there should be a separate pass for culling
  13438. */
  13439. separateCullingPass: boolean;
  13440. /**
  13441. * Stores the state specifing if fog should be enabled
  13442. */
  13443. private _fogEnabled;
  13444. /**
  13445. * Sets the state for enabling fog
  13446. */
  13447. /**
  13448. * Gets the value of the fog enabled state
  13449. */
  13450. fogEnabled: boolean;
  13451. /**
  13452. * Stores the size of points
  13453. */
  13454. pointSize: number;
  13455. /**
  13456. * Stores the z offset value
  13457. */
  13458. zOffset: number;
  13459. /**
  13460. * Gets a value specifying if wireframe mode is enabled
  13461. */
  13462. /**
  13463. * Sets the state of wireframe mode
  13464. */
  13465. wireframe: boolean;
  13466. /**
  13467. * Gets the value specifying if point clouds are enabled
  13468. */
  13469. /**
  13470. * Sets the state of point cloud mode
  13471. */
  13472. pointsCloud: boolean;
  13473. /**
  13474. * Gets the material fill mode
  13475. */
  13476. /**
  13477. * Sets the material fill mode
  13478. */
  13479. fillMode: number;
  13480. /**
  13481. * @hidden
  13482. * Stores the effects for the material
  13483. */
  13484. _effect: Nullable<Effect>;
  13485. /**
  13486. * @hidden
  13487. * Specifies if the material was previously ready
  13488. */
  13489. _wasPreviouslyReady: boolean;
  13490. /**
  13491. * Specifies if uniform buffers should be used
  13492. */
  13493. private _useUBO;
  13494. /**
  13495. * Stores a reference to the scene
  13496. */
  13497. private _scene;
  13498. /**
  13499. * Stores the fill mode state
  13500. */
  13501. private _fillMode;
  13502. /**
  13503. * Specifies if the depth write state should be cached
  13504. */
  13505. private _cachedDepthWriteState;
  13506. /**
  13507. * Stores the uniform buffer
  13508. */
  13509. protected _uniformBuffer: UniformBuffer;
  13510. /** @hidden */
  13511. _indexInSceneMaterialArray: number;
  13512. /** @hidden */
  13513. meshMap: Nullable<{
  13514. [id: string]: AbstractMesh | undefined;
  13515. }>;
  13516. /**
  13517. * Creates a material instance
  13518. * @param name defines the name of the material
  13519. * @param scene defines the scene to reference
  13520. * @param doNotAdd specifies if the material should be added to the scene
  13521. */
  13522. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13523. /**
  13524. * Returns a string representation of the current material
  13525. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13526. * @returns a string with material information
  13527. */
  13528. toString(fullDetails?: boolean): string;
  13529. /**
  13530. * Gets the class name of the material
  13531. * @returns a string with the class name of the material
  13532. */
  13533. getClassName(): string;
  13534. /**
  13535. * Specifies if updates for the material been locked
  13536. */
  13537. readonly isFrozen: boolean;
  13538. /**
  13539. * Locks updates for the material
  13540. */
  13541. freeze(): void;
  13542. /**
  13543. * Unlocks updates for the material
  13544. */
  13545. unfreeze(): void;
  13546. /**
  13547. * Specifies if the material is ready to be used
  13548. * @param mesh defines the mesh to check
  13549. * @param useInstances specifies if instances should be used
  13550. * @returns a boolean indicating if the material is ready to be used
  13551. */
  13552. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13553. /**
  13554. * Specifies that the submesh is ready to be used
  13555. * @param mesh defines the mesh to check
  13556. * @param subMesh defines which submesh to check
  13557. * @param useInstances specifies that instances should be used
  13558. * @returns a boolean indicating that the submesh is ready or not
  13559. */
  13560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13561. /**
  13562. * Returns the material effect
  13563. * @returns the effect associated with the material
  13564. */
  13565. getEffect(): Nullable<Effect>;
  13566. /**
  13567. * Returns the current scene
  13568. * @returns a Scene
  13569. */
  13570. getScene(): Scene;
  13571. /**
  13572. * Specifies if the material will require alpha blending
  13573. * @returns a boolean specifying if alpha blending is needed
  13574. */
  13575. needAlphaBlending(): boolean;
  13576. /**
  13577. * Specifies if the mesh will require alpha blending
  13578. * @param mesh defines the mesh to check
  13579. * @returns a boolean specifying if alpha blending is needed for the mesh
  13580. */
  13581. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13582. /**
  13583. * Specifies if this material should be rendered in alpha test mode
  13584. * @returns a boolean specifying if an alpha test is needed.
  13585. */
  13586. needAlphaTesting(): boolean;
  13587. /**
  13588. * Gets the texture used for the alpha test
  13589. * @returns the texture to use for alpha testing
  13590. */
  13591. getAlphaTestTexture(): Nullable<BaseTexture>;
  13592. /**
  13593. * Marks the material to indicate that it needs to be re-calculated
  13594. */
  13595. markDirty(): void;
  13596. /** @hidden */
  13597. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13598. /**
  13599. * Binds the material to the mesh
  13600. * @param world defines the world transformation matrix
  13601. * @param mesh defines the mesh to bind the material to
  13602. */
  13603. bind(world: Matrix, mesh?: Mesh): void;
  13604. /**
  13605. * Binds the submesh to the material
  13606. * @param world defines the world transformation matrix
  13607. * @param mesh defines the mesh containing the submesh
  13608. * @param subMesh defines the submesh to bind the material to
  13609. */
  13610. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13611. /**
  13612. * Binds the world matrix to the material
  13613. * @param world defines the world transformation matrix
  13614. */
  13615. bindOnlyWorldMatrix(world: Matrix): void;
  13616. /**
  13617. * Binds the scene's uniform buffer to the effect.
  13618. * @param effect defines the effect to bind to the scene uniform buffer
  13619. * @param sceneUbo defines the uniform buffer storing scene data
  13620. */
  13621. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13622. /**
  13623. * Binds the view matrix to the effect
  13624. * @param effect defines the effect to bind the view matrix to
  13625. */
  13626. bindView(effect: Effect): void;
  13627. /**
  13628. * Binds the view projection matrix to the effect
  13629. * @param effect defines the effect to bind the view projection matrix to
  13630. */
  13631. bindViewProjection(effect: Effect): void;
  13632. /**
  13633. * Specifies if material alpha testing should be turned on for the mesh
  13634. * @param mesh defines the mesh to check
  13635. */
  13636. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13637. /**
  13638. * Processes to execute after binding the material to a mesh
  13639. * @param mesh defines the rendered mesh
  13640. */
  13641. protected _afterBind(mesh?: Mesh): void;
  13642. /**
  13643. * Unbinds the material from the mesh
  13644. */
  13645. unbind(): void;
  13646. /**
  13647. * Gets the active textures from the material
  13648. * @returns an array of textures
  13649. */
  13650. getActiveTextures(): BaseTexture[];
  13651. /**
  13652. * Specifies if the material uses a texture
  13653. * @param texture defines the texture to check against the material
  13654. * @returns a boolean specifying if the material uses the texture
  13655. */
  13656. hasTexture(texture: BaseTexture): boolean;
  13657. /**
  13658. * Makes a duplicate of the material, and gives it a new name
  13659. * @param name defines the new name for the duplicated material
  13660. * @returns the cloned material
  13661. */
  13662. clone(name: string): Nullable<Material>;
  13663. /**
  13664. * Gets the meshes bound to the material
  13665. * @returns an array of meshes bound to the material
  13666. */
  13667. getBindedMeshes(): AbstractMesh[];
  13668. /**
  13669. * Force shader compilation
  13670. * @param mesh defines the mesh associated with this material
  13671. * @param onCompiled defines a function to execute once the material is compiled
  13672. * @param options defines the options to configure the compilation
  13673. */
  13674. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13675. clipPlane: boolean;
  13676. }>): void;
  13677. /**
  13678. * Force shader compilation
  13679. * @param mesh defines the mesh that will use this material
  13680. * @param options defines additional options for compiling the shaders
  13681. * @returns a promise that resolves when the compilation completes
  13682. */
  13683. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13684. clipPlane: boolean;
  13685. }>): Promise<void>;
  13686. private static readonly _ImageProcessingDirtyCallBack;
  13687. private static readonly _TextureDirtyCallBack;
  13688. private static readonly _FresnelDirtyCallBack;
  13689. private static readonly _MiscDirtyCallBack;
  13690. private static readonly _LightsDirtyCallBack;
  13691. private static readonly _AttributeDirtyCallBack;
  13692. private static _FresnelAndMiscDirtyCallBack;
  13693. private static _TextureAndMiscDirtyCallBack;
  13694. private static readonly _DirtyCallbackArray;
  13695. private static readonly _RunDirtyCallBacks;
  13696. /**
  13697. * Marks a define in the material to indicate that it needs to be re-computed
  13698. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13699. */
  13700. markAsDirty(flag: number): void;
  13701. /**
  13702. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13703. * @param func defines a function which checks material defines against the submeshes
  13704. */
  13705. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13706. /**
  13707. * Indicates that image processing needs to be re-calculated for all submeshes
  13708. */
  13709. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13710. /**
  13711. * Indicates that textures need to be re-calculated for all submeshes
  13712. */
  13713. protected _markAllSubMeshesAsTexturesDirty(): void;
  13714. /**
  13715. * Indicates that fresnel needs to be re-calculated for all submeshes
  13716. */
  13717. protected _markAllSubMeshesAsFresnelDirty(): void;
  13718. /**
  13719. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13720. */
  13721. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13722. /**
  13723. * Indicates that lights need to be re-calculated for all submeshes
  13724. */
  13725. protected _markAllSubMeshesAsLightsDirty(): void;
  13726. /**
  13727. * Indicates that attributes need to be re-calculated for all submeshes
  13728. */
  13729. protected _markAllSubMeshesAsAttributesDirty(): void;
  13730. /**
  13731. * Indicates that misc needs to be re-calculated for all submeshes
  13732. */
  13733. protected _markAllSubMeshesAsMiscDirty(): void;
  13734. /**
  13735. * Indicates that textures and misc need to be re-calculated for all submeshes
  13736. */
  13737. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13738. /**
  13739. * Disposes the material
  13740. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13741. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13742. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  13743. */
  13744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  13745. /** @hidden */
  13746. private releaseVertexArrayObject;
  13747. /**
  13748. * Serializes this material
  13749. * @returns the serialized material object
  13750. */
  13751. serialize(): any;
  13752. /**
  13753. * Creates a material from parsed material data
  13754. * @param parsedMaterial defines parsed material data
  13755. * @param scene defines the hosting scene
  13756. * @param rootUrl defines the root URL to use to load textures
  13757. * @returns a new material
  13758. */
  13759. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13760. }
  13761. }
  13762. declare module "babylonjs/PostProcesses/postProcessManager" {
  13763. import { Nullable } from "babylonjs/types";
  13764. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13765. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13766. import { Scene } from "babylonjs/scene";
  13767. /**
  13768. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13769. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13770. */
  13771. export class PostProcessManager {
  13772. private _scene;
  13773. private _indexBuffer;
  13774. private _vertexBuffers;
  13775. /**
  13776. * Creates a new instance PostProcess
  13777. * @param scene The scene that the post process is associated with.
  13778. */
  13779. constructor(scene: Scene);
  13780. private _prepareBuffers;
  13781. private _buildIndexBuffer;
  13782. /**
  13783. * Rebuilds the vertex buffers of the manager.
  13784. * @hidden
  13785. */
  13786. _rebuild(): void;
  13787. /**
  13788. * Prepares a frame to be run through a post process.
  13789. * @param sourceTexture The input texture to the post procesess. (default: null)
  13790. * @param postProcesses An array of post processes to be run. (default: null)
  13791. * @returns True if the post processes were able to be run.
  13792. * @hidden
  13793. */
  13794. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13795. /**
  13796. * Manually render a set of post processes to a texture.
  13797. * @param postProcesses An array of post processes to be run.
  13798. * @param targetTexture The target texture to render to.
  13799. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13800. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13801. * @param lodLevel defines which lod of the texture to render to
  13802. */
  13803. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13804. /**
  13805. * Finalize the result of the output of the postprocesses.
  13806. * @param doNotPresent If true the result will not be displayed to the screen.
  13807. * @param targetTexture The target texture to render to.
  13808. * @param faceIndex The index of the face to bind the target texture to.
  13809. * @param postProcesses The array of post processes to render.
  13810. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13811. * @hidden
  13812. */
  13813. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13814. /**
  13815. * Disposes of the post process manager.
  13816. */
  13817. dispose(): void;
  13818. }
  13819. }
  13820. declare module "babylonjs/Materials/colorCurves" {
  13821. import { Effect } from "babylonjs/Materials/effect";
  13822. /**
  13823. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13824. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13825. * 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;
  13826. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13827. */
  13828. export class ColorCurves {
  13829. private _dirty;
  13830. private _tempColor;
  13831. private _globalCurve;
  13832. private _highlightsCurve;
  13833. private _midtonesCurve;
  13834. private _shadowsCurve;
  13835. private _positiveCurve;
  13836. private _negativeCurve;
  13837. private _globalHue;
  13838. private _globalDensity;
  13839. private _globalSaturation;
  13840. private _globalExposure;
  13841. /**
  13842. * Gets the global Hue value.
  13843. * 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).
  13844. */
  13845. /**
  13846. * Sets the global Hue value.
  13847. * 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).
  13848. */
  13849. globalHue: number;
  13850. /**
  13851. * Gets the global Density value.
  13852. * 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.
  13853. * Values less than zero provide a filter of opposite hue.
  13854. */
  13855. /**
  13856. * Sets the global Density value.
  13857. * 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.
  13858. * Values less than zero provide a filter of opposite hue.
  13859. */
  13860. globalDensity: number;
  13861. /**
  13862. * Gets the global Saturation value.
  13863. * 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.
  13864. */
  13865. /**
  13866. * Sets the global Saturation value.
  13867. * 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.
  13868. */
  13869. globalSaturation: number;
  13870. /**
  13871. * Gets the global Exposure value.
  13872. * 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.
  13873. */
  13874. /**
  13875. * Sets the global Exposure value.
  13876. * 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.
  13877. */
  13878. globalExposure: number;
  13879. private _highlightsHue;
  13880. private _highlightsDensity;
  13881. private _highlightsSaturation;
  13882. private _highlightsExposure;
  13883. /**
  13884. * Gets the highlights Hue value.
  13885. * 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).
  13886. */
  13887. /**
  13888. * Sets the highlights Hue value.
  13889. * 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).
  13890. */
  13891. highlightsHue: number;
  13892. /**
  13893. * Gets the highlights Density value.
  13894. * 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.
  13895. * Values less than zero provide a filter of opposite hue.
  13896. */
  13897. /**
  13898. * Sets the highlights Density value.
  13899. * 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.
  13900. * Values less than zero provide a filter of opposite hue.
  13901. */
  13902. highlightsDensity: number;
  13903. /**
  13904. * Gets the highlights Saturation value.
  13905. * 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.
  13906. */
  13907. /**
  13908. * Sets the highlights Saturation value.
  13909. * 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.
  13910. */
  13911. highlightsSaturation: number;
  13912. /**
  13913. * Gets the highlights Exposure value.
  13914. * 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.
  13915. */
  13916. /**
  13917. * Sets the highlights Exposure value.
  13918. * 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.
  13919. */
  13920. highlightsExposure: number;
  13921. private _midtonesHue;
  13922. private _midtonesDensity;
  13923. private _midtonesSaturation;
  13924. private _midtonesExposure;
  13925. /**
  13926. * Gets the midtones Hue value.
  13927. * 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).
  13928. */
  13929. /**
  13930. * Sets the midtones Hue value.
  13931. * 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).
  13932. */
  13933. midtonesHue: number;
  13934. /**
  13935. * Gets the midtones Density value.
  13936. * 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.
  13937. * Values less than zero provide a filter of opposite hue.
  13938. */
  13939. /**
  13940. * Sets the midtones Density value.
  13941. * 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.
  13942. * Values less than zero provide a filter of opposite hue.
  13943. */
  13944. midtonesDensity: number;
  13945. /**
  13946. * Gets the midtones Saturation value.
  13947. * 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.
  13948. */
  13949. /**
  13950. * Sets the midtones Saturation value.
  13951. * 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.
  13952. */
  13953. midtonesSaturation: number;
  13954. /**
  13955. * Gets the midtones Exposure value.
  13956. * 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.
  13957. */
  13958. /**
  13959. * Sets the midtones Exposure value.
  13960. * 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.
  13961. */
  13962. midtonesExposure: number;
  13963. private _shadowsHue;
  13964. private _shadowsDensity;
  13965. private _shadowsSaturation;
  13966. private _shadowsExposure;
  13967. /**
  13968. * Gets the shadows Hue value.
  13969. * 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).
  13970. */
  13971. /**
  13972. * Sets the shadows Hue value.
  13973. * 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).
  13974. */
  13975. shadowsHue: number;
  13976. /**
  13977. * Gets the shadows Density value.
  13978. * 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.
  13979. * Values less than zero provide a filter of opposite hue.
  13980. */
  13981. /**
  13982. * Sets the shadows Density value.
  13983. * 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.
  13984. * Values less than zero provide a filter of opposite hue.
  13985. */
  13986. shadowsDensity: number;
  13987. /**
  13988. * Gets the shadows Saturation value.
  13989. * 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.
  13990. */
  13991. /**
  13992. * Sets the shadows Saturation value.
  13993. * 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.
  13994. */
  13995. shadowsSaturation: number;
  13996. /**
  13997. * Gets the shadows Exposure value.
  13998. * 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.
  13999. */
  14000. /**
  14001. * Sets the shadows Exposure value.
  14002. * 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.
  14003. */
  14004. shadowsExposure: number;
  14005. /**
  14006. * Returns the class name
  14007. * @returns The class name
  14008. */
  14009. getClassName(): string;
  14010. /**
  14011. * Binds the color curves to the shader.
  14012. * @param colorCurves The color curve to bind
  14013. * @param effect The effect to bind to
  14014. * @param positiveUniform The positive uniform shader parameter
  14015. * @param neutralUniform The neutral uniform shader parameter
  14016. * @param negativeUniform The negative uniform shader parameter
  14017. */
  14018. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  14019. /**
  14020. * Prepare the list of uniforms associated with the ColorCurves effects.
  14021. * @param uniformsList The list of uniforms used in the effect
  14022. */
  14023. static PrepareUniforms(uniformsList: string[]): void;
  14024. /**
  14025. * Returns color grading data based on a hue, density, saturation and exposure value.
  14026. * @param filterHue The hue of the color filter.
  14027. * @param filterDensity The density of the color filter.
  14028. * @param saturation The saturation.
  14029. * @param exposure The exposure.
  14030. * @param result The result data container.
  14031. */
  14032. private getColorGradingDataToRef;
  14033. /**
  14034. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  14035. * @param value The input slider value in range [-100,100].
  14036. * @returns Adjusted value.
  14037. */
  14038. private static applyColorGradingSliderNonlinear;
  14039. /**
  14040. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  14041. * @param hue The hue (H) input.
  14042. * @param saturation The saturation (S) input.
  14043. * @param brightness The brightness (B) input.
  14044. * @result An RGBA color represented as Vector4.
  14045. */
  14046. private static fromHSBToRef;
  14047. /**
  14048. * Returns a value clamped between min and max
  14049. * @param value The value to clamp
  14050. * @param min The minimum of value
  14051. * @param max The maximum of value
  14052. * @returns The clamped value.
  14053. */
  14054. private static clamp;
  14055. /**
  14056. * Clones the current color curve instance.
  14057. * @return The cloned curves
  14058. */
  14059. clone(): ColorCurves;
  14060. /**
  14061. * Serializes the current color curve instance to a json representation.
  14062. * @return a JSON representation
  14063. */
  14064. serialize(): any;
  14065. /**
  14066. * Parses the color curve from a json representation.
  14067. * @param source the JSON source to parse
  14068. * @return The parsed curves
  14069. */
  14070. static Parse(source: any): ColorCurves;
  14071. }
  14072. }
  14073. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  14074. import { Observable } from "babylonjs/Misc/observable";
  14075. import { Nullable } from "babylonjs/types";
  14076. import { Color4 } from "babylonjs/Maths/math";
  14077. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  14078. import { Effect } from "babylonjs/Materials/effect";
  14079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14080. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  14081. /**
  14082. * Interface to follow in your material defines to integrate easily the
  14083. * Image proccessing functions.
  14084. * @hidden
  14085. */
  14086. export interface IImageProcessingConfigurationDefines {
  14087. IMAGEPROCESSING: boolean;
  14088. VIGNETTE: boolean;
  14089. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14090. VIGNETTEBLENDMODEOPAQUE: boolean;
  14091. TONEMAPPING: boolean;
  14092. TONEMAPPING_ACES: boolean;
  14093. CONTRAST: boolean;
  14094. EXPOSURE: boolean;
  14095. COLORCURVES: boolean;
  14096. COLORGRADING: boolean;
  14097. COLORGRADING3D: boolean;
  14098. SAMPLER3DGREENDEPTH: boolean;
  14099. SAMPLER3DBGRMAP: boolean;
  14100. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14101. }
  14102. /**
  14103. * @hidden
  14104. */
  14105. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14106. IMAGEPROCESSING: boolean;
  14107. VIGNETTE: boolean;
  14108. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14109. VIGNETTEBLENDMODEOPAQUE: boolean;
  14110. TONEMAPPING: boolean;
  14111. TONEMAPPING_ACES: boolean;
  14112. CONTRAST: boolean;
  14113. COLORCURVES: boolean;
  14114. COLORGRADING: boolean;
  14115. COLORGRADING3D: boolean;
  14116. SAMPLER3DGREENDEPTH: boolean;
  14117. SAMPLER3DBGRMAP: boolean;
  14118. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14119. EXPOSURE: boolean;
  14120. constructor();
  14121. }
  14122. /**
  14123. * This groups together the common properties used for image processing either in direct forward pass
  14124. * or through post processing effect depending on the use of the image processing pipeline in your scene
  14125. * or not.
  14126. */
  14127. export class ImageProcessingConfiguration {
  14128. /**
  14129. * Default tone mapping applied in BabylonJS.
  14130. */
  14131. static readonly TONEMAPPING_STANDARD: number;
  14132. /**
  14133. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  14134. * to other engines rendering to increase portability.
  14135. */
  14136. static readonly TONEMAPPING_ACES: number;
  14137. /**
  14138. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  14139. */
  14140. colorCurves: Nullable<ColorCurves>;
  14141. private _colorCurvesEnabled;
  14142. /**
  14143. * Gets wether the color curves effect is enabled.
  14144. */
  14145. /**
  14146. * Sets wether the color curves effect is enabled.
  14147. */
  14148. colorCurvesEnabled: boolean;
  14149. private _colorGradingTexture;
  14150. /**
  14151. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14152. */
  14153. /**
  14154. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14155. */
  14156. colorGradingTexture: Nullable<BaseTexture>;
  14157. private _colorGradingEnabled;
  14158. /**
  14159. * Gets wether the color grading effect is enabled.
  14160. */
  14161. /**
  14162. * Sets wether the color grading effect is enabled.
  14163. */
  14164. colorGradingEnabled: boolean;
  14165. private _colorGradingWithGreenDepth;
  14166. /**
  14167. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  14168. */
  14169. /**
  14170. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  14171. */
  14172. colorGradingWithGreenDepth: boolean;
  14173. private _colorGradingBGR;
  14174. /**
  14175. * Gets wether the color grading texture contains BGR values.
  14176. */
  14177. /**
  14178. * Sets wether the color grading texture contains BGR values.
  14179. */
  14180. colorGradingBGR: boolean;
  14181. /** @hidden */
  14182. _exposure: number;
  14183. /**
  14184. * Gets the Exposure used in the effect.
  14185. */
  14186. /**
  14187. * Sets the Exposure used in the effect.
  14188. */
  14189. exposure: number;
  14190. private _toneMappingEnabled;
  14191. /**
  14192. * Gets wether the tone mapping effect is enabled.
  14193. */
  14194. /**
  14195. * Sets wether the tone mapping effect is enabled.
  14196. */
  14197. toneMappingEnabled: boolean;
  14198. private _toneMappingType;
  14199. /**
  14200. * Gets the type of tone mapping effect.
  14201. */
  14202. /**
  14203. * Sets the type of tone mapping effect used in BabylonJS.
  14204. */
  14205. toneMappingType: number;
  14206. protected _contrast: number;
  14207. /**
  14208. * Gets the contrast used in the effect.
  14209. */
  14210. /**
  14211. * Sets the contrast used in the effect.
  14212. */
  14213. contrast: number;
  14214. /**
  14215. * Vignette stretch size.
  14216. */
  14217. vignetteStretch: number;
  14218. /**
  14219. * Vignette centre X Offset.
  14220. */
  14221. vignetteCentreX: number;
  14222. /**
  14223. * Vignette centre Y Offset.
  14224. */
  14225. vignetteCentreY: number;
  14226. /**
  14227. * Vignette weight or intensity of the vignette effect.
  14228. */
  14229. vignetteWeight: number;
  14230. /**
  14231. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14232. * if vignetteEnabled is set to true.
  14233. */
  14234. vignetteColor: Color4;
  14235. /**
  14236. * Camera field of view used by the Vignette effect.
  14237. */
  14238. vignetteCameraFov: number;
  14239. private _vignetteBlendMode;
  14240. /**
  14241. * Gets the vignette blend mode allowing different kind of effect.
  14242. */
  14243. /**
  14244. * Sets the vignette blend mode allowing different kind of effect.
  14245. */
  14246. vignetteBlendMode: number;
  14247. private _vignetteEnabled;
  14248. /**
  14249. * Gets wether the vignette effect is enabled.
  14250. */
  14251. /**
  14252. * Sets wether the vignette effect is enabled.
  14253. */
  14254. vignetteEnabled: boolean;
  14255. private _applyByPostProcess;
  14256. /**
  14257. * Gets wether the image processing is applied through a post process or not.
  14258. */
  14259. /**
  14260. * Sets wether the image processing is applied through a post process or not.
  14261. */
  14262. applyByPostProcess: boolean;
  14263. private _isEnabled;
  14264. /**
  14265. * Gets wether the image processing is enabled or not.
  14266. */
  14267. /**
  14268. * Sets wether the image processing is enabled or not.
  14269. */
  14270. isEnabled: boolean;
  14271. /**
  14272. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14273. */
  14274. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14275. /**
  14276. * Method called each time the image processing information changes requires to recompile the effect.
  14277. */
  14278. protected _updateParameters(): void;
  14279. /**
  14280. * Gets the current class name.
  14281. * @return "ImageProcessingConfiguration"
  14282. */
  14283. getClassName(): string;
  14284. /**
  14285. * Prepare the list of uniforms associated with the Image Processing effects.
  14286. * @param uniforms The list of uniforms used in the effect
  14287. * @param defines the list of defines currently in use
  14288. */
  14289. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14290. /**
  14291. * Prepare the list of samplers associated with the Image Processing effects.
  14292. * @param samplersList The list of uniforms used in the effect
  14293. * @param defines the list of defines currently in use
  14294. */
  14295. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14296. /**
  14297. * Prepare the list of defines associated to the shader.
  14298. * @param defines the list of defines to complete
  14299. * @param forPostProcess Define if we are currently in post process mode or not
  14300. */
  14301. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14302. /**
  14303. * Returns true if all the image processing information are ready.
  14304. * @returns True if ready, otherwise, false
  14305. */
  14306. isReady(): boolean;
  14307. /**
  14308. * Binds the image processing to the shader.
  14309. * @param effect The effect to bind to
  14310. * @param aspectRatio Define the current aspect ratio of the effect
  14311. */
  14312. bind(effect: Effect, aspectRatio?: number): void;
  14313. /**
  14314. * Clones the current image processing instance.
  14315. * @return The cloned image processing
  14316. */
  14317. clone(): ImageProcessingConfiguration;
  14318. /**
  14319. * Serializes the current image processing instance to a json representation.
  14320. * @return a JSON representation
  14321. */
  14322. serialize(): any;
  14323. /**
  14324. * Parses the image processing from a json representation.
  14325. * @param source the JSON source to parse
  14326. * @return The parsed image processing
  14327. */
  14328. static Parse(source: any): ImageProcessingConfiguration;
  14329. private static _VIGNETTEMODE_MULTIPLY;
  14330. private static _VIGNETTEMODE_OPAQUE;
  14331. /**
  14332. * Used to apply the vignette as a mix with the pixel color.
  14333. */
  14334. static readonly VIGNETTEMODE_MULTIPLY: number;
  14335. /**
  14336. * Used to apply the vignette as a replacement of the pixel color.
  14337. */
  14338. static readonly VIGNETTEMODE_OPAQUE: number;
  14339. }
  14340. }
  14341. declare module "babylonjs/Layers/layerSceneComponent" {
  14342. import { Scene } from "babylonjs/scene";
  14343. import { ISceneComponent } from "babylonjs/sceneComponent";
  14344. import { Layer } from "babylonjs/Layers/layer";
  14345. module "babylonjs/abstractScene" {
  14346. interface AbstractScene {
  14347. /**
  14348. * The list of layers (background and foreground) of the scene
  14349. */
  14350. layers: Array<Layer>;
  14351. }
  14352. }
  14353. /**
  14354. * Defines the layer scene component responsible to manage any layers
  14355. * in a given scene.
  14356. */
  14357. export class LayerSceneComponent implements ISceneComponent {
  14358. /**
  14359. * The component name helpfull to identify the component in the list of scene components.
  14360. */
  14361. readonly name: string;
  14362. /**
  14363. * The scene the component belongs to.
  14364. */
  14365. scene: Scene;
  14366. private _engine;
  14367. /**
  14368. * Creates a new instance of the component for the given scene
  14369. * @param scene Defines the scene to register the component in
  14370. */
  14371. constructor(scene: Scene);
  14372. /**
  14373. * Registers the component in a given scene
  14374. */
  14375. register(): void;
  14376. /**
  14377. * Rebuilds the elements related to this component in case of
  14378. * context lost for instance.
  14379. */
  14380. rebuild(): void;
  14381. /**
  14382. * Disposes the component and the associated ressources.
  14383. */
  14384. dispose(): void;
  14385. private _draw;
  14386. private _drawCameraPredicate;
  14387. private _drawCameraBackground;
  14388. private _drawCameraForeground;
  14389. private _drawRenderTargetPredicate;
  14390. private _drawRenderTargetBackground;
  14391. private _drawRenderTargetForeground;
  14392. }
  14393. }
  14394. declare module "babylonjs/Shaders/layer.fragment" {
  14395. export var layerPixelShader: {
  14396. name: string;
  14397. shader: string;
  14398. };
  14399. }
  14400. declare module "babylonjs/Shaders/layer.vertex" {
  14401. export var layerVertexShader: {
  14402. name: string;
  14403. shader: string;
  14404. };
  14405. }
  14406. declare module "babylonjs/Layers/layer" {
  14407. import { Observable } from "babylonjs/Misc/observable";
  14408. import { Nullable } from "babylonjs/types";
  14409. import { Scene } from "babylonjs/scene";
  14410. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14411. import { Texture } from "babylonjs/Materials/Textures/texture";
  14412. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14413. import "Shaders/layer.fragment";
  14414. import "Shaders/layer.vertex";
  14415. /**
  14416. * This represents a full screen 2d layer.
  14417. * This can be useful to display a picture in the background of your scene for instance.
  14418. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14419. */
  14420. export class Layer {
  14421. /**
  14422. * Define the name of the layer.
  14423. */
  14424. name: string;
  14425. /**
  14426. * Define the texture the layer should display.
  14427. */
  14428. texture: Nullable<Texture>;
  14429. /**
  14430. * Is the layer in background or foreground.
  14431. */
  14432. isBackground: boolean;
  14433. /**
  14434. * Define the color of the layer (instead of texture).
  14435. */
  14436. color: Color4;
  14437. /**
  14438. * Define the scale of the layer in order to zoom in out of the texture.
  14439. */
  14440. scale: Vector2;
  14441. /**
  14442. * Define an offset for the layer in order to shift the texture.
  14443. */
  14444. offset: Vector2;
  14445. /**
  14446. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14447. */
  14448. alphaBlendingMode: number;
  14449. /**
  14450. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14451. * Alpha test will not mix with the background color in case of transparency.
  14452. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14453. */
  14454. alphaTest: boolean;
  14455. /**
  14456. * Define a mask to restrict the layer to only some of the scene cameras.
  14457. */
  14458. layerMask: number;
  14459. /**
  14460. * Define the list of render target the layer is visible into.
  14461. */
  14462. renderTargetTextures: RenderTargetTexture[];
  14463. /**
  14464. * Define if the layer is only used in renderTarget or if it also
  14465. * renders in the main frame buffer of the canvas.
  14466. */
  14467. renderOnlyInRenderTargetTextures: boolean;
  14468. private _scene;
  14469. private _vertexBuffers;
  14470. private _indexBuffer;
  14471. private _effect;
  14472. private _alphaTestEffect;
  14473. /**
  14474. * An event triggered when the layer is disposed.
  14475. */
  14476. onDisposeObservable: Observable<Layer>;
  14477. private _onDisposeObserver;
  14478. /**
  14479. * Back compatibility with callback before the onDisposeObservable existed.
  14480. * The set callback will be triggered when the layer has been disposed.
  14481. */
  14482. onDispose: () => void;
  14483. /**
  14484. * An event triggered before rendering the scene
  14485. */
  14486. onBeforeRenderObservable: Observable<Layer>;
  14487. private _onBeforeRenderObserver;
  14488. /**
  14489. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14490. * The set callback will be triggered just before rendering the layer.
  14491. */
  14492. onBeforeRender: () => void;
  14493. /**
  14494. * An event triggered after rendering the scene
  14495. */
  14496. onAfterRenderObservable: Observable<Layer>;
  14497. private _onAfterRenderObserver;
  14498. /**
  14499. * Back compatibility with callback before the onAfterRenderObservable existed.
  14500. * The set callback will be triggered just after rendering the layer.
  14501. */
  14502. onAfterRender: () => void;
  14503. /**
  14504. * Instantiates a new layer.
  14505. * This represents a full screen 2d layer.
  14506. * This can be useful to display a picture in the background of your scene for instance.
  14507. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14508. * @param name Define the name of the layer in the scene
  14509. * @param imgUrl Define the url of the texture to display in the layer
  14510. * @param scene Define the scene the layer belongs to
  14511. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14512. * @param color Defines a color for the layer
  14513. */
  14514. constructor(
  14515. /**
  14516. * Define the name of the layer.
  14517. */
  14518. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14519. private _createIndexBuffer;
  14520. /** @hidden */
  14521. _rebuild(): void;
  14522. /**
  14523. * Renders the layer in the scene.
  14524. */
  14525. render(): void;
  14526. /**
  14527. * Disposes and releases the associated ressources.
  14528. */
  14529. dispose(): void;
  14530. }
  14531. }
  14532. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14533. import { Scene } from "babylonjs/scene";
  14534. import { ISceneComponent } from "babylonjs/sceneComponent";
  14535. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14536. module "babylonjs/abstractScene" {
  14537. interface AbstractScene {
  14538. /**
  14539. * The list of procedural textures added to the scene
  14540. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14541. */
  14542. proceduralTextures: Array<ProceduralTexture>;
  14543. }
  14544. }
  14545. /**
  14546. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14547. * in a given scene.
  14548. */
  14549. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14550. /**
  14551. * The component name helpfull to identify the component in the list of scene components.
  14552. */
  14553. readonly name: string;
  14554. /**
  14555. * The scene the component belongs to.
  14556. */
  14557. scene: Scene;
  14558. /**
  14559. * Creates a new instance of the component for the given scene
  14560. * @param scene Defines the scene to register the component in
  14561. */
  14562. constructor(scene: Scene);
  14563. /**
  14564. * Registers the component in a given scene
  14565. */
  14566. register(): void;
  14567. /**
  14568. * Rebuilds the elements related to this component in case of
  14569. * context lost for instance.
  14570. */
  14571. rebuild(): void;
  14572. /**
  14573. * Disposes the component and the associated ressources.
  14574. */
  14575. dispose(): void;
  14576. private _beforeClear;
  14577. }
  14578. }
  14579. declare module "babylonjs/Shaders/procedural.vertex" {
  14580. export var proceduralVertexShader: {
  14581. name: string;
  14582. shader: string;
  14583. };
  14584. }
  14585. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14586. import { Observable } from "babylonjs/Misc/observable";
  14587. import { Nullable } from "babylonjs/types";
  14588. import { Scene } from "babylonjs/scene";
  14589. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14590. import { Effect } from "babylonjs/Materials/effect";
  14591. import { Texture } from "babylonjs/Materials/Textures/texture";
  14592. import "Shaders/procedural.vertex";
  14593. /**
  14594. * 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.
  14595. * This is the base class of any Procedural texture and contains most of the shareable code.
  14596. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14597. */
  14598. export class ProceduralTexture extends Texture {
  14599. isCube: boolean;
  14600. /**
  14601. * Define if the texture is enabled or not (disabled texture will not render)
  14602. */
  14603. isEnabled: boolean;
  14604. /**
  14605. * Define if the texture must be cleared before rendering (default is true)
  14606. */
  14607. autoClear: boolean;
  14608. /**
  14609. * Callback called when the texture is generated
  14610. */
  14611. onGenerated: () => void;
  14612. /**
  14613. * Event raised when the texture is generated
  14614. */
  14615. onGeneratedObservable: Observable<ProceduralTexture>;
  14616. /** @hidden */
  14617. _generateMipMaps: boolean;
  14618. /** @hidden **/
  14619. _effect: Effect;
  14620. /** @hidden */
  14621. _textures: {
  14622. [key: string]: Texture;
  14623. };
  14624. private _size;
  14625. private _currentRefreshId;
  14626. private _refreshRate;
  14627. private _vertexBuffers;
  14628. private _indexBuffer;
  14629. private _uniforms;
  14630. private _samplers;
  14631. private _fragment;
  14632. private _floats;
  14633. private _ints;
  14634. private _floatsArrays;
  14635. private _colors3;
  14636. private _colors4;
  14637. private _vectors2;
  14638. private _vectors3;
  14639. private _matrices;
  14640. private _fallbackTexture;
  14641. private _fallbackTextureUsed;
  14642. private _engine;
  14643. private _cachedDefines;
  14644. private _contentUpdateId;
  14645. private _contentData;
  14646. /**
  14647. * Instantiates a new procedural texture.
  14648. * 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.
  14649. * This is the base class of any Procedural texture and contains most of the shareable code.
  14650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14651. * @param name Define the name of the texture
  14652. * @param size Define the size of the texture to create
  14653. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14654. * @param scene Define the scene the texture belongs to
  14655. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14656. * @param generateMipMaps Define if the texture should creates mip maps or not
  14657. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14658. */
  14659. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14660. /**
  14661. * The effect that is created when initializing the post process.
  14662. * @returns The created effect corrisponding the the postprocess.
  14663. */
  14664. getEffect(): Effect;
  14665. /**
  14666. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14667. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14668. */
  14669. getContent(): Nullable<ArrayBufferView>;
  14670. private _createIndexBuffer;
  14671. /** @hidden */
  14672. _rebuild(): void;
  14673. /**
  14674. * Resets the texture in order to recreate its associated resources.
  14675. * This can be called in case of context loss
  14676. */
  14677. reset(): void;
  14678. protected _getDefines(): string;
  14679. /**
  14680. * Is the texture ready to be used ? (rendered at least once)
  14681. * @returns true if ready, otherwise, false.
  14682. */
  14683. isReady(): boolean;
  14684. /**
  14685. * Resets the refresh counter of the texture and start bak from scratch.
  14686. * Could be useful to regenerate the texture if it is setup to render only once.
  14687. */
  14688. resetRefreshCounter(): void;
  14689. /**
  14690. * Set the fragment shader to use in order to render the texture.
  14691. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14692. */
  14693. setFragment(fragment: any): void;
  14694. /**
  14695. * Define the refresh rate of the texture or the rendering frequency.
  14696. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14697. */
  14698. refreshRate: number;
  14699. /** @hidden */
  14700. _shouldRender(): boolean;
  14701. /**
  14702. * Get the size the texture is rendering at.
  14703. * @returns the size (texture is always squared)
  14704. */
  14705. getRenderSize(): number;
  14706. /**
  14707. * Resize the texture to new value.
  14708. * @param size Define the new size the texture should have
  14709. * @param generateMipMaps Define whether the new texture should create mip maps
  14710. */
  14711. resize(size: number, generateMipMaps: boolean): void;
  14712. private _checkUniform;
  14713. /**
  14714. * Set a texture in the shader program used to render.
  14715. * @param name Define the name of the uniform samplers as defined in the shader
  14716. * @param texture Define the texture to bind to this sampler
  14717. * @return the texture itself allowing "fluent" like uniform updates
  14718. */
  14719. setTexture(name: string, texture: Texture): ProceduralTexture;
  14720. /**
  14721. * Set a float in the shader.
  14722. * @param name Define the name of the uniform as defined in the shader
  14723. * @param value Define the value to give to the uniform
  14724. * @return the texture itself allowing "fluent" like uniform updates
  14725. */
  14726. setFloat(name: string, value: number): ProceduralTexture;
  14727. /**
  14728. * Set a int in the shader.
  14729. * @param name Define the name of the uniform as defined in the shader
  14730. * @param value Define the value to give to the uniform
  14731. * @return the texture itself allowing "fluent" like uniform updates
  14732. */
  14733. setInt(name: string, value: number): ProceduralTexture;
  14734. /**
  14735. * Set an array of floats in the shader.
  14736. * @param name Define the name of the uniform as defined in the shader
  14737. * @param value Define the value to give to the uniform
  14738. * @return the texture itself allowing "fluent" like uniform updates
  14739. */
  14740. setFloats(name: string, value: number[]): ProceduralTexture;
  14741. /**
  14742. * Set a vec3 in the shader from a Color3.
  14743. * @param name Define the name of the uniform as defined in the shader
  14744. * @param value Define the value to give to the uniform
  14745. * @return the texture itself allowing "fluent" like uniform updates
  14746. */
  14747. setColor3(name: string, value: Color3): ProceduralTexture;
  14748. /**
  14749. * Set a vec4 in the shader from a Color4.
  14750. * @param name Define the name of the uniform as defined in the shader
  14751. * @param value Define the value to give to the uniform
  14752. * @return the texture itself allowing "fluent" like uniform updates
  14753. */
  14754. setColor4(name: string, value: Color4): ProceduralTexture;
  14755. /**
  14756. * Set a vec2 in the shader from a Vector2.
  14757. * @param name Define the name of the uniform as defined in the shader
  14758. * @param value Define the value to give to the uniform
  14759. * @return the texture itself allowing "fluent" like uniform updates
  14760. */
  14761. setVector2(name: string, value: Vector2): ProceduralTexture;
  14762. /**
  14763. * Set a vec3 in the shader from a Vector3.
  14764. * @param name Define the name of the uniform as defined in the shader
  14765. * @param value Define the value to give to the uniform
  14766. * @return the texture itself allowing "fluent" like uniform updates
  14767. */
  14768. setVector3(name: string, value: Vector3): ProceduralTexture;
  14769. /**
  14770. * Set a mat4 in the shader from a MAtrix.
  14771. * @param name Define the name of the uniform as defined in the shader
  14772. * @param value Define the value to give to the uniform
  14773. * @return the texture itself allowing "fluent" like uniform updates
  14774. */
  14775. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14776. /**
  14777. * Render the texture to its associated render target.
  14778. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14779. */
  14780. render(useCameraPostProcess?: boolean): void;
  14781. /**
  14782. * Clone the texture.
  14783. * @returns the cloned texture
  14784. */
  14785. clone(): ProceduralTexture;
  14786. /**
  14787. * Dispose the texture and release its asoociated resources.
  14788. */
  14789. dispose(): void;
  14790. }
  14791. }
  14792. declare module "babylonjs/Particles/baseParticleSystem" {
  14793. import { Nullable } from "babylonjs/types";
  14794. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14796. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14797. import { Texture } from "babylonjs/Materials/Textures/texture";
  14798. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14799. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14800. import { Scene } from "babylonjs/scene";
  14801. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14802. import { Animation } from "babylonjs/Animations/animation";
  14803. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14804. /**
  14805. * This represents the base class for particle system in Babylon.
  14806. * 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.
  14807. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14808. * @example https://doc.babylonjs.com/babylon101/particles
  14809. */
  14810. export class BaseParticleSystem {
  14811. /**
  14812. * Source color is added to the destination color without alpha affecting the result
  14813. */
  14814. static BLENDMODE_ONEONE: number;
  14815. /**
  14816. * Blend current color and particle color using particle’s alpha
  14817. */
  14818. static BLENDMODE_STANDARD: number;
  14819. /**
  14820. * Add current color and particle color multiplied by particle’s alpha
  14821. */
  14822. static BLENDMODE_ADD: number;
  14823. /**
  14824. * Multiply current color with particle color
  14825. */
  14826. static BLENDMODE_MULTIPLY: number;
  14827. /**
  14828. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14829. */
  14830. static BLENDMODE_MULTIPLYADD: number;
  14831. /**
  14832. * List of animations used by the particle system.
  14833. */
  14834. animations: Animation[];
  14835. /**
  14836. * The id of the Particle system.
  14837. */
  14838. id: string;
  14839. /**
  14840. * The friendly name of the Particle system.
  14841. */
  14842. name: string;
  14843. /**
  14844. * The rendering group used by the Particle system to chose when to render.
  14845. */
  14846. renderingGroupId: number;
  14847. /**
  14848. * The emitter represents the Mesh or position we are attaching the particle system to.
  14849. */
  14850. emitter: Nullable<AbstractMesh | Vector3>;
  14851. /**
  14852. * The maximum number of particles to emit per frame
  14853. */
  14854. emitRate: number;
  14855. /**
  14856. * If you want to launch only a few particles at once, that can be done, as well.
  14857. */
  14858. manualEmitCount: number;
  14859. /**
  14860. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14861. */
  14862. updateSpeed: number;
  14863. /**
  14864. * The amount of time the particle system is running (depends of the overall update speed).
  14865. */
  14866. targetStopDuration: number;
  14867. /**
  14868. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14869. */
  14870. disposeOnStop: boolean;
  14871. /**
  14872. * Minimum power of emitting particles.
  14873. */
  14874. minEmitPower: number;
  14875. /**
  14876. * Maximum power of emitting particles.
  14877. */
  14878. maxEmitPower: number;
  14879. /**
  14880. * Minimum life time of emitting particles.
  14881. */
  14882. minLifeTime: number;
  14883. /**
  14884. * Maximum life time of emitting particles.
  14885. */
  14886. maxLifeTime: number;
  14887. /**
  14888. * Minimum Size of emitting particles.
  14889. */
  14890. minSize: number;
  14891. /**
  14892. * Maximum Size of emitting particles.
  14893. */
  14894. maxSize: number;
  14895. /**
  14896. * Minimum scale of emitting particles on X axis.
  14897. */
  14898. minScaleX: number;
  14899. /**
  14900. * Maximum scale of emitting particles on X axis.
  14901. */
  14902. maxScaleX: number;
  14903. /**
  14904. * Minimum scale of emitting particles on Y axis.
  14905. */
  14906. minScaleY: number;
  14907. /**
  14908. * Maximum scale of emitting particles on Y axis.
  14909. */
  14910. maxScaleY: number;
  14911. /**
  14912. * Gets or sets the minimal initial rotation in radians.
  14913. */
  14914. minInitialRotation: number;
  14915. /**
  14916. * Gets or sets the maximal initial rotation in radians.
  14917. */
  14918. maxInitialRotation: number;
  14919. /**
  14920. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14921. */
  14922. minAngularSpeed: number;
  14923. /**
  14924. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14925. */
  14926. maxAngularSpeed: number;
  14927. /**
  14928. * The texture used to render each particle. (this can be a spritesheet)
  14929. */
  14930. particleTexture: Nullable<Texture>;
  14931. /**
  14932. * The layer mask we are rendering the particles through.
  14933. */
  14934. layerMask: number;
  14935. /**
  14936. * This can help using your own shader to render the particle system.
  14937. * The according effect will be created
  14938. */
  14939. customShader: any;
  14940. /**
  14941. * By default particle system starts as soon as they are created. This prevents the
  14942. * automatic start to happen and let you decide when to start emitting particles.
  14943. */
  14944. preventAutoStart: boolean;
  14945. private _noiseTexture;
  14946. /**
  14947. * Gets or sets a texture used to add random noise to particle positions
  14948. */
  14949. noiseTexture: Nullable<ProceduralTexture>;
  14950. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14951. noiseStrength: Vector3;
  14952. /**
  14953. * Callback triggered when the particle animation is ending.
  14954. */
  14955. onAnimationEnd: Nullable<() => void>;
  14956. /**
  14957. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14958. */
  14959. blendMode: number;
  14960. /**
  14961. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14962. * to override the particles.
  14963. */
  14964. forceDepthWrite: boolean;
  14965. /** 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 */
  14966. preWarmCycles: number;
  14967. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14968. preWarmStepOffset: number;
  14969. /**
  14970. * 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)
  14971. */
  14972. spriteCellChangeSpeed: number;
  14973. /**
  14974. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14975. */
  14976. startSpriteCellID: number;
  14977. /**
  14978. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14979. */
  14980. endSpriteCellID: number;
  14981. /**
  14982. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14983. */
  14984. spriteCellWidth: number;
  14985. /**
  14986. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14987. */
  14988. spriteCellHeight: number;
  14989. /**
  14990. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14991. */
  14992. spriteRandomStartCell: boolean;
  14993. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14994. translationPivot: Vector2;
  14995. /** @hidden */
  14996. protected _isAnimationSheetEnabled: boolean;
  14997. /**
  14998. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14999. */
  15000. beginAnimationOnStart: boolean;
  15001. /**
  15002. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15003. */
  15004. beginAnimationFrom: number;
  15005. /**
  15006. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15007. */
  15008. beginAnimationTo: number;
  15009. /**
  15010. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15011. */
  15012. beginAnimationLoop: boolean;
  15013. /**
  15014. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15015. */
  15016. isAnimationSheetEnabled: boolean;
  15017. /**
  15018. * Get hosting scene
  15019. * @returns the scene
  15020. */
  15021. getScene(): Scene;
  15022. /**
  15023. * You can use gravity if you want to give an orientation to your particles.
  15024. */
  15025. gravity: Vector3;
  15026. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15027. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15028. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15029. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15030. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15031. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15032. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15033. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15034. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15035. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15036. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15037. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15038. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15039. /**
  15040. * Defines the delay in milliseconds before starting the system (0 by default)
  15041. */
  15042. startDelay: number;
  15043. /**
  15044. * Gets the current list of drag gradients.
  15045. * You must use addDragGradient and removeDragGradient to udpate this list
  15046. * @returns the list of drag gradients
  15047. */
  15048. getDragGradients(): Nullable<Array<FactorGradient>>;
  15049. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15050. limitVelocityDamping: number;
  15051. /**
  15052. * Gets the current list of limit velocity gradients.
  15053. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15054. * @returns the list of limit velocity gradients
  15055. */
  15056. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15057. /**
  15058. * Gets the current list of color gradients.
  15059. * You must use addColorGradient and removeColorGradient to udpate this list
  15060. * @returns the list of color gradients
  15061. */
  15062. getColorGradients(): Nullable<Array<ColorGradient>>;
  15063. /**
  15064. * Gets the current list of size gradients.
  15065. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15066. * @returns the list of size gradients
  15067. */
  15068. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15069. /**
  15070. * Gets the current list of color remap gradients.
  15071. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15072. * @returns the list of color remap gradients
  15073. */
  15074. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15075. /**
  15076. * Gets the current list of alpha remap gradients.
  15077. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15078. * @returns the list of alpha remap gradients
  15079. */
  15080. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15081. /**
  15082. * Gets the current list of life time gradients.
  15083. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15084. * @returns the list of life time gradients
  15085. */
  15086. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15087. /**
  15088. * Gets the current list of angular speed gradients.
  15089. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15090. * @returns the list of angular speed gradients
  15091. */
  15092. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15093. /**
  15094. * Gets the current list of velocity gradients.
  15095. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15096. * @returns the list of velocity gradients
  15097. */
  15098. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15099. /**
  15100. * Gets the current list of start size gradients.
  15101. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15102. * @returns the list of start size gradients
  15103. */
  15104. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15105. /**
  15106. * Gets the current list of emit rate gradients.
  15107. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15108. * @returns the list of emit rate gradients
  15109. */
  15110. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15111. /**
  15112. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15113. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15114. */
  15115. direction1: Vector3;
  15116. /**
  15117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15118. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15119. */
  15120. direction2: Vector3;
  15121. /**
  15122. * 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.
  15123. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15124. */
  15125. minEmitBox: Vector3;
  15126. /**
  15127. * 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.
  15128. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15129. */
  15130. maxEmitBox: Vector3;
  15131. /**
  15132. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15133. */
  15134. color1: Color4;
  15135. /**
  15136. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15137. */
  15138. color2: Color4;
  15139. /**
  15140. * Color the particle will have at the end of its lifetime
  15141. */
  15142. colorDead: Color4;
  15143. /**
  15144. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15145. */
  15146. textureMask: Color4;
  15147. /**
  15148. * The particle emitter type defines the emitter used by the particle system.
  15149. * It can be for example box, sphere, or cone...
  15150. */
  15151. particleEmitterType: IParticleEmitterType;
  15152. /** @hidden */
  15153. _isSubEmitter: boolean;
  15154. /**
  15155. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15156. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15157. */
  15158. billboardMode: number;
  15159. protected _isBillboardBased: boolean;
  15160. /**
  15161. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15162. */
  15163. isBillboardBased: boolean;
  15164. /**
  15165. * The scene the particle system belongs to.
  15166. */
  15167. protected _scene: Scene;
  15168. /**
  15169. * Local cache of defines for image processing.
  15170. */
  15171. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15172. /**
  15173. * Default configuration related to image processing available in the standard Material.
  15174. */
  15175. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15176. /**
  15177. * Gets the image processing configuration used either in this material.
  15178. */
  15179. /**
  15180. * Sets the Default image processing configuration used either in the this material.
  15181. *
  15182. * If sets to null, the scene one is in use.
  15183. */
  15184. imageProcessingConfiguration: ImageProcessingConfiguration;
  15185. /**
  15186. * Attaches a new image processing configuration to the Standard Material.
  15187. * @param configuration
  15188. */
  15189. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15190. /** @hidden */
  15191. protected _reset(): void;
  15192. /** @hidden */
  15193. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15194. /**
  15195. * Instantiates a particle system.
  15196. * 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.
  15197. * @param name The name of the particle system
  15198. */
  15199. constructor(name: string);
  15200. /**
  15201. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15202. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15203. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15204. * @returns the emitter
  15205. */
  15206. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15207. /**
  15208. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15209. * @param radius The radius of the hemisphere to emit from
  15210. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15211. * @returns the emitter
  15212. */
  15213. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15214. /**
  15215. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15216. * @param radius The radius of the sphere to emit from
  15217. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15218. * @returns the emitter
  15219. */
  15220. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15221. /**
  15222. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15223. * @param radius The radius of the sphere to emit from
  15224. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15225. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15226. * @returns the emitter
  15227. */
  15228. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15229. /**
  15230. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15231. * @param radius The radius of the emission cylinder
  15232. * @param height The height of the emission cylinder
  15233. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15234. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15235. * @returns the emitter
  15236. */
  15237. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15238. /**
  15239. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15240. * @param radius The radius of the cylinder to emit from
  15241. * @param height The height of the emission cylinder
  15242. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15243. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15244. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15245. * @returns the emitter
  15246. */
  15247. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15248. /**
  15249. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15250. * @param radius The radius of the cone to emit from
  15251. * @param angle The base angle of the cone
  15252. * @returns the emitter
  15253. */
  15254. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15255. /**
  15256. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15257. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15258. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15259. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15260. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15261. * @returns the emitter
  15262. */
  15263. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15264. }
  15265. }
  15266. declare module "babylonjs/Particles/subEmitter" {
  15267. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15268. import { Scene } from "babylonjs/scene";
  15269. /**
  15270. * Type of sub emitter
  15271. */
  15272. export enum SubEmitterType {
  15273. /**
  15274. * Attached to the particle over it's lifetime
  15275. */
  15276. ATTACHED = 0,
  15277. /**
  15278. * Created when the particle dies
  15279. */
  15280. END = 1
  15281. }
  15282. /**
  15283. * Sub emitter class used to emit particles from an existing particle
  15284. */
  15285. export class SubEmitter {
  15286. /**
  15287. * the particle system to be used by the sub emitter
  15288. */
  15289. particleSystem: ParticleSystem;
  15290. /**
  15291. * Type of the submitter (Default: END)
  15292. */
  15293. type: SubEmitterType;
  15294. /**
  15295. * 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)
  15296. * Note: This only is supported when using an emitter of type Mesh
  15297. */
  15298. inheritDirection: boolean;
  15299. /**
  15300. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15301. */
  15302. inheritedVelocityAmount: number;
  15303. /**
  15304. * Creates a sub emitter
  15305. * @param particleSystem the particle system to be used by the sub emitter
  15306. */
  15307. constructor(
  15308. /**
  15309. * the particle system to be used by the sub emitter
  15310. */
  15311. particleSystem: ParticleSystem);
  15312. /**
  15313. * Clones the sub emitter
  15314. * @returns the cloned sub emitter
  15315. */
  15316. clone(): SubEmitter;
  15317. /**
  15318. * Serialize current object to a JSON object
  15319. * @returns the serialized object
  15320. */
  15321. serialize(): any;
  15322. /**
  15323. * Creates a new SubEmitter from a serialized JSON version
  15324. * @param serializationObject defines the JSON object to read from
  15325. * @param scene defines the hosting scene
  15326. * @param rootUrl defines the rootUrl for data loading
  15327. * @returns a new SubEmitter
  15328. */
  15329. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15330. /** Release associated resources */
  15331. dispose(): void;
  15332. }
  15333. }
  15334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15335. export var clipPlaneFragmentDeclaration: {
  15336. name: string;
  15337. shader: string;
  15338. };
  15339. }
  15340. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15341. export var imageProcessingDeclaration: {
  15342. name: string;
  15343. shader: string;
  15344. };
  15345. }
  15346. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15347. export var imageProcessingFunctions: {
  15348. name: string;
  15349. shader: string;
  15350. };
  15351. }
  15352. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15353. export var clipPlaneFragment: {
  15354. name: string;
  15355. shader: string;
  15356. };
  15357. }
  15358. declare module "babylonjs/Shaders/particles.fragment" {
  15359. import "Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15360. import "Shaders/ShadersInclude/imageProcessingDeclaration";
  15361. import "Shaders/ShadersInclude/helperFunctions";
  15362. import "Shaders/ShadersInclude/imageProcessingFunctions";
  15363. import "Shaders/ShadersInclude/clipPlaneFragment";
  15364. export var particlesPixelShader: {
  15365. name: string;
  15366. shader: string;
  15367. };
  15368. }
  15369. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15370. export var clipPlaneVertexDeclaration: {
  15371. name: string;
  15372. shader: string;
  15373. };
  15374. }
  15375. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15376. export var clipPlaneVertex: {
  15377. name: string;
  15378. shader: string;
  15379. };
  15380. }
  15381. declare module "babylonjs/Shaders/particles.vertex" {
  15382. import "Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15383. import "Shaders/ShadersInclude/clipPlaneVertex";
  15384. export var particlesVertexShader: {
  15385. name: string;
  15386. shader: string;
  15387. };
  15388. }
  15389. declare module "babylonjs/Particles/particleSystem" {
  15390. import { Nullable } from "babylonjs/types";
  15391. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15392. import { Observable } from "babylonjs/Misc/observable";
  15393. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15394. import { Effect } from "babylonjs/Materials/effect";
  15395. import { Scene, IDisposable } from "babylonjs/scene";
  15396. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15397. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15398. import { Particle } from "babylonjs/Particles/particle";
  15399. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15400. import "Shaders/particles.fragment";
  15401. import "Shaders/particles.vertex";
  15402. /**
  15403. * This represents a particle system in Babylon.
  15404. * 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.
  15405. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15406. * @example https://doc.babylonjs.com/babylon101/particles
  15407. */
  15408. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15409. /**
  15410. * Billboard mode will only apply to Y axis
  15411. */
  15412. static readonly BILLBOARDMODE_Y: number;
  15413. /**
  15414. * Billboard mode will apply to all axes
  15415. */
  15416. static readonly BILLBOARDMODE_ALL: number;
  15417. /**
  15418. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15419. */
  15420. static readonly BILLBOARDMODE_STRETCHED: number;
  15421. /**
  15422. * This function can be defined to provide custom update for active particles.
  15423. * This function will be called instead of regular update (age, position, color, etc.).
  15424. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15425. */
  15426. updateFunction: (particles: Particle[]) => void;
  15427. private _emitterWorldMatrix;
  15428. /**
  15429. * This function can be defined to specify initial direction for every new particle.
  15430. * It by default use the emitterType defined function
  15431. */
  15432. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15433. /**
  15434. * This function can be defined to specify initial position for every new particle.
  15435. * It by default use the emitterType defined function
  15436. */
  15437. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15438. /**
  15439. * @hidden
  15440. */
  15441. _inheritedVelocityOffset: Vector3;
  15442. /**
  15443. * An event triggered when the system is disposed
  15444. */
  15445. onDisposeObservable: Observable<ParticleSystem>;
  15446. private _onDisposeObserver;
  15447. /**
  15448. * Sets a callback that will be triggered when the system is disposed
  15449. */
  15450. onDispose: () => void;
  15451. private _particles;
  15452. private _epsilon;
  15453. private _capacity;
  15454. private _stockParticles;
  15455. private _newPartsExcess;
  15456. private _vertexData;
  15457. private _vertexBuffer;
  15458. private _vertexBuffers;
  15459. private _spriteBuffer;
  15460. private _indexBuffer;
  15461. private _effect;
  15462. private _customEffect;
  15463. private _cachedDefines;
  15464. private _scaledColorStep;
  15465. private _colorDiff;
  15466. private _scaledDirection;
  15467. private _scaledGravity;
  15468. private _currentRenderId;
  15469. private _alive;
  15470. private _useInstancing;
  15471. private _started;
  15472. private _stopped;
  15473. private _actualFrame;
  15474. private _scaledUpdateSpeed;
  15475. private _vertexBufferSize;
  15476. /** @hidden */
  15477. _currentEmitRateGradient: Nullable<FactorGradient>;
  15478. /** @hidden */
  15479. _currentEmitRate1: number;
  15480. /** @hidden */
  15481. _currentEmitRate2: number;
  15482. /** @hidden */
  15483. _currentStartSizeGradient: Nullable<FactorGradient>;
  15484. /** @hidden */
  15485. _currentStartSize1: number;
  15486. /** @hidden */
  15487. _currentStartSize2: number;
  15488. private readonly _rawTextureWidth;
  15489. private _rampGradientsTexture;
  15490. private _useRampGradients;
  15491. /** Gets or sets a boolean indicating that ramp gradients must be used
  15492. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15493. */
  15494. useRampGradients: boolean;
  15495. /**
  15496. * 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.
  15497. * 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: [])
  15498. */
  15499. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15500. private _subEmitters;
  15501. /**
  15502. * @hidden
  15503. * If the particle systems emitter should be disposed when the particle system is disposed
  15504. */
  15505. _disposeEmitterOnDispose: boolean;
  15506. /**
  15507. * The current active Sub-systems, this property is used by the root particle system only.
  15508. */
  15509. activeSubSystems: Array<ParticleSystem>;
  15510. private _rootParticleSystem;
  15511. /**
  15512. * Gets the current list of active particles
  15513. */
  15514. readonly particles: Particle[];
  15515. /**
  15516. * Returns the string "ParticleSystem"
  15517. * @returns a string containing the class name
  15518. */
  15519. getClassName(): string;
  15520. /**
  15521. * Instantiates a particle system.
  15522. * 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.
  15523. * @param name The name of the particle system
  15524. * @param capacity The max number of particles alive at the same time
  15525. * @param scene The scene the particle system belongs to
  15526. * @param customEffect a custom effect used to change the way particles are rendered by default
  15527. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15528. * @param epsilon Offset used to render the particles
  15529. */
  15530. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15531. private _addFactorGradient;
  15532. private _removeFactorGradient;
  15533. /**
  15534. * Adds a new life time gradient
  15535. * @param gradient defines the gradient to use (between 0 and 1)
  15536. * @param factor defines the life time factor to affect to the specified gradient
  15537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15538. * @returns the current particle system
  15539. */
  15540. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15541. /**
  15542. * Remove a specific life time gradient
  15543. * @param gradient defines the gradient to remove
  15544. * @returns the current particle system
  15545. */
  15546. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15547. /**
  15548. * Adds a new size gradient
  15549. * @param gradient defines the gradient to use (between 0 and 1)
  15550. * @param factor defines the size factor to affect to the specified gradient
  15551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15552. * @returns the current particle system
  15553. */
  15554. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15555. /**
  15556. * Remove a specific size gradient
  15557. * @param gradient defines the gradient to remove
  15558. * @returns the current particle system
  15559. */
  15560. removeSizeGradient(gradient: number): IParticleSystem;
  15561. /**
  15562. * Adds a new color remap gradient
  15563. * @param gradient defines the gradient to use (between 0 and 1)
  15564. * @param min defines the color remap minimal range
  15565. * @param max defines the color remap maximal range
  15566. * @returns the current particle system
  15567. */
  15568. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15569. /**
  15570. * Remove a specific color remap gradient
  15571. * @param gradient defines the gradient to remove
  15572. * @returns the current particle system
  15573. */
  15574. removeColorRemapGradient(gradient: number): IParticleSystem;
  15575. /**
  15576. * Adds a new alpha remap gradient
  15577. * @param gradient defines the gradient to use (between 0 and 1)
  15578. * @param min defines the alpha remap minimal range
  15579. * @param max defines the alpha remap maximal range
  15580. * @returns the current particle system
  15581. */
  15582. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15583. /**
  15584. * Remove a specific alpha remap gradient
  15585. * @param gradient defines the gradient to remove
  15586. * @returns the current particle system
  15587. */
  15588. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15589. /**
  15590. * Adds a new angular speed gradient
  15591. * @param gradient defines the gradient to use (between 0 and 1)
  15592. * @param factor defines the angular speed to affect to the specified gradient
  15593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15594. * @returns the current particle system
  15595. */
  15596. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15597. /**
  15598. * Remove a specific angular speed gradient
  15599. * @param gradient defines the gradient to remove
  15600. * @returns the current particle system
  15601. */
  15602. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15603. /**
  15604. * Adds a new velocity gradient
  15605. * @param gradient defines the gradient to use (between 0 and 1)
  15606. * @param factor defines the velocity to affect to the specified gradient
  15607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15608. * @returns the current particle system
  15609. */
  15610. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15611. /**
  15612. * Remove a specific velocity gradient
  15613. * @param gradient defines the gradient to remove
  15614. * @returns the current particle system
  15615. */
  15616. removeVelocityGradient(gradient: number): IParticleSystem;
  15617. /**
  15618. * Adds a new limit velocity gradient
  15619. * @param gradient defines the gradient to use (between 0 and 1)
  15620. * @param factor defines the limit velocity value to affect to the specified gradient
  15621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15622. * @returns the current particle system
  15623. */
  15624. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15625. /**
  15626. * Remove a specific limit velocity gradient
  15627. * @param gradient defines the gradient to remove
  15628. * @returns the current particle system
  15629. */
  15630. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15631. /**
  15632. * Adds a new drag gradient
  15633. * @param gradient defines the gradient to use (between 0 and 1)
  15634. * @param factor defines the drag value to affect to the specified gradient
  15635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15636. * @returns the current particle system
  15637. */
  15638. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15639. /**
  15640. * Remove a specific drag gradient
  15641. * @param gradient defines the gradient to remove
  15642. * @returns the current particle system
  15643. */
  15644. removeDragGradient(gradient: number): IParticleSystem;
  15645. /**
  15646. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15647. * @param gradient defines the gradient to use (between 0 and 1)
  15648. * @param factor defines the emit rate value to affect to the specified gradient
  15649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15650. * @returns the current particle system
  15651. */
  15652. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15653. /**
  15654. * Remove a specific emit rate gradient
  15655. * @param gradient defines the gradient to remove
  15656. * @returns the current particle system
  15657. */
  15658. removeEmitRateGradient(gradient: number): IParticleSystem;
  15659. /**
  15660. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15661. * @param gradient defines the gradient to use (between 0 and 1)
  15662. * @param factor defines the start size value to affect to the specified gradient
  15663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15664. * @returns the current particle system
  15665. */
  15666. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15667. /**
  15668. * Remove a specific start size gradient
  15669. * @param gradient defines the gradient to remove
  15670. * @returns the current particle system
  15671. */
  15672. removeStartSizeGradient(gradient: number): IParticleSystem;
  15673. private _createRampGradientTexture;
  15674. /**
  15675. * Gets the current list of ramp gradients.
  15676. * You must use addRampGradient and removeRampGradient to udpate this list
  15677. * @returns the list of ramp gradients
  15678. */
  15679. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15680. /**
  15681. * Adds a new ramp gradient used to remap particle colors
  15682. * @param gradient defines the gradient to use (between 0 and 1)
  15683. * @param color defines the color to affect to the specified gradient
  15684. * @returns the current particle system
  15685. */
  15686. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15687. /**
  15688. * Remove a specific ramp gradient
  15689. * @param gradient defines the gradient to remove
  15690. * @returns the current particle system
  15691. */
  15692. removeRampGradient(gradient: number): ParticleSystem;
  15693. /**
  15694. * Adds a new color gradient
  15695. * @param gradient defines the gradient to use (between 0 and 1)
  15696. * @param color1 defines the color to affect to the specified gradient
  15697. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15698. * @returns this particle system
  15699. */
  15700. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15701. /**
  15702. * Remove a specific color gradient
  15703. * @param gradient defines the gradient to remove
  15704. * @returns this particle system
  15705. */
  15706. removeColorGradient(gradient: number): IParticleSystem;
  15707. private _fetchR;
  15708. protected _reset(): void;
  15709. private _resetEffect;
  15710. private _createVertexBuffers;
  15711. private _createIndexBuffer;
  15712. /**
  15713. * Gets the maximum number of particles active at the same time.
  15714. * @returns The max number of active particles.
  15715. */
  15716. getCapacity(): number;
  15717. /**
  15718. * Gets whether there are still active particles in the system.
  15719. * @returns True if it is alive, otherwise false.
  15720. */
  15721. isAlive(): boolean;
  15722. /**
  15723. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15724. * @returns True if it has been started, otherwise false.
  15725. */
  15726. isStarted(): boolean;
  15727. private _prepareSubEmitterInternalArray;
  15728. /**
  15729. * Starts the particle system and begins to emit
  15730. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15731. */
  15732. start(delay?: number): void;
  15733. /**
  15734. * Stops the particle system.
  15735. * @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.
  15736. */
  15737. stop(stopSubEmitters?: boolean): void;
  15738. /**
  15739. * Remove all active particles
  15740. */
  15741. reset(): void;
  15742. /**
  15743. * @hidden (for internal use only)
  15744. */
  15745. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15746. /**
  15747. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15748. * Its lifetime will start back at 0.
  15749. */
  15750. recycleParticle: (particle: Particle) => void;
  15751. private _stopSubEmitters;
  15752. private _createParticle;
  15753. private _removeFromRoot;
  15754. private _emitFromParticle;
  15755. private _update;
  15756. /** @hidden */
  15757. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15758. /** @hidden */
  15759. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15760. /** @hidden */
  15761. private _getEffect;
  15762. /**
  15763. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15764. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15765. */
  15766. animate(preWarmOnly?: boolean): void;
  15767. private _appendParticleVertices;
  15768. /**
  15769. * Rebuilds the particle system.
  15770. */
  15771. rebuild(): void;
  15772. /**
  15773. * Is this system ready to be used/rendered
  15774. * @return true if the system is ready
  15775. */
  15776. isReady(): boolean;
  15777. private _render;
  15778. /**
  15779. * Renders the particle system in its current state.
  15780. * @returns the current number of particles
  15781. */
  15782. render(): number;
  15783. /**
  15784. * Disposes the particle system and free the associated resources
  15785. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15786. */
  15787. dispose(disposeTexture?: boolean): void;
  15788. /**
  15789. * Clones the particle system.
  15790. * @param name The name of the cloned object
  15791. * @param newEmitter The new emitter to use
  15792. * @returns the cloned particle system
  15793. */
  15794. clone(name: string, newEmitter: any): ParticleSystem;
  15795. /**
  15796. * Serializes the particle system to a JSON object.
  15797. * @returns the JSON object
  15798. */
  15799. serialize(): any;
  15800. /** @hidden */
  15801. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15802. /** @hidden */
  15803. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15804. /**
  15805. * Parses a JSON object to create a particle system.
  15806. * @param parsedParticleSystem The JSON object to parse
  15807. * @param scene The scene to create the particle system in
  15808. * @param rootUrl The root url to use to load external dependencies like texture
  15809. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15810. * @returns the Parsed particle system
  15811. */
  15812. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15813. }
  15814. }
  15815. declare module "babylonjs/Particles/particle" {
  15816. import { Nullable } from "babylonjs/types";
  15817. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15818. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15819. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15820. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15821. /**
  15822. * A particle represents one of the element emitted by a particle system.
  15823. * This is mainly define by its coordinates, direction, velocity and age.
  15824. */
  15825. export class Particle {
  15826. /**
  15827. * The particle system the particle belongs to.
  15828. */
  15829. particleSystem: ParticleSystem;
  15830. private static _Count;
  15831. /**
  15832. * Unique ID of the particle
  15833. */
  15834. id: number;
  15835. /**
  15836. * The world position of the particle in the scene.
  15837. */
  15838. position: Vector3;
  15839. /**
  15840. * The world direction of the particle in the scene.
  15841. */
  15842. direction: Vector3;
  15843. /**
  15844. * The color of the particle.
  15845. */
  15846. color: Color4;
  15847. /**
  15848. * The color change of the particle per step.
  15849. */
  15850. colorStep: Color4;
  15851. /**
  15852. * Defines how long will the life of the particle be.
  15853. */
  15854. lifeTime: number;
  15855. /**
  15856. * The current age of the particle.
  15857. */
  15858. age: number;
  15859. /**
  15860. * The current size of the particle.
  15861. */
  15862. size: number;
  15863. /**
  15864. * The current scale of the particle.
  15865. */
  15866. scale: Vector2;
  15867. /**
  15868. * The current angle of the particle.
  15869. */
  15870. angle: number;
  15871. /**
  15872. * Defines how fast is the angle changing.
  15873. */
  15874. angularSpeed: number;
  15875. /**
  15876. * Defines the cell index used by the particle to be rendered from a sprite.
  15877. */
  15878. cellIndex: number;
  15879. /**
  15880. * The information required to support color remapping
  15881. */
  15882. remapData: Vector4;
  15883. /** @hidden */
  15884. _randomCellOffset?: number;
  15885. /** @hidden */
  15886. _initialDirection: Nullable<Vector3>;
  15887. /** @hidden */
  15888. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15889. /** @hidden */
  15890. _initialStartSpriteCellID: number;
  15891. /** @hidden */
  15892. _initialEndSpriteCellID: number;
  15893. /** @hidden */
  15894. _currentColorGradient: Nullable<ColorGradient>;
  15895. /** @hidden */
  15896. _currentColor1: Color4;
  15897. /** @hidden */
  15898. _currentColor2: Color4;
  15899. /** @hidden */
  15900. _currentSizeGradient: Nullable<FactorGradient>;
  15901. /** @hidden */
  15902. _currentSize1: number;
  15903. /** @hidden */
  15904. _currentSize2: number;
  15905. /** @hidden */
  15906. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15907. /** @hidden */
  15908. _currentAngularSpeed1: number;
  15909. /** @hidden */
  15910. _currentAngularSpeed2: number;
  15911. /** @hidden */
  15912. _currentVelocityGradient: Nullable<FactorGradient>;
  15913. /** @hidden */
  15914. _currentVelocity1: number;
  15915. /** @hidden */
  15916. _currentVelocity2: number;
  15917. /** @hidden */
  15918. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15919. /** @hidden */
  15920. _currentLimitVelocity1: number;
  15921. /** @hidden */
  15922. _currentLimitVelocity2: number;
  15923. /** @hidden */
  15924. _currentDragGradient: Nullable<FactorGradient>;
  15925. /** @hidden */
  15926. _currentDrag1: number;
  15927. /** @hidden */
  15928. _currentDrag2: number;
  15929. /** @hidden */
  15930. _randomNoiseCoordinates1: Vector3;
  15931. /** @hidden */
  15932. _randomNoiseCoordinates2: Vector3;
  15933. /**
  15934. * Creates a new instance Particle
  15935. * @param particleSystem the particle system the particle belongs to
  15936. */
  15937. constructor(
  15938. /**
  15939. * The particle system the particle belongs to.
  15940. */
  15941. particleSystem: ParticleSystem);
  15942. private updateCellInfoFromSystem;
  15943. /**
  15944. * Defines how the sprite cell index is updated for the particle
  15945. */
  15946. updateCellIndex(): void;
  15947. /** @hidden */
  15948. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15949. /** @hidden */
  15950. _inheritParticleInfoToSubEmitters(): void;
  15951. /** @hidden */
  15952. _reset(): void;
  15953. /**
  15954. * Copy the properties of particle to another one.
  15955. * @param other the particle to copy the information to.
  15956. */
  15957. copyTo(other: Particle): void;
  15958. }
  15959. }
  15960. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15961. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15962. import { Effect } from "babylonjs/Materials/effect";
  15963. import { Particle } from "babylonjs/Particles/particle";
  15964. /**
  15965. * Particle emitter represents a volume emitting particles.
  15966. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15967. */
  15968. export interface IParticleEmitterType {
  15969. /**
  15970. * Called by the particle System when the direction is computed for the created particle.
  15971. * @param worldMatrix is the world matrix of the particle system
  15972. * @param directionToUpdate is the direction vector to update with the result
  15973. * @param particle is the particle we are computed the direction for
  15974. */
  15975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15976. /**
  15977. * Called by the particle System when the position is computed for the created particle.
  15978. * @param worldMatrix is the world matrix of the particle system
  15979. * @param positionToUpdate is the position vector to update with the result
  15980. * @param particle is the particle we are computed the position for
  15981. */
  15982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15983. /**
  15984. * Clones the current emitter and returns a copy of it
  15985. * @returns the new emitter
  15986. */
  15987. clone(): IParticleEmitterType;
  15988. /**
  15989. * Called by the GPUParticleSystem to setup the update shader
  15990. * @param effect defines the update shader
  15991. */
  15992. applyToShader(effect: Effect): void;
  15993. /**
  15994. * Returns a string to use to update the GPU particles update shader
  15995. * @returns the effect defines string
  15996. */
  15997. getEffectDefines(): string;
  15998. /**
  15999. * Returns a string representing the class name
  16000. * @returns a string containing the class name
  16001. */
  16002. getClassName(): string;
  16003. /**
  16004. * Serializes the particle system to a JSON object.
  16005. * @returns the JSON object
  16006. */
  16007. serialize(): any;
  16008. /**
  16009. * Parse properties from a JSON object
  16010. * @param serializationObject defines the JSON object
  16011. */
  16012. parse(serializationObject: any): void;
  16013. }
  16014. }
  16015. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16016. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16017. import { Effect } from "babylonjs/Materials/effect";
  16018. import { Particle } from "babylonjs/Particles/particle";
  16019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16020. /**
  16021. * Particle emitter emitting particles from the inside of a box.
  16022. * It emits the particles randomly between 2 given directions.
  16023. */
  16024. export class BoxParticleEmitter implements IParticleEmitterType {
  16025. /**
  16026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16027. */
  16028. direction1: Vector3;
  16029. /**
  16030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16031. */
  16032. direction2: Vector3;
  16033. /**
  16034. * 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.
  16035. */
  16036. minEmitBox: Vector3;
  16037. /**
  16038. * 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.
  16039. */
  16040. maxEmitBox: Vector3;
  16041. /**
  16042. * Creates a new instance BoxParticleEmitter
  16043. */
  16044. constructor();
  16045. /**
  16046. * Called by the particle System when the direction is computed for the created particle.
  16047. * @param worldMatrix is the world matrix of the particle system
  16048. * @param directionToUpdate is the direction vector to update with the result
  16049. * @param particle is the particle we are computed the direction for
  16050. */
  16051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16052. /**
  16053. * Called by the particle System when the position is computed for the created particle.
  16054. * @param worldMatrix is the world matrix of the particle system
  16055. * @param positionToUpdate is the position vector to update with the result
  16056. * @param particle is the particle we are computed the position for
  16057. */
  16058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16059. /**
  16060. * Clones the current emitter and returns a copy of it
  16061. * @returns the new emitter
  16062. */
  16063. clone(): BoxParticleEmitter;
  16064. /**
  16065. * Called by the GPUParticleSystem to setup the update shader
  16066. * @param effect defines the update shader
  16067. */
  16068. applyToShader(effect: Effect): void;
  16069. /**
  16070. * Returns a string to use to update the GPU particles update shader
  16071. * @returns a string containng the defines string
  16072. */
  16073. getEffectDefines(): string;
  16074. /**
  16075. * Returns the string "BoxParticleEmitter"
  16076. * @returns a string containing the class name
  16077. */
  16078. getClassName(): string;
  16079. /**
  16080. * Serializes the particle system to a JSON object.
  16081. * @returns the JSON object
  16082. */
  16083. serialize(): any;
  16084. /**
  16085. * Parse properties from a JSON object
  16086. * @param serializationObject defines the JSON object
  16087. */
  16088. parse(serializationObject: any): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16092. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16093. import { Effect } from "babylonjs/Materials/effect";
  16094. import { Particle } from "babylonjs/Particles/particle";
  16095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16096. /**
  16097. * Particle emitter emitting particles from the inside of a cone.
  16098. * It emits the particles alongside the cone volume from the base to the particle.
  16099. * The emission direction might be randomized.
  16100. */
  16101. export class ConeParticleEmitter implements IParticleEmitterType {
  16102. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16103. directionRandomizer: number;
  16104. private _radius;
  16105. private _angle;
  16106. private _height;
  16107. /**
  16108. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16109. */
  16110. radiusRange: number;
  16111. /**
  16112. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16113. */
  16114. heightRange: number;
  16115. /**
  16116. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16117. */
  16118. emitFromSpawnPointOnly: boolean;
  16119. /**
  16120. * Gets or sets the radius of the emission cone
  16121. */
  16122. radius: number;
  16123. /**
  16124. * Gets or sets the angle of the emission cone
  16125. */
  16126. angle: number;
  16127. private _buildHeight;
  16128. /**
  16129. * Creates a new instance ConeParticleEmitter
  16130. * @param radius the radius of the emission cone (1 by default)
  16131. * @param angles the cone base angle (PI by default)
  16132. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16133. */
  16134. constructor(radius?: number, angle?: number,
  16135. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16136. directionRandomizer?: number);
  16137. /**
  16138. * Called by the particle System when the direction is computed for the created particle.
  16139. * @param worldMatrix is the world matrix of the particle system
  16140. * @param directionToUpdate is the direction vector to update with the result
  16141. * @param particle is the particle we are computed the direction for
  16142. */
  16143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16144. /**
  16145. * Called by the particle System when the position is computed for the created particle.
  16146. * @param worldMatrix is the world matrix of the particle system
  16147. * @param positionToUpdate is the position vector to update with the result
  16148. * @param particle is the particle we are computed the position for
  16149. */
  16150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16151. /**
  16152. * Clones the current emitter and returns a copy of it
  16153. * @returns the new emitter
  16154. */
  16155. clone(): ConeParticleEmitter;
  16156. /**
  16157. * Called by the GPUParticleSystem to setup the update shader
  16158. * @param effect defines the update shader
  16159. */
  16160. applyToShader(effect: Effect): void;
  16161. /**
  16162. * Returns a string to use to update the GPU particles update shader
  16163. * @returns a string containng the defines string
  16164. */
  16165. getEffectDefines(): string;
  16166. /**
  16167. * Returns the string "ConeParticleEmitter"
  16168. * @returns a string containing the class name
  16169. */
  16170. getClassName(): string;
  16171. /**
  16172. * Serializes the particle system to a JSON object.
  16173. * @returns the JSON object
  16174. */
  16175. serialize(): any;
  16176. /**
  16177. * Parse properties from a JSON object
  16178. * @param serializationObject defines the JSON object
  16179. */
  16180. parse(serializationObject: any): void;
  16181. }
  16182. }
  16183. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16184. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16185. import { Effect } from "babylonjs/Materials/effect";
  16186. import { Particle } from "babylonjs/Particles/particle";
  16187. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16188. /**
  16189. * Particle emitter emitting particles from the inside of a cylinder.
  16190. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16191. */
  16192. export class CylinderParticleEmitter implements IParticleEmitterType {
  16193. /**
  16194. * The radius of the emission cylinder.
  16195. */
  16196. radius: number;
  16197. /**
  16198. * The height of the emission cylinder.
  16199. */
  16200. height: number;
  16201. /**
  16202. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16203. */
  16204. radiusRange: number;
  16205. /**
  16206. * How much to randomize the particle direction [0-1].
  16207. */
  16208. directionRandomizer: number;
  16209. /**
  16210. * Creates a new instance CylinderParticleEmitter
  16211. * @param radius the radius of the emission cylinder (1 by default)
  16212. * @param height the height of the emission cylinder (1 by default)
  16213. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16214. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16215. */
  16216. constructor(
  16217. /**
  16218. * The radius of the emission cylinder.
  16219. */
  16220. radius?: number,
  16221. /**
  16222. * The height of the emission cylinder.
  16223. */
  16224. height?: number,
  16225. /**
  16226. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16227. */
  16228. radiusRange?: number,
  16229. /**
  16230. * How much to randomize the particle direction [0-1].
  16231. */
  16232. directionRandomizer?: number);
  16233. /**
  16234. * Called by the particle System when the direction is computed for the created particle.
  16235. * @param worldMatrix is the world matrix of the particle system
  16236. * @param directionToUpdate is the direction vector to update with the result
  16237. * @param particle is the particle we are computed the direction for
  16238. */
  16239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16240. /**
  16241. * Called by the particle System when the position is computed for the created particle.
  16242. * @param worldMatrix is the world matrix of the particle system
  16243. * @param positionToUpdate is the position vector to update with the result
  16244. * @param particle is the particle we are computed the position for
  16245. */
  16246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16247. /**
  16248. * Clones the current emitter and returns a copy of it
  16249. * @returns the new emitter
  16250. */
  16251. clone(): CylinderParticleEmitter;
  16252. /**
  16253. * Called by the GPUParticleSystem to setup the update shader
  16254. * @param effect defines the update shader
  16255. */
  16256. applyToShader(effect: Effect): void;
  16257. /**
  16258. * Returns a string to use to update the GPU particles update shader
  16259. * @returns a string containng the defines string
  16260. */
  16261. getEffectDefines(): string;
  16262. /**
  16263. * Returns the string "CylinderParticleEmitter"
  16264. * @returns a string containing the class name
  16265. */
  16266. getClassName(): string;
  16267. /**
  16268. * Serializes the particle system to a JSON object.
  16269. * @returns the JSON object
  16270. */
  16271. serialize(): any;
  16272. /**
  16273. * Parse properties from a JSON object
  16274. * @param serializationObject defines the JSON object
  16275. */
  16276. parse(serializationObject: any): void;
  16277. }
  16278. /**
  16279. * Particle emitter emitting particles from the inside of a cylinder.
  16280. * It emits the particles randomly between two vectors.
  16281. */
  16282. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16283. /**
  16284. * The min limit of the emission direction.
  16285. */
  16286. direction1: Vector3;
  16287. /**
  16288. * The max limit of the emission direction.
  16289. */
  16290. direction2: Vector3;
  16291. /**
  16292. * Creates a new instance CylinderDirectedParticleEmitter
  16293. * @param radius the radius of the emission cylinder (1 by default)
  16294. * @param height the height of the emission cylinder (1 by default)
  16295. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16296. * @param direction1 the min limit of the emission direction (up vector by default)
  16297. * @param direction2 the max limit of the emission direction (up vector by default)
  16298. */
  16299. constructor(radius?: number, height?: number, radiusRange?: number,
  16300. /**
  16301. * The min limit of the emission direction.
  16302. */
  16303. direction1?: Vector3,
  16304. /**
  16305. * The max limit of the emission direction.
  16306. */
  16307. direction2?: Vector3);
  16308. /**
  16309. * Called by the particle System when the direction is computed for the created particle.
  16310. * @param worldMatrix is the world matrix of the particle system
  16311. * @param directionToUpdate is the direction vector to update with the result
  16312. * @param particle is the particle we are computed the direction for
  16313. */
  16314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16315. /**
  16316. * Clones the current emitter and returns a copy of it
  16317. * @returns the new emitter
  16318. */
  16319. clone(): CylinderDirectedParticleEmitter;
  16320. /**
  16321. * Called by the GPUParticleSystem to setup the update shader
  16322. * @param effect defines the update shader
  16323. */
  16324. applyToShader(effect: Effect): void;
  16325. /**
  16326. * Returns a string to use to update the GPU particles update shader
  16327. * @returns a string containng the defines string
  16328. */
  16329. getEffectDefines(): string;
  16330. /**
  16331. * Returns the string "CylinderDirectedParticleEmitter"
  16332. * @returns a string containing the class name
  16333. */
  16334. getClassName(): string;
  16335. /**
  16336. * Serializes the particle system to a JSON object.
  16337. * @returns the JSON object
  16338. */
  16339. serialize(): any;
  16340. /**
  16341. * Parse properties from a JSON object
  16342. * @param serializationObject defines the JSON object
  16343. */
  16344. parse(serializationObject: any): void;
  16345. }
  16346. }
  16347. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16348. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16349. import { Effect } from "babylonjs/Materials/effect";
  16350. import { Particle } from "babylonjs/Particles/particle";
  16351. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16352. /**
  16353. * Particle emitter emitting particles from the inside of a hemisphere.
  16354. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16355. */
  16356. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16357. /**
  16358. * The radius of the emission hemisphere.
  16359. */
  16360. radius: number;
  16361. /**
  16362. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16363. */
  16364. radiusRange: number;
  16365. /**
  16366. * How much to randomize the particle direction [0-1].
  16367. */
  16368. directionRandomizer: number;
  16369. /**
  16370. * Creates a new instance HemisphericParticleEmitter
  16371. * @param radius the radius of the emission hemisphere (1 by default)
  16372. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16373. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16374. */
  16375. constructor(
  16376. /**
  16377. * The radius of the emission hemisphere.
  16378. */
  16379. radius?: number,
  16380. /**
  16381. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16382. */
  16383. radiusRange?: number,
  16384. /**
  16385. * How much to randomize the particle direction [0-1].
  16386. */
  16387. directionRandomizer?: number);
  16388. /**
  16389. * Called by the particle System when the direction is computed for the created particle.
  16390. * @param worldMatrix is the world matrix of the particle system
  16391. * @param directionToUpdate is the direction vector to update with the result
  16392. * @param particle is the particle we are computed the direction for
  16393. */
  16394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16395. /**
  16396. * Called by the particle System when the position is computed for the created particle.
  16397. * @param worldMatrix is the world matrix of the particle system
  16398. * @param positionToUpdate is the position vector to update with the result
  16399. * @param particle is the particle we are computed the position for
  16400. */
  16401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16402. /**
  16403. * Clones the current emitter and returns a copy of it
  16404. * @returns the new emitter
  16405. */
  16406. clone(): HemisphericParticleEmitter;
  16407. /**
  16408. * Called by the GPUParticleSystem to setup the update shader
  16409. * @param effect defines the update shader
  16410. */
  16411. applyToShader(effect: Effect): void;
  16412. /**
  16413. * Returns a string to use to update the GPU particles update shader
  16414. * @returns a string containng the defines string
  16415. */
  16416. getEffectDefines(): string;
  16417. /**
  16418. * Returns the string "HemisphericParticleEmitter"
  16419. * @returns a string containing the class name
  16420. */
  16421. getClassName(): string;
  16422. /**
  16423. * Serializes the particle system to a JSON object.
  16424. * @returns the JSON object
  16425. */
  16426. serialize(): any;
  16427. /**
  16428. * Parse properties from a JSON object
  16429. * @param serializationObject defines the JSON object
  16430. */
  16431. parse(serializationObject: any): void;
  16432. }
  16433. }
  16434. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16435. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16436. import { Effect } from "babylonjs/Materials/effect";
  16437. import { Particle } from "babylonjs/Particles/particle";
  16438. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16439. /**
  16440. * Particle emitter emitting particles from a point.
  16441. * It emits the particles randomly between 2 given directions.
  16442. */
  16443. export class PointParticleEmitter implements IParticleEmitterType {
  16444. /**
  16445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16446. */
  16447. direction1: Vector3;
  16448. /**
  16449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16450. */
  16451. direction2: Vector3;
  16452. /**
  16453. * Creates a new instance PointParticleEmitter
  16454. */
  16455. constructor();
  16456. /**
  16457. * Called by the particle System when the direction is computed for the created particle.
  16458. * @param worldMatrix is the world matrix of the particle system
  16459. * @param directionToUpdate is the direction vector to update with the result
  16460. * @param particle is the particle we are computed the direction for
  16461. */
  16462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16463. /**
  16464. * Called by the particle System when the position is computed for the created particle.
  16465. * @param worldMatrix is the world matrix of the particle system
  16466. * @param positionToUpdate is the position vector to update with the result
  16467. * @param particle is the particle we are computed the position for
  16468. */
  16469. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16470. /**
  16471. * Clones the current emitter and returns a copy of it
  16472. * @returns the new emitter
  16473. */
  16474. clone(): PointParticleEmitter;
  16475. /**
  16476. * Called by the GPUParticleSystem to setup the update shader
  16477. * @param effect defines the update shader
  16478. */
  16479. applyToShader(effect: Effect): void;
  16480. /**
  16481. * Returns a string to use to update the GPU particles update shader
  16482. * @returns a string containng the defines string
  16483. */
  16484. getEffectDefines(): string;
  16485. /**
  16486. * Returns the string "PointParticleEmitter"
  16487. * @returns a string containing the class name
  16488. */
  16489. getClassName(): string;
  16490. /**
  16491. * Serializes the particle system to a JSON object.
  16492. * @returns the JSON object
  16493. */
  16494. serialize(): any;
  16495. /**
  16496. * Parse properties from a JSON object
  16497. * @param serializationObject defines the JSON object
  16498. */
  16499. parse(serializationObject: any): void;
  16500. }
  16501. }
  16502. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16503. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16504. import { Effect } from "babylonjs/Materials/effect";
  16505. import { Particle } from "babylonjs/Particles/particle";
  16506. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16507. /**
  16508. * Particle emitter emitting particles from the inside of a sphere.
  16509. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16510. */
  16511. export class SphereParticleEmitter implements IParticleEmitterType {
  16512. /**
  16513. * The radius of the emission sphere.
  16514. */
  16515. radius: number;
  16516. /**
  16517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16518. */
  16519. radiusRange: number;
  16520. /**
  16521. * How much to randomize the particle direction [0-1].
  16522. */
  16523. directionRandomizer: number;
  16524. /**
  16525. * Creates a new instance SphereParticleEmitter
  16526. * @param radius the radius of the emission sphere (1 by default)
  16527. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16529. */
  16530. constructor(
  16531. /**
  16532. * The radius of the emission sphere.
  16533. */
  16534. radius?: number,
  16535. /**
  16536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16537. */
  16538. radiusRange?: number,
  16539. /**
  16540. * How much to randomize the particle direction [0-1].
  16541. */
  16542. directionRandomizer?: number);
  16543. /**
  16544. * Called by the particle System when the direction is computed for the created particle.
  16545. * @param worldMatrix is the world matrix of the particle system
  16546. * @param directionToUpdate is the direction vector to update with the result
  16547. * @param particle is the particle we are computed the direction for
  16548. */
  16549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16550. /**
  16551. * Called by the particle System when the position is computed for the created particle.
  16552. * @param worldMatrix is the world matrix of the particle system
  16553. * @param positionToUpdate is the position vector to update with the result
  16554. * @param particle is the particle we are computed the position for
  16555. */
  16556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16557. /**
  16558. * Clones the current emitter and returns a copy of it
  16559. * @returns the new emitter
  16560. */
  16561. clone(): SphereParticleEmitter;
  16562. /**
  16563. * Called by the GPUParticleSystem to setup the update shader
  16564. * @param effect defines the update shader
  16565. */
  16566. applyToShader(effect: Effect): void;
  16567. /**
  16568. * Returns a string to use to update the GPU particles update shader
  16569. * @returns a string containng the defines string
  16570. */
  16571. getEffectDefines(): string;
  16572. /**
  16573. * Returns the string "SphereParticleEmitter"
  16574. * @returns a string containing the class name
  16575. */
  16576. getClassName(): string;
  16577. /**
  16578. * Serializes the particle system to a JSON object.
  16579. * @returns the JSON object
  16580. */
  16581. serialize(): any;
  16582. /**
  16583. * Parse properties from a JSON object
  16584. * @param serializationObject defines the JSON object
  16585. */
  16586. parse(serializationObject: any): void;
  16587. }
  16588. /**
  16589. * Particle emitter emitting particles from the inside of a sphere.
  16590. * It emits the particles randomly between two vectors.
  16591. */
  16592. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16593. /**
  16594. * The min limit of the emission direction.
  16595. */
  16596. direction1: Vector3;
  16597. /**
  16598. * The max limit of the emission direction.
  16599. */
  16600. direction2: Vector3;
  16601. /**
  16602. * Creates a new instance SphereDirectedParticleEmitter
  16603. * @param radius the radius of the emission sphere (1 by default)
  16604. * @param direction1 the min limit of the emission direction (up vector by default)
  16605. * @param direction2 the max limit of the emission direction (up vector by default)
  16606. */
  16607. constructor(radius?: number,
  16608. /**
  16609. * The min limit of the emission direction.
  16610. */
  16611. direction1?: Vector3,
  16612. /**
  16613. * The max limit of the emission direction.
  16614. */
  16615. direction2?: Vector3);
  16616. /**
  16617. * Called by the particle System when the direction is computed for the created particle.
  16618. * @param worldMatrix is the world matrix of the particle system
  16619. * @param directionToUpdate is the direction vector to update with the result
  16620. * @param particle is the particle we are computed the direction for
  16621. */
  16622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16623. /**
  16624. * Clones the current emitter and returns a copy of it
  16625. * @returns the new emitter
  16626. */
  16627. clone(): SphereDirectedParticleEmitter;
  16628. /**
  16629. * Called by the GPUParticleSystem to setup the update shader
  16630. * @param effect defines the update shader
  16631. */
  16632. applyToShader(effect: Effect): void;
  16633. /**
  16634. * Returns a string to use to update the GPU particles update shader
  16635. * @returns a string containng the defines string
  16636. */
  16637. getEffectDefines(): string;
  16638. /**
  16639. * Returns the string "SphereDirectedParticleEmitter"
  16640. * @returns a string containing the class name
  16641. */
  16642. getClassName(): string;
  16643. /**
  16644. * Serializes the particle system to a JSON object.
  16645. * @returns the JSON object
  16646. */
  16647. serialize(): any;
  16648. /**
  16649. * Parse properties from a JSON object
  16650. * @param serializationObject defines the JSON object
  16651. */
  16652. parse(serializationObject: any): void;
  16653. }
  16654. }
  16655. declare module "babylonjs/Particles/EmitterTypes/index" {
  16656. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16657. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16658. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16659. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16660. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16661. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16662. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16663. }
  16664. declare module "babylonjs/Particles/IParticleSystem" {
  16665. import { Nullable } from "babylonjs/types";
  16666. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16669. import { Texture } from "babylonjs/Materials/Textures/texture";
  16670. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16671. import { Scene } from "babylonjs/scene";
  16672. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16673. import { Animation } from "babylonjs/Animations/animation";
  16674. /**
  16675. * Interface representing a particle system in Babylon.js.
  16676. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16677. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16678. */
  16679. export interface IParticleSystem {
  16680. /**
  16681. * List of animations used by the particle system.
  16682. */
  16683. animations: Animation[];
  16684. /**
  16685. * The id of the Particle system.
  16686. */
  16687. id: string;
  16688. /**
  16689. * The name of the Particle system.
  16690. */
  16691. name: string;
  16692. /**
  16693. * The emitter represents the Mesh or position we are attaching the particle system to.
  16694. */
  16695. emitter: Nullable<AbstractMesh | Vector3>;
  16696. /**
  16697. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16698. */
  16699. isBillboardBased: boolean;
  16700. /**
  16701. * The rendering group used by the Particle system to chose when to render.
  16702. */
  16703. renderingGroupId: number;
  16704. /**
  16705. * The layer mask we are rendering the particles through.
  16706. */
  16707. layerMask: number;
  16708. /**
  16709. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16710. */
  16711. updateSpeed: number;
  16712. /**
  16713. * The amount of time the particle system is running (depends of the overall update speed).
  16714. */
  16715. targetStopDuration: number;
  16716. /**
  16717. * The texture used to render each particle. (this can be a spritesheet)
  16718. */
  16719. particleTexture: Nullable<Texture>;
  16720. /**
  16721. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16722. */
  16723. blendMode: number;
  16724. /**
  16725. * Minimum life time of emitting particles.
  16726. */
  16727. minLifeTime: number;
  16728. /**
  16729. * Maximum life time of emitting particles.
  16730. */
  16731. maxLifeTime: number;
  16732. /**
  16733. * Minimum Size of emitting particles.
  16734. */
  16735. minSize: number;
  16736. /**
  16737. * Maximum Size of emitting particles.
  16738. */
  16739. maxSize: number;
  16740. /**
  16741. * Minimum scale of emitting particles on X axis.
  16742. */
  16743. minScaleX: number;
  16744. /**
  16745. * Maximum scale of emitting particles on X axis.
  16746. */
  16747. maxScaleX: number;
  16748. /**
  16749. * Minimum scale of emitting particles on Y axis.
  16750. */
  16751. minScaleY: number;
  16752. /**
  16753. * Maximum scale of emitting particles on Y axis.
  16754. */
  16755. maxScaleY: number;
  16756. /**
  16757. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16758. */
  16759. color1: Color4;
  16760. /**
  16761. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16762. */
  16763. color2: Color4;
  16764. /**
  16765. * Color the particle will have at the end of its lifetime.
  16766. */
  16767. colorDead: Color4;
  16768. /**
  16769. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16770. */
  16771. emitRate: number;
  16772. /**
  16773. * You can use gravity if you want to give an orientation to your particles.
  16774. */
  16775. gravity: Vector3;
  16776. /**
  16777. * Minimum power of emitting particles.
  16778. */
  16779. minEmitPower: number;
  16780. /**
  16781. * Maximum power of emitting particles.
  16782. */
  16783. maxEmitPower: number;
  16784. /**
  16785. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16786. */
  16787. minAngularSpeed: number;
  16788. /**
  16789. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16790. */
  16791. maxAngularSpeed: number;
  16792. /**
  16793. * Gets or sets the minimal initial rotation in radians.
  16794. */
  16795. minInitialRotation: number;
  16796. /**
  16797. * Gets or sets the maximal initial rotation in radians.
  16798. */
  16799. maxInitialRotation: number;
  16800. /**
  16801. * The particle emitter type defines the emitter used by the particle system.
  16802. * It can be for example box, sphere, or cone...
  16803. */
  16804. particleEmitterType: Nullable<IParticleEmitterType>;
  16805. /**
  16806. * Defines the delay in milliseconds before starting the system (0 by default)
  16807. */
  16808. startDelay: number;
  16809. /**
  16810. * 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
  16811. */
  16812. preWarmCycles: number;
  16813. /**
  16814. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16815. */
  16816. preWarmStepOffset: number;
  16817. /**
  16818. * 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)
  16819. */
  16820. spriteCellChangeSpeed: number;
  16821. /**
  16822. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16823. */
  16824. startSpriteCellID: number;
  16825. /**
  16826. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16827. */
  16828. endSpriteCellID: number;
  16829. /**
  16830. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16831. */
  16832. spriteCellWidth: number;
  16833. /**
  16834. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16835. */
  16836. spriteCellHeight: number;
  16837. /**
  16838. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16839. */
  16840. spriteRandomStartCell: boolean;
  16841. /**
  16842. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16843. */
  16844. isAnimationSheetEnabled: boolean;
  16845. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16846. translationPivot: Vector2;
  16847. /**
  16848. * Gets or sets a texture used to add random noise to particle positions
  16849. */
  16850. noiseTexture: Nullable<BaseTexture>;
  16851. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16852. noiseStrength: Vector3;
  16853. /**
  16854. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16855. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16856. */
  16857. billboardMode: number;
  16858. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16859. limitVelocityDamping: number;
  16860. /**
  16861. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16862. */
  16863. beginAnimationOnStart: boolean;
  16864. /**
  16865. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16866. */
  16867. beginAnimationFrom: number;
  16868. /**
  16869. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16870. */
  16871. beginAnimationTo: number;
  16872. /**
  16873. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16874. */
  16875. beginAnimationLoop: boolean;
  16876. /**
  16877. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16878. */
  16879. disposeOnStop: boolean;
  16880. /**
  16881. * Gets the maximum number of particles active at the same time.
  16882. * @returns The max number of active particles.
  16883. */
  16884. getCapacity(): number;
  16885. /**
  16886. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16887. * @returns True if it has been started, otherwise false.
  16888. */
  16889. isStarted(): boolean;
  16890. /**
  16891. * Animates the particle system for this frame.
  16892. */
  16893. animate(): void;
  16894. /**
  16895. * Renders the particle system in its current state.
  16896. * @returns the current number of particles
  16897. */
  16898. render(): number;
  16899. /**
  16900. * Dispose the particle system and frees its associated resources.
  16901. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16902. */
  16903. dispose(disposeTexture?: boolean): void;
  16904. /**
  16905. * Clones the particle system.
  16906. * @param name The name of the cloned object
  16907. * @param newEmitter The new emitter to use
  16908. * @returns the cloned particle system
  16909. */
  16910. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16911. /**
  16912. * Serializes the particle system to a JSON object.
  16913. * @returns the JSON object
  16914. */
  16915. serialize(): any;
  16916. /**
  16917. * Rebuild the particle system
  16918. */
  16919. rebuild(): void;
  16920. /**
  16921. * Starts the particle system and begins to emit
  16922. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16923. */
  16924. start(delay?: number): void;
  16925. /**
  16926. * Stops the particle system.
  16927. */
  16928. stop(): void;
  16929. /**
  16930. * Remove all active particles
  16931. */
  16932. reset(): void;
  16933. /**
  16934. * Is this system ready to be used/rendered
  16935. * @return true if the system is ready
  16936. */
  16937. isReady(): boolean;
  16938. /**
  16939. * Adds a new color gradient
  16940. * @param gradient defines the gradient to use (between 0 and 1)
  16941. * @param color1 defines the color to affect to the specified gradient
  16942. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16943. * @returns the current particle system
  16944. */
  16945. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16946. /**
  16947. * Remove a specific color gradient
  16948. * @param gradient defines the gradient to remove
  16949. * @returns the current particle system
  16950. */
  16951. removeColorGradient(gradient: number): IParticleSystem;
  16952. /**
  16953. * Adds a new size gradient
  16954. * @param gradient defines the gradient to use (between 0 and 1)
  16955. * @param factor defines the size factor to affect to the specified gradient
  16956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16957. * @returns the current particle system
  16958. */
  16959. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16960. /**
  16961. * Remove a specific size gradient
  16962. * @param gradient defines the gradient to remove
  16963. * @returns the current particle system
  16964. */
  16965. removeSizeGradient(gradient: number): IParticleSystem;
  16966. /**
  16967. * Gets the current list of color gradients.
  16968. * You must use addColorGradient and removeColorGradient to udpate this list
  16969. * @returns the list of color gradients
  16970. */
  16971. getColorGradients(): Nullable<Array<ColorGradient>>;
  16972. /**
  16973. * Gets the current list of size gradients.
  16974. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16975. * @returns the list of size gradients
  16976. */
  16977. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16978. /**
  16979. * Gets the current list of angular speed gradients.
  16980. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16981. * @returns the list of angular speed gradients
  16982. */
  16983. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16984. /**
  16985. * Adds a new angular speed gradient
  16986. * @param gradient defines the gradient to use (between 0 and 1)
  16987. * @param factor defines the angular speed to affect to the specified gradient
  16988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16989. * @returns the current particle system
  16990. */
  16991. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16992. /**
  16993. * Remove a specific angular speed gradient
  16994. * @param gradient defines the gradient to remove
  16995. * @returns the current particle system
  16996. */
  16997. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16998. /**
  16999. * Gets the current list of velocity gradients.
  17000. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17001. * @returns the list of velocity gradients
  17002. */
  17003. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Adds a new velocity gradient
  17006. * @param gradient defines the gradient to use (between 0 and 1)
  17007. * @param factor defines the velocity to affect to the specified gradient
  17008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17009. * @returns the current particle system
  17010. */
  17011. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17012. /**
  17013. * Remove a specific velocity gradient
  17014. * @param gradient defines the gradient to remove
  17015. * @returns the current particle system
  17016. */
  17017. removeVelocityGradient(gradient: number): IParticleSystem;
  17018. /**
  17019. * Gets the current list of limit velocity gradients.
  17020. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17021. * @returns the list of limit velocity gradients
  17022. */
  17023. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17024. /**
  17025. * Adds a new limit velocity gradient
  17026. * @param gradient defines the gradient to use (between 0 and 1)
  17027. * @param factor defines the limit velocity to affect to the specified gradient
  17028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17029. * @returns the current particle system
  17030. */
  17031. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17032. /**
  17033. * Remove a specific limit velocity gradient
  17034. * @param gradient defines the gradient to remove
  17035. * @returns the current particle system
  17036. */
  17037. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17038. /**
  17039. * Adds a new drag gradient
  17040. * @param gradient defines the gradient to use (between 0 and 1)
  17041. * @param factor defines the drag to affect to the specified gradient
  17042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17043. * @returns the current particle system
  17044. */
  17045. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17046. /**
  17047. * Remove a specific drag gradient
  17048. * @param gradient defines the gradient to remove
  17049. * @returns the current particle system
  17050. */
  17051. removeDragGradient(gradient: number): IParticleSystem;
  17052. /**
  17053. * Gets the current list of drag gradients.
  17054. * You must use addDragGradient and removeDragGradient to udpate this list
  17055. * @returns the list of drag gradients
  17056. */
  17057. getDragGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17060. * @param gradient defines the gradient to use (between 0 and 1)
  17061. * @param factor defines the emit rate to affect to the specified gradient
  17062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17063. * @returns the current particle system
  17064. */
  17065. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17066. /**
  17067. * Remove a specific emit rate gradient
  17068. * @param gradient defines the gradient to remove
  17069. * @returns the current particle system
  17070. */
  17071. removeEmitRateGradient(gradient: number): IParticleSystem;
  17072. /**
  17073. * Gets the current list of emit rate gradients.
  17074. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17075. * @returns the list of emit rate gradients
  17076. */
  17077. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17078. /**
  17079. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17080. * @param gradient defines the gradient to use (between 0 and 1)
  17081. * @param factor defines the start size to affect to the specified gradient
  17082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17083. * @returns the current particle system
  17084. */
  17085. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17086. /**
  17087. * Remove a specific start size gradient
  17088. * @param gradient defines the gradient to remove
  17089. * @returns the current particle system
  17090. */
  17091. removeStartSizeGradient(gradient: number): IParticleSystem;
  17092. /**
  17093. * Gets the current list of start size gradients.
  17094. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17095. * @returns the list of start size gradients
  17096. */
  17097. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17098. /**
  17099. * Adds a new life time gradient
  17100. * @param gradient defines the gradient to use (between 0 and 1)
  17101. * @param factor defines the life time factor to affect to the specified gradient
  17102. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17103. * @returns the current particle system
  17104. */
  17105. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17106. /**
  17107. * Remove a specific life time gradient
  17108. * @param gradient defines the gradient to remove
  17109. * @returns the current particle system
  17110. */
  17111. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17112. /**
  17113. * Gets the current list of life time gradients.
  17114. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17115. * @returns the list of life time gradients
  17116. */
  17117. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17118. /**
  17119. * Gets the current list of color gradients.
  17120. * You must use addColorGradient and removeColorGradient to udpate this list
  17121. * @returns the list of color gradients
  17122. */
  17123. getColorGradients(): Nullable<Array<ColorGradient>>;
  17124. /**
  17125. * Adds a new ramp gradient used to remap particle colors
  17126. * @param gradient defines the gradient to use (between 0 and 1)
  17127. * @param color defines the color to affect to the specified gradient
  17128. * @returns the current particle system
  17129. */
  17130. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17131. /**
  17132. * Gets the current list of ramp gradients.
  17133. * You must use addRampGradient and removeRampGradient to udpate this list
  17134. * @returns the list of ramp gradients
  17135. */
  17136. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17137. /** Gets or sets a boolean indicating that ramp gradients must be used
  17138. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17139. */
  17140. useRampGradients: boolean;
  17141. /**
  17142. * Adds a new color remap gradient
  17143. * @param gradient defines the gradient to use (between 0 and 1)
  17144. * @param min defines the color remap minimal range
  17145. * @param max defines the color remap maximal range
  17146. * @returns the current particle system
  17147. */
  17148. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17149. /**
  17150. * Gets the current list of color remap gradients.
  17151. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17152. * @returns the list of color remap gradients
  17153. */
  17154. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17155. /**
  17156. * Adds a new alpha remap gradient
  17157. * @param gradient defines the gradient to use (between 0 and 1)
  17158. * @param min defines the alpha remap minimal range
  17159. * @param max defines the alpha remap maximal range
  17160. * @returns the current particle system
  17161. */
  17162. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17163. /**
  17164. * Gets the current list of alpha remap gradients.
  17165. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17166. * @returns the list of alpha remap gradients
  17167. */
  17168. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17169. /**
  17170. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17171. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17172. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17173. * @returns the emitter
  17174. */
  17175. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17176. /**
  17177. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17178. * @param radius The radius of the hemisphere to emit from
  17179. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17180. * @returns the emitter
  17181. */
  17182. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17183. /**
  17184. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17185. * @param radius The radius of the sphere to emit from
  17186. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17187. * @returns the emitter
  17188. */
  17189. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17190. /**
  17191. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17192. * @param radius The radius of the sphere to emit from
  17193. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17194. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17195. * @returns the emitter
  17196. */
  17197. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17198. /**
  17199. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17200. * @param radius The radius of the emission cylinder
  17201. * @param height The height of the emission cylinder
  17202. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17203. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17204. * @returns the emitter
  17205. */
  17206. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17207. /**
  17208. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17209. * @param radius The radius of the cylinder to emit from
  17210. * @param height The height of the emission cylinder
  17211. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17212. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17213. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17214. * @returns the emitter
  17215. */
  17216. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17217. /**
  17218. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17219. * @param radius The radius of the cone to emit from
  17220. * @param angle The base angle of the cone
  17221. * @returns the emitter
  17222. */
  17223. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17224. /**
  17225. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17228. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17229. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17230. * @returns the emitter
  17231. */
  17232. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17233. /**
  17234. * Get hosting scene
  17235. * @returns the scene
  17236. */
  17237. getScene(): Scene;
  17238. }
  17239. }
  17240. declare module "babylonjs/Meshes/instancedMesh" {
  17241. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17242. import { Vector3 } from "babylonjs/Maths/math";
  17243. import { Camera } from "babylonjs/Cameras/camera";
  17244. import { Node } from "babylonjs/node";
  17245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17246. import { Mesh } from "babylonjs/Meshes/mesh";
  17247. import { Material } from "babylonjs/Materials/material";
  17248. import { Skeleton } from "babylonjs/Bones/skeleton";
  17249. /**
  17250. * Creates an instance based on a source mesh.
  17251. */
  17252. export class InstancedMesh extends AbstractMesh {
  17253. private _sourceMesh;
  17254. private _currentLOD;
  17255. /** @hidden */
  17256. _indexInSourceMeshInstanceArray: number;
  17257. constructor(name: string, source: Mesh);
  17258. /**
  17259. * Returns the string "InstancedMesh".
  17260. */
  17261. getClassName(): string;
  17262. /**
  17263. * If the source mesh receives shadows
  17264. */
  17265. readonly receiveShadows: boolean;
  17266. /**
  17267. * The material of the source mesh
  17268. */
  17269. readonly material: Nullable<Material>;
  17270. /**
  17271. * Visibility of the source mesh
  17272. */
  17273. readonly visibility: number;
  17274. /**
  17275. * Skeleton of the source mesh
  17276. */
  17277. readonly skeleton: Nullable<Skeleton>;
  17278. /**
  17279. * Rendering ground id of the source mesh
  17280. */
  17281. renderingGroupId: number;
  17282. /**
  17283. * Returns the total number of vertices (integer).
  17284. */
  17285. getTotalVertices(): number;
  17286. /**
  17287. * Returns a positive integer : the total number of indices in this mesh geometry.
  17288. * @returns the numner of indices or zero if the mesh has no geometry.
  17289. */
  17290. getTotalIndices(): number;
  17291. /**
  17292. * The source mesh of the instance
  17293. */
  17294. readonly sourceMesh: Mesh;
  17295. /**
  17296. * Is this node ready to be used/rendered
  17297. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17298. * @return {boolean} is it ready
  17299. */
  17300. isReady(completeCheck?: boolean): boolean;
  17301. /**
  17302. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17303. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17304. * @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.
  17305. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17306. */
  17307. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17308. /**
  17309. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17310. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17311. * The `data` are either a numeric array either a Float32Array.
  17312. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17313. * 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).
  17314. * Note that a new underlying VertexBuffer object is created each call.
  17315. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17316. *
  17317. * Possible `kind` values :
  17318. * - VertexBuffer.PositionKind
  17319. * - VertexBuffer.UVKind
  17320. * - VertexBuffer.UV2Kind
  17321. * - VertexBuffer.UV3Kind
  17322. * - VertexBuffer.UV4Kind
  17323. * - VertexBuffer.UV5Kind
  17324. * - VertexBuffer.UV6Kind
  17325. * - VertexBuffer.ColorKind
  17326. * - VertexBuffer.MatricesIndicesKind
  17327. * - VertexBuffer.MatricesIndicesExtraKind
  17328. * - VertexBuffer.MatricesWeightsKind
  17329. * - VertexBuffer.MatricesWeightsExtraKind
  17330. *
  17331. * Returns the Mesh.
  17332. */
  17333. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17334. /**
  17335. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17336. * If the mesh has no geometry, it is simply returned as it is.
  17337. * The `data` are either a numeric array either a Float32Array.
  17338. * No new underlying VertexBuffer object is created.
  17339. * 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.
  17340. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17341. *
  17342. * Possible `kind` values :
  17343. * - VertexBuffer.PositionKind
  17344. * - VertexBuffer.UVKind
  17345. * - VertexBuffer.UV2Kind
  17346. * - VertexBuffer.UV3Kind
  17347. * - VertexBuffer.UV4Kind
  17348. * - VertexBuffer.UV5Kind
  17349. * - VertexBuffer.UV6Kind
  17350. * - VertexBuffer.ColorKind
  17351. * - VertexBuffer.MatricesIndicesKind
  17352. * - VertexBuffer.MatricesIndicesExtraKind
  17353. * - VertexBuffer.MatricesWeightsKind
  17354. * - VertexBuffer.MatricesWeightsExtraKind
  17355. *
  17356. * Returns the Mesh.
  17357. */
  17358. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17359. /**
  17360. * Sets the mesh indices.
  17361. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17362. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17363. * This method creates a new index buffer each call.
  17364. * Returns the Mesh.
  17365. */
  17366. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17367. /**
  17368. * Boolean : True if the mesh owns the requested kind of data.
  17369. */
  17370. isVerticesDataPresent(kind: string): boolean;
  17371. /**
  17372. * Returns an array of indices (IndicesArray).
  17373. */
  17374. getIndices(): Nullable<IndicesArray>;
  17375. readonly _positions: Nullable<Vector3[]>;
  17376. /**
  17377. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17378. * This means the mesh underlying bounding box and sphere are recomputed.
  17379. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17380. * @returns the current mesh
  17381. */
  17382. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17383. /** @hidden */
  17384. _preActivate(): InstancedMesh;
  17385. /** @hidden */
  17386. _activate(renderId: number): InstancedMesh;
  17387. /**
  17388. * Returns the current associated LOD AbstractMesh.
  17389. */
  17390. getLOD(camera: Camera): AbstractMesh;
  17391. /** @hidden */
  17392. _syncSubMeshes(): InstancedMesh;
  17393. /** @hidden */
  17394. _generatePointsArray(): boolean;
  17395. /**
  17396. * Creates a new InstancedMesh from the current mesh.
  17397. * - name (string) : the cloned mesh name
  17398. * - newParent (optional Node) : the optional Node to parent the clone to.
  17399. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17400. *
  17401. * Returns the clone.
  17402. */
  17403. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17404. /**
  17405. * Disposes the InstancedMesh.
  17406. * Returns nothing.
  17407. */
  17408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17409. }
  17410. }
  17411. declare module "babylonjs/Materials/shaderMaterial" {
  17412. import { Scene } from "babylonjs/scene";
  17413. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17415. import { Mesh } from "babylonjs/Meshes/mesh";
  17416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17417. import { Texture } from "babylonjs/Materials/Textures/texture";
  17418. import { Material } from "babylonjs/Materials/material";
  17419. /**
  17420. * Defines the options associated with the creation of a shader material.
  17421. */
  17422. export interface IShaderMaterialOptions {
  17423. /**
  17424. * Does the material work in alpha blend mode
  17425. */
  17426. needAlphaBlending: boolean;
  17427. /**
  17428. * Does the material work in alpha test mode
  17429. */
  17430. needAlphaTesting: boolean;
  17431. /**
  17432. * The list of attribute names used in the shader
  17433. */
  17434. attributes: string[];
  17435. /**
  17436. * The list of unifrom names used in the shader
  17437. */
  17438. uniforms: string[];
  17439. /**
  17440. * The list of UBO names used in the shader
  17441. */
  17442. uniformBuffers: string[];
  17443. /**
  17444. * The list of sampler names used in the shader
  17445. */
  17446. samplers: string[];
  17447. /**
  17448. * The list of defines used in the shader
  17449. */
  17450. defines: string[];
  17451. }
  17452. /**
  17453. * 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.
  17454. *
  17455. * This returned material effects how the mesh will look based on the code in the shaders.
  17456. *
  17457. * @see http://doc.babylonjs.com/how_to/shader_material
  17458. */
  17459. export class ShaderMaterial extends Material {
  17460. private _shaderPath;
  17461. private _options;
  17462. private _textures;
  17463. private _textureArrays;
  17464. private _floats;
  17465. private _ints;
  17466. private _floatsArrays;
  17467. private _colors3;
  17468. private _colors3Arrays;
  17469. private _colors4;
  17470. private _vectors2;
  17471. private _vectors3;
  17472. private _vectors4;
  17473. private _matrices;
  17474. private _matrices3x3;
  17475. private _matrices2x2;
  17476. private _vectors2Arrays;
  17477. private _vectors3Arrays;
  17478. private _cachedWorldViewMatrix;
  17479. private _renderId;
  17480. /**
  17481. * Instantiate a new shader material.
  17482. * 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.
  17483. * This returned material effects how the mesh will look based on the code in the shaders.
  17484. * @see http://doc.babylonjs.com/how_to/shader_material
  17485. * @param name Define the name of the material in the scene
  17486. * @param scene Define the scene the material belongs to
  17487. * @param shaderPath Defines the route to the shader code in one of three ways:
  17488. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17489. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17490. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17491. * @param options Define the options used to create the shader
  17492. */
  17493. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17494. /**
  17495. * Gets the current class name of the material e.g. "ShaderMaterial"
  17496. * Mainly use in serialization.
  17497. * @returns the class name
  17498. */
  17499. getClassName(): string;
  17500. /**
  17501. * Specifies if the material will require alpha blending
  17502. * @returns a boolean specifying if alpha blending is needed
  17503. */
  17504. needAlphaBlending(): boolean;
  17505. /**
  17506. * Specifies if this material should be rendered in alpha test mode
  17507. * @returns a boolean specifying if an alpha test is needed.
  17508. */
  17509. needAlphaTesting(): boolean;
  17510. private _checkUniform;
  17511. /**
  17512. * Set a texture in the shader.
  17513. * @param name Define the name of the uniform samplers as defined in the shader
  17514. * @param texture Define the texture to bind to this sampler
  17515. * @return the material itself allowing "fluent" like uniform updates
  17516. */
  17517. setTexture(name: string, texture: Texture): ShaderMaterial;
  17518. /**
  17519. * Set a texture array in the shader.
  17520. * @param name Define the name of the uniform sampler array as defined in the shader
  17521. * @param textures Define the list of textures to bind to this sampler
  17522. * @return the material itself allowing "fluent" like uniform updates
  17523. */
  17524. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17525. /**
  17526. * Set a float in the shader.
  17527. * @param name Define the name of the uniform as defined in the shader
  17528. * @param value Define the value to give to the uniform
  17529. * @return the material itself allowing "fluent" like uniform updates
  17530. */
  17531. setFloat(name: string, value: number): ShaderMaterial;
  17532. /**
  17533. * Set a int in the shader.
  17534. * @param name Define the name of the uniform as defined in the shader
  17535. * @param value Define the value to give to the uniform
  17536. * @return the material itself allowing "fluent" like uniform updates
  17537. */
  17538. setInt(name: string, value: number): ShaderMaterial;
  17539. /**
  17540. * Set an array of floats in the shader.
  17541. * @param name Define the name of the uniform as defined in the shader
  17542. * @param value Define the value to give to the uniform
  17543. * @return the material itself allowing "fluent" like uniform updates
  17544. */
  17545. setFloats(name: string, value: number[]): ShaderMaterial;
  17546. /**
  17547. * Set a vec3 in the shader from a Color3.
  17548. * @param name Define the name of the uniform as defined in the shader
  17549. * @param value Define the value to give to the uniform
  17550. * @return the material itself allowing "fluent" like uniform updates
  17551. */
  17552. setColor3(name: string, value: Color3): ShaderMaterial;
  17553. /**
  17554. * Set a vec3 array in the shader from a Color3 array.
  17555. * @param name Define the name of the uniform as defined in the shader
  17556. * @param value Define the value to give to the uniform
  17557. * @return the material itself allowing "fluent" like uniform updates
  17558. */
  17559. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17560. /**
  17561. * Set a vec4 in the shader from a Color4.
  17562. * @param name Define the name of the uniform as defined in the shader
  17563. * @param value Define the value to give to the uniform
  17564. * @return the material itself allowing "fluent" like uniform updates
  17565. */
  17566. setColor4(name: string, value: Color4): ShaderMaterial;
  17567. /**
  17568. * Set a vec2 in the shader from a Vector2.
  17569. * @param name Define the name of the uniform as defined in the shader
  17570. * @param value Define the value to give to the uniform
  17571. * @return the material itself allowing "fluent" like uniform updates
  17572. */
  17573. setVector2(name: string, value: Vector2): ShaderMaterial;
  17574. /**
  17575. * Set a vec3 in the shader from a Vector3.
  17576. * @param name Define the name of the uniform as defined in the shader
  17577. * @param value Define the value to give to the uniform
  17578. * @return the material itself allowing "fluent" like uniform updates
  17579. */
  17580. setVector3(name: string, value: Vector3): ShaderMaterial;
  17581. /**
  17582. * Set a vec4 in the shader from a Vector4.
  17583. * @param name Define the name of the uniform as defined in the shader
  17584. * @param value Define the value to give to the uniform
  17585. * @return the material itself allowing "fluent" like uniform updates
  17586. */
  17587. setVector4(name: string, value: Vector4): ShaderMaterial;
  17588. /**
  17589. * Set a mat4 in the shader from a Matrix.
  17590. * @param name Define the name of the uniform as defined in the shader
  17591. * @param value Define the value to give to the uniform
  17592. * @return the material itself allowing "fluent" like uniform updates
  17593. */
  17594. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17595. /**
  17596. * Set a mat3 in the shader from a Float32Array.
  17597. * @param name Define the name of the uniform as defined in the shader
  17598. * @param value Define the value to give to the uniform
  17599. * @return the material itself allowing "fluent" like uniform updates
  17600. */
  17601. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17602. /**
  17603. * Set a mat2 in the shader from a Float32Array.
  17604. * @param name Define the name of the uniform as defined in the shader
  17605. * @param value Define the value to give to the uniform
  17606. * @return the material itself allowing "fluent" like uniform updates
  17607. */
  17608. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17609. /**
  17610. * Set a vec2 array in the shader from a number array.
  17611. * @param name Define the name of the uniform as defined in the shader
  17612. * @param value Define the value to give to the uniform
  17613. * @return the material itself allowing "fluent" like uniform updates
  17614. */
  17615. setArray2(name: string, value: number[]): ShaderMaterial;
  17616. /**
  17617. * Set a vec3 array in the shader from a number array.
  17618. * @param name Define the name of the uniform as defined in the shader
  17619. * @param value Define the value to give to the uniform
  17620. * @return the material itself allowing "fluent" like uniform updates
  17621. */
  17622. setArray3(name: string, value: number[]): ShaderMaterial;
  17623. private _checkCache;
  17624. /**
  17625. * Checks if the material is ready to render the requested mesh
  17626. * @param mesh Define the mesh to render
  17627. * @param useInstances Define whether or not the material is used with instances
  17628. * @returns true if ready, otherwise false
  17629. */
  17630. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17631. /**
  17632. * Binds the world matrix to the material
  17633. * @param world defines the world transformation matrix
  17634. */
  17635. bindOnlyWorldMatrix(world: Matrix): void;
  17636. /**
  17637. * Binds the material to the mesh
  17638. * @param world defines the world transformation matrix
  17639. * @param mesh defines the mesh to bind the material to
  17640. */
  17641. bind(world: Matrix, mesh?: Mesh): void;
  17642. /**
  17643. * Gets the active textures from the material
  17644. * @returns an array of textures
  17645. */
  17646. getActiveTextures(): BaseTexture[];
  17647. /**
  17648. * Specifies if the material uses a texture
  17649. * @param texture defines the texture to check against the material
  17650. * @returns a boolean specifying if the material uses the texture
  17651. */
  17652. hasTexture(texture: BaseTexture): boolean;
  17653. /**
  17654. * Makes a duplicate of the material, and gives it a new name
  17655. * @param name defines the new name for the duplicated material
  17656. * @returns the cloned material
  17657. */
  17658. clone(name: string): ShaderMaterial;
  17659. /**
  17660. * Disposes the material
  17661. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17662. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17663. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17664. */
  17665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17666. /**
  17667. * Serializes this material in a JSON representation
  17668. * @returns the serialized material object
  17669. */
  17670. serialize(): any;
  17671. /**
  17672. * Creates a shader material from parsed shader material data
  17673. * @param source defines the JSON represnetation of the material
  17674. * @param scene defines the hosting scene
  17675. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17676. * @returns a new material
  17677. */
  17678. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17679. }
  17680. }
  17681. declare module "babylonjs/Shaders/color.fragment" {
  17682. export var colorPixelShader: {
  17683. name: string;
  17684. shader: string;
  17685. };
  17686. }
  17687. declare module "babylonjs/Shaders/color.vertex" {
  17688. import "Shaders/ShadersInclude/bonesDeclaration";
  17689. import "Shaders/ShadersInclude/instancesDeclaration";
  17690. import "Shaders/ShadersInclude/instancesVertex";
  17691. import "Shaders/ShadersInclude/bonesVertex";
  17692. export var colorVertexShader: {
  17693. name: string;
  17694. shader: string;
  17695. };
  17696. }
  17697. declare module "babylonjs/Meshes/linesMesh" {
  17698. import { Nullable } from "babylonjs/types";
  17699. import { Scene } from "babylonjs/scene";
  17700. import { Color3 } from "babylonjs/Maths/math";
  17701. import { Node } from "babylonjs/node";
  17702. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17703. import { Mesh } from "babylonjs/Meshes/mesh";
  17704. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17705. import { Effect } from "babylonjs/Materials/effect";
  17706. import { Material } from "babylonjs/Materials/material";
  17707. import "Shaders/color.fragment";
  17708. import "Shaders/color.vertex";
  17709. /**
  17710. * Line mesh
  17711. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17712. */
  17713. export class LinesMesh extends Mesh {
  17714. /**
  17715. * If vertex color should be applied to the mesh
  17716. */
  17717. useVertexColor?: boolean | undefined;
  17718. /**
  17719. * If vertex alpha should be applied to the mesh
  17720. */
  17721. useVertexAlpha?: boolean | undefined;
  17722. /**
  17723. * Color of the line (Default: White)
  17724. */
  17725. color: Color3;
  17726. /**
  17727. * Alpha of the line (Default: 1)
  17728. */
  17729. alpha: number;
  17730. /**
  17731. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17732. * This margin is expressed in world space coordinates, so its value may vary.
  17733. * Default value is 0.1
  17734. */
  17735. intersectionThreshold: number;
  17736. private _colorShader;
  17737. /**
  17738. * Creates a new LinesMesh
  17739. * @param name defines the name
  17740. * @param scene defines the hosting scene
  17741. * @param parent defines the parent mesh if any
  17742. * @param source defines the optional source LinesMesh used to clone data from
  17743. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17744. * When false, achieved by calling a clone(), also passing False.
  17745. * This will make creation of children, recursive.
  17746. * @param useVertexColor defines if this LinesMesh supports vertex color
  17747. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17748. */
  17749. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17750. /**
  17751. * If vertex color should be applied to the mesh
  17752. */
  17753. useVertexColor?: boolean | undefined,
  17754. /**
  17755. * If vertex alpha should be applied to the mesh
  17756. */
  17757. useVertexAlpha?: boolean | undefined);
  17758. /**
  17759. * Returns the string "LineMesh"
  17760. */
  17761. getClassName(): string;
  17762. /**
  17763. * @hidden
  17764. */
  17765. /**
  17766. * @hidden
  17767. */
  17768. material: Material;
  17769. /**
  17770. * @hidden
  17771. */
  17772. readonly checkCollisions: boolean;
  17773. /** @hidden */
  17774. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17775. /** @hidden */
  17776. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17777. /**
  17778. * Disposes of the line mesh
  17779. * @param doNotRecurse If children should be disposed
  17780. */
  17781. dispose(doNotRecurse?: boolean): void;
  17782. /**
  17783. * Returns a new LineMesh object cloned from the current one.
  17784. */
  17785. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17786. /**
  17787. * Creates a new InstancedLinesMesh object from the mesh model.
  17788. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17789. * @param name defines the name of the new instance
  17790. * @returns a new InstancedLinesMesh
  17791. */
  17792. createInstance(name: string): InstancedLinesMesh;
  17793. }
  17794. /**
  17795. * Creates an instance based on a source LinesMesh
  17796. */
  17797. export class InstancedLinesMesh extends InstancedMesh {
  17798. /**
  17799. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17800. * This margin is expressed in world space coordinates, so its value may vary.
  17801. * Initilized with the intersectionThreshold value of the source LinesMesh
  17802. */
  17803. intersectionThreshold: number;
  17804. constructor(name: string, source: LinesMesh);
  17805. /**
  17806. * Returns the string "InstancedLinesMesh".
  17807. */
  17808. getClassName(): string;
  17809. }
  17810. }
  17811. declare module "babylonjs/Shaders/line.fragment" {
  17812. export var linePixelShader: {
  17813. name: string;
  17814. shader: string;
  17815. };
  17816. }
  17817. declare module "babylonjs/Shaders/line.vertex" {
  17818. export var lineVertexShader: {
  17819. name: string;
  17820. shader: string;
  17821. };
  17822. }
  17823. declare module "babylonjs/Rendering/edgesRenderer" {
  17824. import { Nullable } from "babylonjs/types";
  17825. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17827. import { Vector3 } from "babylonjs/Maths/math";
  17828. import { IDisposable } from "babylonjs/scene";
  17829. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17830. import "Shaders/line.fragment";
  17831. import "Shaders/line.vertex";
  17832. module "babylonjs/Meshes/abstractMesh" {
  17833. interface AbstractMesh {
  17834. /**
  17835. * Disables the mesh edge rendering mode
  17836. * @returns the currentAbstractMesh
  17837. */
  17838. disableEdgesRendering(): AbstractMesh;
  17839. /**
  17840. * Enables the edge rendering mode on the mesh.
  17841. * This mode makes the mesh edges visible
  17842. * @param epsilon defines the maximal distance between two angles to detect a face
  17843. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17844. * @returns the currentAbstractMesh
  17845. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17846. */
  17847. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17848. /**
  17849. * Gets the edgesRenderer associated with the mesh
  17850. */
  17851. edgesRenderer: Nullable<EdgesRenderer>;
  17852. }
  17853. }
  17854. module "babylonjs/Meshes/linesMesh" {
  17855. interface LinesMesh {
  17856. /**
  17857. * Enables the edge rendering mode on the mesh.
  17858. * This mode makes the mesh edges visible
  17859. * @param epsilon defines the maximal distance between two angles to detect a face
  17860. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17861. * @returns the currentAbstractMesh
  17862. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17863. */
  17864. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17865. }
  17866. }
  17867. module "babylonjs/Meshes/linesMesh" {
  17868. interface InstancedLinesMesh {
  17869. /**
  17870. * Enables the edge rendering mode on the mesh.
  17871. * This mode makes the mesh edges visible
  17872. * @param epsilon defines the maximal distance between two angles to detect a face
  17873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17874. * @returns the current InstancedLinesMesh
  17875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17876. */
  17877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17878. }
  17879. }
  17880. /**
  17881. * Defines the minimum contract an Edges renderer should follow.
  17882. */
  17883. export interface IEdgesRenderer extends IDisposable {
  17884. /**
  17885. * Gets or sets a boolean indicating if the edgesRenderer is active
  17886. */
  17887. isEnabled: boolean;
  17888. /**
  17889. * Renders the edges of the attached mesh,
  17890. */
  17891. render(): void;
  17892. /**
  17893. * Checks wether or not the edges renderer is ready to render.
  17894. * @return true if ready, otherwise false.
  17895. */
  17896. isReady(): boolean;
  17897. }
  17898. /**
  17899. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17900. */
  17901. export class EdgesRenderer implements IEdgesRenderer {
  17902. /**
  17903. * Define the size of the edges with an orthographic camera
  17904. */
  17905. edgesWidthScalerForOrthographic: number;
  17906. /**
  17907. * Define the size of the edges with a perspective camera
  17908. */
  17909. edgesWidthScalerForPerspective: number;
  17910. protected _source: AbstractMesh;
  17911. protected _linesPositions: number[];
  17912. protected _linesNormals: number[];
  17913. protected _linesIndices: number[];
  17914. protected _epsilon: number;
  17915. protected _indicesCount: number;
  17916. protected _lineShader: ShaderMaterial;
  17917. protected _ib: WebGLBuffer;
  17918. protected _buffers: {
  17919. [key: string]: Nullable<VertexBuffer>;
  17920. };
  17921. protected _checkVerticesInsteadOfIndices: boolean;
  17922. private _meshRebuildObserver;
  17923. private _meshDisposeObserver;
  17924. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17925. isEnabled: boolean;
  17926. /**
  17927. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17928. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17929. * @param source Mesh used to create edges
  17930. * @param epsilon sum of angles in adjacency to check for edge
  17931. * @param checkVerticesInsteadOfIndices
  17932. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17933. */
  17934. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17935. protected _prepareRessources(): void;
  17936. /** @hidden */
  17937. _rebuild(): void;
  17938. /**
  17939. * Releases the required resources for the edges renderer
  17940. */
  17941. dispose(): void;
  17942. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17943. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17944. /**
  17945. * Checks if the pair of p0 and p1 is en edge
  17946. * @param faceIndex
  17947. * @param edge
  17948. * @param faceNormals
  17949. * @param p0
  17950. * @param p1
  17951. * @private
  17952. */
  17953. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17954. /**
  17955. * push line into the position, normal and index buffer
  17956. * @protected
  17957. */
  17958. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17959. /**
  17960. * Generates lines edges from adjacencjes
  17961. * @private
  17962. */
  17963. _generateEdgesLines(): void;
  17964. /**
  17965. * Checks wether or not the edges renderer is ready to render.
  17966. * @return true if ready, otherwise false.
  17967. */
  17968. isReady(): boolean;
  17969. /**
  17970. * Renders the edges of the attached mesh,
  17971. */
  17972. render(): void;
  17973. }
  17974. /**
  17975. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17976. */
  17977. export class LineEdgesRenderer extends EdgesRenderer {
  17978. /**
  17979. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17980. * @param source LineMesh used to generate edges
  17981. * @param epsilon not important (specified angle for edge detection)
  17982. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17983. */
  17984. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17985. /**
  17986. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17987. */
  17988. _generateEdgesLines(): void;
  17989. }
  17990. }
  17991. declare module "babylonjs/Rendering/renderingGroup" {
  17992. import { SmartArray } from "babylonjs/Misc/smartArray";
  17993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17995. import { Nullable } from "babylonjs/types";
  17996. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17998. import { Material } from "babylonjs/Materials/material";
  17999. import { Scene } from "babylonjs/scene";
  18000. /**
  18001. * This represents the object necessary to create a rendering group.
  18002. * This is exclusively used and created by the rendering manager.
  18003. * To modify the behavior, you use the available helpers in your scene or meshes.
  18004. * @hidden
  18005. */
  18006. export class RenderingGroup {
  18007. index: number;
  18008. private _scene;
  18009. private _opaqueSubMeshes;
  18010. private _transparentSubMeshes;
  18011. private _alphaTestSubMeshes;
  18012. private _depthOnlySubMeshes;
  18013. private _particleSystems;
  18014. private _spriteManagers;
  18015. private _opaqueSortCompareFn;
  18016. private _alphaTestSortCompareFn;
  18017. private _transparentSortCompareFn;
  18018. private _renderOpaque;
  18019. private _renderAlphaTest;
  18020. private _renderTransparent;
  18021. private _edgesRenderers;
  18022. onBeforeTransparentRendering: () => void;
  18023. /**
  18024. * Set the opaque sort comparison function.
  18025. * If null the sub meshes will be render in the order they were created
  18026. */
  18027. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18028. /**
  18029. * Set the alpha test sort comparison function.
  18030. * If null the sub meshes will be render in the order they were created
  18031. */
  18032. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18033. /**
  18034. * Set the transparent sort comparison function.
  18035. * If null the sub meshes will be render in the order they were created
  18036. */
  18037. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18038. /**
  18039. * Creates a new rendering group.
  18040. * @param index The rendering group index
  18041. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  18042. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  18043. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  18044. */
  18045. 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>);
  18046. /**
  18047. * Render all the sub meshes contained in the group.
  18048. * @param customRenderFunction Used to override the default render behaviour of the group.
  18049. * @returns true if rendered some submeshes.
  18050. */
  18051. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  18052. /**
  18053. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18054. * @param subMeshes The submeshes to render
  18055. */
  18056. private renderOpaqueSorted;
  18057. /**
  18058. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18059. * @param subMeshes The submeshes to render
  18060. */
  18061. private renderAlphaTestSorted;
  18062. /**
  18063. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18064. * @param subMeshes The submeshes to render
  18065. */
  18066. private renderTransparentSorted;
  18067. /**
  18068. * Renders the submeshes in a specified order.
  18069. * @param subMeshes The submeshes to sort before render
  18070. * @param sortCompareFn The comparison function use to sort
  18071. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18072. * @param transparent Specifies to activate blending if true
  18073. */
  18074. private static renderSorted;
  18075. /**
  18076. * Renders the submeshes in the order they were dispatched (no sort applied).
  18077. * @param subMeshes The submeshes to render
  18078. */
  18079. private static renderUnsorted;
  18080. /**
  18081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18082. * are rendered back to front if in the same alpha index.
  18083. *
  18084. * @param a The first submesh
  18085. * @param b The second submesh
  18086. * @returns The result of the comparison
  18087. */
  18088. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18089. /**
  18090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18091. * are rendered back to front.
  18092. *
  18093. * @param a The first submesh
  18094. * @param b The second submesh
  18095. * @returns The result of the comparison
  18096. */
  18097. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18098. /**
  18099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18100. * are rendered front to back (prevent overdraw).
  18101. *
  18102. * @param a The first submesh
  18103. * @param b The second submesh
  18104. * @returns The result of the comparison
  18105. */
  18106. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18107. /**
  18108. * Resets the different lists of submeshes to prepare a new frame.
  18109. */
  18110. prepare(): void;
  18111. dispose(): void;
  18112. /**
  18113. * Inserts the submesh in its correct queue depending on its material.
  18114. * @param subMesh The submesh to dispatch
  18115. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18116. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18117. */
  18118. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18119. dispatchSprites(spriteManager: ISpriteManager): void;
  18120. dispatchParticles(particleSystem: IParticleSystem): void;
  18121. private _renderParticles;
  18122. private _renderSprites;
  18123. }
  18124. }
  18125. declare module "babylonjs/Rendering/renderingManager" {
  18126. import { Nullable } from "babylonjs/types";
  18127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18129. import { SmartArray } from "babylonjs/Misc/smartArray";
  18130. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18132. import { Material } from "babylonjs/Materials/material";
  18133. import { Scene } from "babylonjs/scene";
  18134. import { Camera } from "babylonjs/Cameras/camera";
  18135. /**
  18136. * Interface describing the different options available in the rendering manager
  18137. * regarding Auto Clear between groups.
  18138. */
  18139. export interface IRenderingManagerAutoClearSetup {
  18140. /**
  18141. * Defines whether or not autoclear is enable.
  18142. */
  18143. autoClear: boolean;
  18144. /**
  18145. * Defines whether or not to autoclear the depth buffer.
  18146. */
  18147. depth: boolean;
  18148. /**
  18149. * Defines whether or not to autoclear the stencil buffer.
  18150. */
  18151. stencil: boolean;
  18152. }
  18153. /**
  18154. * This class is used by the onRenderingGroupObservable
  18155. */
  18156. export class RenderingGroupInfo {
  18157. /**
  18158. * The Scene that being rendered
  18159. */
  18160. scene: Scene;
  18161. /**
  18162. * The camera currently used for the rendering pass
  18163. */
  18164. camera: Nullable<Camera>;
  18165. /**
  18166. * The ID of the renderingGroup being processed
  18167. */
  18168. renderingGroupId: number;
  18169. }
  18170. /**
  18171. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18172. * It is enable to manage the different groups as well as the different necessary sort functions.
  18173. * This should not be used directly aside of the few static configurations
  18174. */
  18175. export class RenderingManager {
  18176. /**
  18177. * The max id used for rendering groups (not included)
  18178. */
  18179. static MAX_RENDERINGGROUPS: number;
  18180. /**
  18181. * The min id used for rendering groups (included)
  18182. */
  18183. static MIN_RENDERINGGROUPS: number;
  18184. /**
  18185. * Used to globally prevent autoclearing scenes.
  18186. */
  18187. static AUTOCLEAR: boolean;
  18188. /**
  18189. * @hidden
  18190. */
  18191. _useSceneAutoClearSetup: boolean;
  18192. private _scene;
  18193. private _renderingGroups;
  18194. private _depthStencilBufferAlreadyCleaned;
  18195. private _autoClearDepthStencil;
  18196. private _customOpaqueSortCompareFn;
  18197. private _customAlphaTestSortCompareFn;
  18198. private _customTransparentSortCompareFn;
  18199. private _renderingGroupInfo;
  18200. /**
  18201. * Instantiates a new rendering group for a particular scene
  18202. * @param scene Defines the scene the groups belongs to
  18203. */
  18204. constructor(scene: Scene);
  18205. private _clearDepthStencilBuffer;
  18206. /**
  18207. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18208. * @hidden
  18209. */
  18210. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18211. /**
  18212. * Resets the different information of the group to prepare a new frame
  18213. * @hidden
  18214. */
  18215. reset(): void;
  18216. /**
  18217. * Dispose and release the group and its associated resources.
  18218. * @hidden
  18219. */
  18220. dispose(): void;
  18221. /**
  18222. * Clear the info related to rendering groups preventing retention points during dispose.
  18223. */
  18224. freeRenderingGroups(): void;
  18225. private _prepareRenderingGroup;
  18226. /**
  18227. * Add a sprite manager to the rendering manager in order to render it this frame.
  18228. * @param spriteManager Define the sprite manager to render
  18229. */
  18230. dispatchSprites(spriteManager: ISpriteManager): void;
  18231. /**
  18232. * Add a particle system to the rendering manager in order to render it this frame.
  18233. * @param particleSystem Define the particle system to render
  18234. */
  18235. dispatchParticles(particleSystem: IParticleSystem): void;
  18236. /**
  18237. * Add a submesh to the manager in order to render it this frame
  18238. * @param subMesh The submesh to dispatch
  18239. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18240. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18241. */
  18242. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18243. /**
  18244. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18245. * This allowed control for front to back rendering or reversly depending of the special needs.
  18246. *
  18247. * @param renderingGroupId The rendering group id corresponding to its index
  18248. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18249. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18250. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18251. */
  18252. 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;
  18253. /**
  18254. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18255. *
  18256. * @param renderingGroupId The rendering group id corresponding to its index
  18257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18258. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18259. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18260. */
  18261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18262. /**
  18263. * Gets the current auto clear configuration for one rendering group of the rendering
  18264. * manager.
  18265. * @param index the rendering group index to get the information for
  18266. * @returns The auto clear setup for the requested rendering group
  18267. */
  18268. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18269. }
  18270. }
  18271. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18272. import { Observable } from "babylonjs/Misc/observable";
  18273. import { SmartArray } from "babylonjs/Misc/smartArray";
  18274. import { Nullable } from "babylonjs/types";
  18275. import { Camera } from "babylonjs/Cameras/camera";
  18276. import { Scene } from "babylonjs/scene";
  18277. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18278. import { Engine, RenderTargetCreationOptions } from "babylonjs/Engines/engine";
  18279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18280. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18282. import { Texture } from "babylonjs/Materials/Textures/texture";
  18283. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18284. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18285. /**
  18286. * This Helps creating a texture that will be created from a camera in your scene.
  18287. * It is basically a dynamic texture that could be used to create special effects for instance.
  18288. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18289. */
  18290. export class RenderTargetTexture extends Texture {
  18291. isCube: boolean;
  18292. /**
  18293. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18294. */
  18295. static readonly REFRESHRATE_RENDER_ONCE: number;
  18296. /**
  18297. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18298. */
  18299. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18300. /**
  18301. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18302. * the central point of your effect and can save a lot of performances.
  18303. */
  18304. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18305. /**
  18306. * Use this predicate to dynamically define the list of mesh you want to render.
  18307. * If set, the renderList property will be overwritten.
  18308. */
  18309. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18310. private _renderList;
  18311. /**
  18312. * Use this list to define the list of mesh you want to render.
  18313. */
  18314. renderList: Nullable<Array<AbstractMesh>>;
  18315. private _hookArray;
  18316. /**
  18317. * Define if particles should be rendered in your texture.
  18318. */
  18319. renderParticles: boolean;
  18320. /**
  18321. * Define if sprites should be rendered in your texture.
  18322. */
  18323. renderSprites: boolean;
  18324. /**
  18325. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18326. */
  18327. coordinatesMode: number;
  18328. /**
  18329. * Define the camera used to render the texture.
  18330. */
  18331. activeCamera: Nullable<Camera>;
  18332. /**
  18333. * Override the render function of the texture with your own one.
  18334. */
  18335. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18336. /**
  18337. * Define if camera post processes should be use while rendering the texture.
  18338. */
  18339. useCameraPostProcesses: boolean;
  18340. /**
  18341. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18342. */
  18343. ignoreCameraViewport: boolean;
  18344. private _postProcessManager;
  18345. private _postProcesses;
  18346. private _resizeObserver;
  18347. /**
  18348. * An event triggered when the texture is unbind.
  18349. */
  18350. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18351. /**
  18352. * An event triggered when the texture is unbind.
  18353. */
  18354. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18355. private _onAfterUnbindObserver;
  18356. /**
  18357. * Set a after unbind callback in the texture.
  18358. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18359. */
  18360. onAfterUnbind: () => void;
  18361. /**
  18362. * An event triggered before rendering the texture
  18363. */
  18364. onBeforeRenderObservable: Observable<number>;
  18365. private _onBeforeRenderObserver;
  18366. /**
  18367. * Set a before render callback in the texture.
  18368. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18369. */
  18370. onBeforeRender: (faceIndex: number) => void;
  18371. /**
  18372. * An event triggered after rendering the texture
  18373. */
  18374. onAfterRenderObservable: Observable<number>;
  18375. private _onAfterRenderObserver;
  18376. /**
  18377. * Set a after render callback in the texture.
  18378. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18379. */
  18380. onAfterRender: (faceIndex: number) => void;
  18381. /**
  18382. * An event triggered after the texture clear
  18383. */
  18384. onClearObservable: Observable<Engine>;
  18385. private _onClearObserver;
  18386. /**
  18387. * Set a clear callback in the texture.
  18388. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18389. */
  18390. onClear: (Engine: Engine) => void;
  18391. /**
  18392. * Define the clear color of the Render Target if it should be different from the scene.
  18393. */
  18394. clearColor: Color4;
  18395. protected _size: number | {
  18396. width: number;
  18397. height: number;
  18398. };
  18399. protected _initialSizeParameter: number | {
  18400. width: number;
  18401. height: number;
  18402. } | {
  18403. ratio: number;
  18404. };
  18405. protected _sizeRatio: Nullable<number>;
  18406. /** @hidden */
  18407. _generateMipMaps: boolean;
  18408. protected _renderingManager: RenderingManager;
  18409. /** @hidden */
  18410. _waitingRenderList: string[];
  18411. protected _doNotChangeAspectRatio: boolean;
  18412. protected _currentRefreshId: number;
  18413. protected _refreshRate: number;
  18414. protected _textureMatrix: Matrix;
  18415. protected _samples: number;
  18416. protected _renderTargetOptions: RenderTargetCreationOptions;
  18417. /**
  18418. * Gets render target creation options that were used.
  18419. */
  18420. readonly renderTargetOptions: RenderTargetCreationOptions;
  18421. protected _engine: Engine;
  18422. protected _onRatioRescale(): void;
  18423. /**
  18424. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18425. * It must define where the camera used to render the texture is set
  18426. */
  18427. boundingBoxPosition: Vector3;
  18428. private _boundingBoxSize;
  18429. /**
  18430. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18431. * When defined, the cubemap will switch to local mode
  18432. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18433. * @example https://www.babylonjs-playground.com/#RNASML
  18434. */
  18435. boundingBoxSize: Vector3;
  18436. /**
  18437. * In case the RTT has been created with a depth texture, get the associated
  18438. * depth texture.
  18439. * Otherwise, return null.
  18440. */
  18441. depthStencilTexture: Nullable<InternalTexture>;
  18442. /**
  18443. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18444. * or used a shadow, depth texture...
  18445. * @param name The friendly name of the texture
  18446. * @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)
  18447. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18448. * @param generateMipMaps True if mip maps need to be generated after render.
  18449. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18450. * @param type The type of the buffer in the RTT (int, half float, float...)
  18451. * @param isCube True if a cube texture needs to be created
  18452. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18453. * @param generateDepthBuffer True to generate a depth buffer
  18454. * @param generateStencilBuffer True to generate a stencil buffer
  18455. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18456. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18457. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18458. */
  18459. constructor(name: string, size: number | {
  18460. width: number;
  18461. height: number;
  18462. } | {
  18463. ratio: number;
  18464. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18465. /**
  18466. * Creates a depth stencil texture.
  18467. * This is only available in WebGL 2 or with the depth texture extension available.
  18468. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18469. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18470. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18471. */
  18472. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18473. private _processSizeParameter;
  18474. /**
  18475. * Define the number of samples to use in case of MSAA.
  18476. * It defaults to one meaning no MSAA has been enabled.
  18477. */
  18478. samples: number;
  18479. /**
  18480. * Resets the refresh counter of the texture and start bak from scratch.
  18481. * Could be useful to regenerate the texture if it is setup to render only once.
  18482. */
  18483. resetRefreshCounter(): void;
  18484. /**
  18485. * Define the refresh rate of the texture or the rendering frequency.
  18486. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18487. */
  18488. refreshRate: number;
  18489. /**
  18490. * Adds a post process to the render target rendering passes.
  18491. * @param postProcess define the post process to add
  18492. */
  18493. addPostProcess(postProcess: PostProcess): void;
  18494. /**
  18495. * Clear all the post processes attached to the render target
  18496. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18497. */
  18498. clearPostProcesses(dispose?: boolean): void;
  18499. /**
  18500. * Remove one of the post process from the list of attached post processes to the texture
  18501. * @param postProcess define the post process to remove from the list
  18502. */
  18503. removePostProcess(postProcess: PostProcess): void;
  18504. /** @hidden */
  18505. _shouldRender(): boolean;
  18506. /**
  18507. * Gets the actual render size of the texture.
  18508. * @returns the width of the render size
  18509. */
  18510. getRenderSize(): number;
  18511. /**
  18512. * Gets the actual render width of the texture.
  18513. * @returns the width of the render size
  18514. */
  18515. getRenderWidth(): number;
  18516. /**
  18517. * Gets the actual render height of the texture.
  18518. * @returns the height of the render size
  18519. */
  18520. getRenderHeight(): number;
  18521. /**
  18522. * Get if the texture can be rescaled or not.
  18523. */
  18524. readonly canRescale: boolean;
  18525. /**
  18526. * Resize the texture using a ratio.
  18527. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18528. */
  18529. scale(ratio: number): void;
  18530. /**
  18531. * Get the texture reflection matrix used to rotate/transform the reflection.
  18532. * @returns the reflection matrix
  18533. */
  18534. getReflectionTextureMatrix(): Matrix;
  18535. /**
  18536. * Resize the texture to a new desired size.
  18537. * Be carrefull as it will recreate all the data in the new texture.
  18538. * @param size Define the new size. It can be:
  18539. * - a number for squared texture,
  18540. * - an object containing { width: number, height: number }
  18541. * - or an object containing a ratio { ratio: number }
  18542. */
  18543. resize(size: number | {
  18544. width: number;
  18545. height: number;
  18546. } | {
  18547. ratio: number;
  18548. }): void;
  18549. /**
  18550. * Renders all the objects from the render list into the texture.
  18551. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18552. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18553. */
  18554. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18555. private _bestReflectionRenderTargetDimension;
  18556. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18557. private renderToTarget;
  18558. /**
  18559. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18560. * This allowed control for front to back rendering or reversly depending of the special needs.
  18561. *
  18562. * @param renderingGroupId The rendering group id corresponding to its index
  18563. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18564. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18565. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18566. */
  18567. 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;
  18568. /**
  18569. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18570. *
  18571. * @param renderingGroupId The rendering group id corresponding to its index
  18572. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18573. */
  18574. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18575. /**
  18576. * Clones the texture.
  18577. * @returns the cloned texture
  18578. */
  18579. clone(): RenderTargetTexture;
  18580. /**
  18581. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18582. * @returns The JSON representation of the texture
  18583. */
  18584. serialize(): any;
  18585. /**
  18586. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18587. */
  18588. disposeFramebufferObjects(): void;
  18589. /**
  18590. * Dispose the texture and release its associated resources.
  18591. */
  18592. dispose(): void;
  18593. /** @hidden */
  18594. _rebuild(): void;
  18595. /**
  18596. * Clear the info related to rendering groups preventing retention point in material dispose.
  18597. */
  18598. freeRenderingGroups(): void;
  18599. }
  18600. }
  18601. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18602. import { Scene } from "babylonjs/scene";
  18603. import { Plane } from "babylonjs/Maths/math";
  18604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18605. /**
  18606. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18607. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18608. * You can then easily use it as a reflectionTexture on a flat surface.
  18609. * In case the surface is not a plane, please consider relying on reflection probes.
  18610. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18611. */
  18612. export class MirrorTexture extends RenderTargetTexture {
  18613. private scene;
  18614. /**
  18615. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18616. * 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.
  18617. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18618. */
  18619. mirrorPlane: Plane;
  18620. /**
  18621. * Define the blur ratio used to blur the reflection if needed.
  18622. */
  18623. blurRatio: number;
  18624. /**
  18625. * Define the adaptive blur kernel used to blur the reflection if needed.
  18626. * This will autocompute the closest best match for the `blurKernel`
  18627. */
  18628. adaptiveBlurKernel: number;
  18629. /**
  18630. * Define the blur kernel used to blur the reflection if needed.
  18631. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18632. */
  18633. blurKernel: number;
  18634. /**
  18635. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18636. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18637. */
  18638. blurKernelX: number;
  18639. /**
  18640. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18641. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18642. */
  18643. blurKernelY: number;
  18644. private _autoComputeBlurKernel;
  18645. protected _onRatioRescale(): void;
  18646. private _updateGammaSpace;
  18647. private _imageProcessingConfigChangeObserver;
  18648. private _transformMatrix;
  18649. private _mirrorMatrix;
  18650. private _savedViewMatrix;
  18651. private _blurX;
  18652. private _blurY;
  18653. private _adaptiveBlurKernel;
  18654. private _blurKernelX;
  18655. private _blurKernelY;
  18656. private _blurRatio;
  18657. /**
  18658. * Instantiates a Mirror Texture.
  18659. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18660. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18661. * You can then easily use it as a reflectionTexture on a flat surface.
  18662. * In case the surface is not a plane, please consider relying on reflection probes.
  18663. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18664. * @param name
  18665. * @param size
  18666. * @param scene
  18667. * @param generateMipMaps
  18668. * @param type
  18669. * @param samplingMode
  18670. * @param generateDepthBuffer
  18671. */
  18672. constructor(name: string, size: number | {
  18673. width: number;
  18674. height: number;
  18675. } | {
  18676. ratio: number;
  18677. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18678. private _preparePostProcesses;
  18679. /**
  18680. * Clone the mirror texture.
  18681. * @returns the cloned texture
  18682. */
  18683. clone(): MirrorTexture;
  18684. /**
  18685. * Serialize the texture to a JSON representation you could use in Parse later on
  18686. * @returns the serialized JSON representation
  18687. */
  18688. serialize(): any;
  18689. /**
  18690. * Dispose the texture and release its associated resources.
  18691. */
  18692. dispose(): void;
  18693. }
  18694. }
  18695. declare module "babylonjs/Materials/Textures/texture" {
  18696. import { Observable } from "babylonjs/Misc/observable";
  18697. import { Nullable } from "babylonjs/types";
  18698. import { Scene } from "babylonjs/scene";
  18699. import { Matrix } from "babylonjs/Maths/math";
  18700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18701. /**
  18702. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18703. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18704. */
  18705. export class Texture extends BaseTexture {
  18706. /** @hidden */
  18707. static _AnimationParser: (jsonAnimation: any) => import("babylonjs/Animations/animation").Animation;
  18708. /** @hidden */
  18709. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18710. /** @hidden */
  18711. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18712. /** @hidden */
  18713. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18714. /** nearest is mag = nearest and min = nearest and mip = linear */
  18715. static readonly NEAREST_SAMPLINGMODE: number;
  18716. /** nearest is mag = nearest and min = nearest and mip = linear */
  18717. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18718. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18719. static readonly BILINEAR_SAMPLINGMODE: number;
  18720. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18721. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18722. /** Trilinear is mag = linear and min = linear and mip = linear */
  18723. static readonly TRILINEAR_SAMPLINGMODE: number;
  18724. /** Trilinear is mag = linear and min = linear and mip = linear */
  18725. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18726. /** mag = nearest and min = nearest and mip = nearest */
  18727. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18728. /** mag = nearest and min = linear and mip = nearest */
  18729. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18730. /** mag = nearest and min = linear and mip = linear */
  18731. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18732. /** mag = nearest and min = linear and mip = none */
  18733. static readonly NEAREST_LINEAR: number;
  18734. /** mag = nearest and min = nearest and mip = none */
  18735. static readonly NEAREST_NEAREST: number;
  18736. /** mag = linear and min = nearest and mip = nearest */
  18737. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18738. /** mag = linear and min = nearest and mip = linear */
  18739. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18740. /** mag = linear and min = linear and mip = none */
  18741. static readonly LINEAR_LINEAR: number;
  18742. /** mag = linear and min = nearest and mip = none */
  18743. static readonly LINEAR_NEAREST: number;
  18744. /** Explicit coordinates mode */
  18745. static readonly EXPLICIT_MODE: number;
  18746. /** Spherical coordinates mode */
  18747. static readonly SPHERICAL_MODE: number;
  18748. /** Planar coordinates mode */
  18749. static readonly PLANAR_MODE: number;
  18750. /** Cubic coordinates mode */
  18751. static readonly CUBIC_MODE: number;
  18752. /** Projection coordinates mode */
  18753. static readonly PROJECTION_MODE: number;
  18754. /** Inverse Cubic coordinates mode */
  18755. static readonly SKYBOX_MODE: number;
  18756. /** Inverse Cubic coordinates mode */
  18757. static readonly INVCUBIC_MODE: number;
  18758. /** Equirectangular coordinates mode */
  18759. static readonly EQUIRECTANGULAR_MODE: number;
  18760. /** Equirectangular Fixed coordinates mode */
  18761. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18762. /** Equirectangular Fixed Mirrored coordinates mode */
  18763. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18764. /** Texture is not repeating outside of 0..1 UVs */
  18765. static readonly CLAMP_ADDRESSMODE: number;
  18766. /** Texture is repeating outside of 0..1 UVs */
  18767. static readonly WRAP_ADDRESSMODE: number;
  18768. /** Texture is repeating and mirrored */
  18769. static readonly MIRROR_ADDRESSMODE: number;
  18770. /**
  18771. * 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
  18772. */
  18773. static UseSerializedUrlIfAny: boolean;
  18774. /**
  18775. * Define the url of the texture.
  18776. */
  18777. url: Nullable<string>;
  18778. /**
  18779. * Define an offset on the texture to offset the u coordinates of the UVs
  18780. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18781. */
  18782. uOffset: number;
  18783. /**
  18784. * Define an offset on the texture to offset the v coordinates of the UVs
  18785. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18786. */
  18787. vOffset: number;
  18788. /**
  18789. * Define an offset on the texture to scale the u coordinates of the UVs
  18790. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18791. */
  18792. uScale: number;
  18793. /**
  18794. * Define an offset on the texture to scale the v coordinates of the UVs
  18795. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18796. */
  18797. vScale: number;
  18798. /**
  18799. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18800. * @see http://doc.babylonjs.com/how_to/more_materials
  18801. */
  18802. uAng: number;
  18803. /**
  18804. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18805. * @see http://doc.babylonjs.com/how_to/more_materials
  18806. */
  18807. vAng: number;
  18808. /**
  18809. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18810. * @see http://doc.babylonjs.com/how_to/more_materials
  18811. */
  18812. wAng: number;
  18813. /**
  18814. * Defines the center of rotation (U)
  18815. */
  18816. uRotationCenter: number;
  18817. /**
  18818. * Defines the center of rotation (V)
  18819. */
  18820. vRotationCenter: number;
  18821. /**
  18822. * Defines the center of rotation (W)
  18823. */
  18824. wRotationCenter: number;
  18825. /**
  18826. * Are mip maps generated for this texture or not.
  18827. */
  18828. readonly noMipmap: boolean;
  18829. private _noMipmap;
  18830. /** @hidden */
  18831. _invertY: boolean;
  18832. private _rowGenerationMatrix;
  18833. private _cachedTextureMatrix;
  18834. private _projectionModeMatrix;
  18835. private _t0;
  18836. private _t1;
  18837. private _t2;
  18838. private _cachedUOffset;
  18839. private _cachedVOffset;
  18840. private _cachedUScale;
  18841. private _cachedVScale;
  18842. private _cachedUAng;
  18843. private _cachedVAng;
  18844. private _cachedWAng;
  18845. private _cachedProjectionMatrixId;
  18846. private _cachedCoordinatesMode;
  18847. /** @hidden */
  18848. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18849. private _deleteBuffer;
  18850. protected _format: Nullable<number>;
  18851. private _delayedOnLoad;
  18852. private _delayedOnError;
  18853. /**
  18854. * Observable triggered once the texture has been loaded.
  18855. */
  18856. onLoadObservable: Observable<Texture>;
  18857. protected _isBlocking: boolean;
  18858. /**
  18859. * Is the texture preventing material to render while loading.
  18860. * If false, a default texture will be used instead of the loading one during the preparation step.
  18861. */
  18862. isBlocking: boolean;
  18863. /**
  18864. * Get the current sampling mode associated with the texture.
  18865. */
  18866. readonly samplingMode: number;
  18867. /**
  18868. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18869. */
  18870. readonly invertY: boolean;
  18871. /**
  18872. * Instantiates a new texture.
  18873. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18874. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18875. * @param url define the url of the picture to load as a texture
  18876. * @param scene define the scene the texture will belong to
  18877. * @param noMipmap define if the texture will require mip maps or not
  18878. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18879. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18880. * @param onLoad define a callback triggered when the texture has been loaded
  18881. * @param onError define a callback triggered when an error occurred during the loading session
  18882. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18883. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18884. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18885. */
  18886. 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);
  18887. /**
  18888. * Update the url (and optional buffer) of this texture if url was null during construction.
  18889. * @param url the url of the texture
  18890. * @param buffer the buffer of the texture (defaults to null)
  18891. * @param onLoad callback called when the texture is loaded (defaults to null)
  18892. */
  18893. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18894. /**
  18895. * Finish the loading sequence of a texture flagged as delayed load.
  18896. * @hidden
  18897. */
  18898. delayLoad(): void;
  18899. private _prepareRowForTextureGeneration;
  18900. /**
  18901. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18902. * @returns the transform matrix of the texture.
  18903. */
  18904. getTextureMatrix(): Matrix;
  18905. /**
  18906. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18907. * @returns The reflection texture transform
  18908. */
  18909. getReflectionTextureMatrix(): Matrix;
  18910. /**
  18911. * Clones the texture.
  18912. * @returns the cloned texture
  18913. */
  18914. clone(): Texture;
  18915. /**
  18916. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18917. * @returns The JSON representation of the texture
  18918. */
  18919. serialize(): any;
  18920. /**
  18921. * Get the current class name of the texture useful for serialization or dynamic coding.
  18922. * @returns "Texture"
  18923. */
  18924. getClassName(): string;
  18925. /**
  18926. * Dispose the texture and release its associated resources.
  18927. */
  18928. dispose(): void;
  18929. /**
  18930. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18931. * @param parsedTexture Define the JSON representation of the texture
  18932. * @param scene Define the scene the parsed texture should be instantiated in
  18933. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18934. * @returns The parsed texture if successful
  18935. */
  18936. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18937. /**
  18938. * Creates a texture from its base 64 representation.
  18939. * @param data Define the base64 payload without the data: prefix
  18940. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18941. * @param scene Define the scene the texture should belong to
  18942. * @param noMipmap Forces the texture to not create mip map information if true
  18943. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18944. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18945. * @param onLoad define a callback triggered when the texture has been loaded
  18946. * @param onError define a callback triggered when an error occurred during the loading session
  18947. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18948. * @returns the created texture
  18949. */
  18950. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18951. /**
  18952. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18953. * @param data Define the base64 payload without the data: prefix
  18954. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18955. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18956. * @param scene Define the scene the texture should belong to
  18957. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18958. * @param noMipmap Forces the texture to not create mip map information if true
  18959. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18960. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18961. * @param onLoad define a callback triggered when the texture has been loaded
  18962. * @param onError define a callback triggered when an error occurred during the loading session
  18963. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18964. * @returns the created texture
  18965. */
  18966. 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;
  18967. }
  18968. }
  18969. declare module "babylonjs/Materials/Textures/rawTexture" {
  18970. import { Scene } from "babylonjs/scene";
  18971. import { Texture } from "babylonjs/Materials/Textures/texture";
  18972. /**
  18973. * Raw texture can help creating a texture directly from an array of data.
  18974. * This can be super useful if you either get the data from an uncompressed source or
  18975. * if you wish to create your texture pixel by pixel.
  18976. */
  18977. export class RawTexture extends Texture {
  18978. /**
  18979. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18980. */
  18981. format: number;
  18982. private _engine;
  18983. /**
  18984. * Instantiates a new RawTexture.
  18985. * Raw texture can help creating a texture directly from an array of data.
  18986. * This can be super useful if you either get the data from an uncompressed source or
  18987. * if you wish to create your texture pixel by pixel.
  18988. * @param data define the array of data to use to create the texture
  18989. * @param width define the width of the texture
  18990. * @param height define the height of the texture
  18991. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18992. * @param scene define the scene the texture belongs to
  18993. * @param generateMipMaps define whether mip maps should be generated or not
  18994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18997. */
  18998. constructor(data: ArrayBufferView, width: number, height: number,
  18999. /**
  19000. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19001. */
  19002. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19003. /**
  19004. * Updates the texture underlying data.
  19005. * @param data Define the new data of the texture
  19006. */
  19007. update(data: ArrayBufferView): void;
  19008. /**
  19009. * Creates a luminance texture from some data.
  19010. * @param data Define the texture data
  19011. * @param width Define the width of the texture
  19012. * @param height Define the height of the texture
  19013. * @param scene Define the scene the texture belongs to
  19014. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19015. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19016. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19017. * @returns the luminance texture
  19018. */
  19019. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19020. /**
  19021. * Creates a luminance alpha texture from some data.
  19022. * @param data Define the texture data
  19023. * @param width Define the width of the texture
  19024. * @param height Define the height of the texture
  19025. * @param scene Define the scene the texture belongs to
  19026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19029. * @returns the luminance alpha texture
  19030. */
  19031. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19032. /**
  19033. * Creates an alpha texture from some data.
  19034. * @param data Define the texture data
  19035. * @param width Define the width of the texture
  19036. * @param height Define the height of the texture
  19037. * @param scene Define the scene the texture belongs to
  19038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19041. * @returns the alpha texture
  19042. */
  19043. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19044. /**
  19045. * Creates a RGB texture from some data.
  19046. * @param data Define the texture data
  19047. * @param width Define the width of the texture
  19048. * @param height Define the height of the texture
  19049. * @param scene Define the scene the texture belongs to
  19050. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19053. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19054. * @returns the RGB alpha texture
  19055. */
  19056. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19057. /**
  19058. * Creates a RGBA texture from some data.
  19059. * @param data Define the texture data
  19060. * @param width Define the width of the texture
  19061. * @param height Define the height of the texture
  19062. * @param scene Define the scene the texture belongs to
  19063. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19064. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19065. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19066. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19067. * @returns the RGBA texture
  19068. */
  19069. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19070. /**
  19071. * Creates a R texture from some data.
  19072. * @param data Define the texture data
  19073. * @param width Define the width of the texture
  19074. * @param height Define the height of the texture
  19075. * @param scene Define the scene the texture belongs to
  19076. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19077. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19078. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19079. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19080. * @returns the R texture
  19081. */
  19082. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19083. }
  19084. }
  19085. declare module "babylonjs/Animations/animationPropertiesOverride" {
  19086. /**
  19087. * Class used to override all child animations of a given target
  19088. */
  19089. export class AnimationPropertiesOverride {
  19090. /**
  19091. * Gets or sets a value indicating if animation blending must be used
  19092. */
  19093. enableBlending: boolean;
  19094. /**
  19095. * Gets or sets the blending speed to use when enableBlending is true
  19096. */
  19097. blendingSpeed: number;
  19098. /**
  19099. * Gets or sets the default loop mode to use
  19100. */
  19101. loopMode: number;
  19102. }
  19103. }
  19104. declare module "babylonjs/Bones/skeleton" {
  19105. import { Bone } from "babylonjs/Bones/bone";
  19106. import { IAnimatable } from "babylonjs/Misc/tools";
  19107. import { Observable } from "babylonjs/Misc/observable";
  19108. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19109. import { Scene } from "babylonjs/scene";
  19110. import { Nullable } from "babylonjs/types";
  19111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19112. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19113. import { Animatable } from "babylonjs/Animations/animatable";
  19114. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19115. import { AnimationRange, Animation } from "babylonjs/Animations/animation";
  19116. /**
  19117. * Class used to handle skinning animations
  19118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19119. */
  19120. export class Skeleton implements IAnimatable {
  19121. /** defines the skeleton name */
  19122. name: string;
  19123. /** defines the skeleton Id */
  19124. id: string;
  19125. /**
  19126. * Defines the list of child bones
  19127. */
  19128. bones: Bone[];
  19129. /**
  19130. * Defines an estimate of the dimension of the skeleton at rest
  19131. */
  19132. dimensionsAtRest: Vector3;
  19133. /**
  19134. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19135. */
  19136. needInitialSkinMatrix: boolean;
  19137. /**
  19138. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19139. */
  19140. overrideMesh: Nullable<AbstractMesh>;
  19141. /**
  19142. * Gets the list of animations attached to this skeleton
  19143. */
  19144. animations: Array<Animation>;
  19145. private _scene;
  19146. private _isDirty;
  19147. private _transformMatrices;
  19148. private _transformMatrixTexture;
  19149. private _meshesWithPoseMatrix;
  19150. private _animatables;
  19151. private _identity;
  19152. private _synchronizedWithMesh;
  19153. private _ranges;
  19154. private _lastAbsoluteTransformsUpdateId;
  19155. private _canUseTextureForBones;
  19156. /** @hidden */
  19157. _numBonesWithLinkedTransformNode: number;
  19158. /**
  19159. * Specifies if the skeleton should be serialized
  19160. */
  19161. doNotSerialize: boolean;
  19162. /**
  19163. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19164. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19165. */
  19166. useTextureToStoreBoneMatrices: boolean;
  19167. private _animationPropertiesOverride;
  19168. /**
  19169. * Gets or sets the animation properties override
  19170. */
  19171. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19172. /**
  19173. * An observable triggered before computing the skeleton's matrices
  19174. */
  19175. onBeforeComputeObservable: Observable<Skeleton>;
  19176. /**
  19177. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19178. */
  19179. readonly isUsingTextureForMatrices: boolean;
  19180. /**
  19181. * Creates a new skeleton
  19182. * @param name defines the skeleton name
  19183. * @param id defines the skeleton Id
  19184. * @param scene defines the hosting scene
  19185. */
  19186. constructor(
  19187. /** defines the skeleton name */
  19188. name: string,
  19189. /** defines the skeleton Id */
  19190. id: string, scene: Scene);
  19191. /**
  19192. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19193. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19194. * @returns a Float32Array containing matrices data
  19195. */
  19196. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19197. /**
  19198. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19199. * @returns a raw texture containing the data
  19200. */
  19201. getTransformMatrixTexture(): Nullable<RawTexture>;
  19202. /**
  19203. * Gets the current hosting scene
  19204. * @returns a scene object
  19205. */
  19206. getScene(): Scene;
  19207. /**
  19208. * Gets a string representing the current skeleton data
  19209. * @param fullDetails defines a boolean indicating if we want a verbose version
  19210. * @returns a string representing the current skeleton data
  19211. */
  19212. toString(fullDetails?: boolean): string;
  19213. /**
  19214. * Get bone's index searching by name
  19215. * @param name defines bone's name to search for
  19216. * @return the indice of the bone. Returns -1 if not found
  19217. */
  19218. getBoneIndexByName(name: string): number;
  19219. /**
  19220. * Creater a new animation range
  19221. * @param name defines the name of the range
  19222. * @param from defines the start key
  19223. * @param to defines the end key
  19224. */
  19225. createAnimationRange(name: string, from: number, to: number): void;
  19226. /**
  19227. * Delete a specific animation range
  19228. * @param name defines the name of the range
  19229. * @param deleteFrames defines if frames must be removed as well
  19230. */
  19231. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19232. /**
  19233. * Gets a specific animation range
  19234. * @param name defines the name of the range to look for
  19235. * @returns the requested animation range or null if not found
  19236. */
  19237. getAnimationRange(name: string): Nullable<AnimationRange>;
  19238. /**
  19239. * Gets the list of all animation ranges defined on this skeleton
  19240. * @returns an array
  19241. */
  19242. getAnimationRanges(): Nullable<AnimationRange>[];
  19243. /**
  19244. * Copy animation range from a source skeleton.
  19245. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19246. * @param source defines the source skeleton
  19247. * @param name defines the name of the range to copy
  19248. * @param rescaleAsRequired defines if rescaling must be applied if required
  19249. * @returns true if operation was successful
  19250. */
  19251. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19252. /**
  19253. * Forces the skeleton to go to rest pose
  19254. */
  19255. returnToRest(): void;
  19256. private _getHighestAnimationFrame;
  19257. /**
  19258. * Begin a specific animation range
  19259. * @param name defines the name of the range to start
  19260. * @param loop defines if looping must be turned on (false by default)
  19261. * @param speedRatio defines the speed ratio to apply (1 by default)
  19262. * @param onAnimationEnd defines a callback which will be called when animation will end
  19263. * @returns a new animatable
  19264. */
  19265. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19266. /** @hidden */
  19267. _markAsDirty(): void;
  19268. /** @hidden */
  19269. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19270. /** @hidden */
  19271. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19272. private _computeTransformMatrices;
  19273. /**
  19274. * Build all resources required to render a skeleton
  19275. */
  19276. prepare(): void;
  19277. /**
  19278. * Gets the list of animatables currently running for this skeleton
  19279. * @returns an array of animatables
  19280. */
  19281. getAnimatables(): IAnimatable[];
  19282. /**
  19283. * Clone the current skeleton
  19284. * @param name defines the name of the new skeleton
  19285. * @param id defines the id of the enw skeleton
  19286. * @returns the new skeleton
  19287. */
  19288. clone(name: string, id: string): Skeleton;
  19289. /**
  19290. * Enable animation blending for this skeleton
  19291. * @param blendingSpeed defines the blending speed to apply
  19292. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19293. */
  19294. enableBlending(blendingSpeed?: number): void;
  19295. /**
  19296. * Releases all resources associated with the current skeleton
  19297. */
  19298. dispose(): void;
  19299. /**
  19300. * Serialize the skeleton in a JSON object
  19301. * @returns a JSON object
  19302. */
  19303. serialize(): any;
  19304. /**
  19305. * Creates a new skeleton from serialized data
  19306. * @param parsedSkeleton defines the serialized data
  19307. * @param scene defines the hosting scene
  19308. * @returns a new skeleton
  19309. */
  19310. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19311. /**
  19312. * Compute all node absolute transforms
  19313. * @param forceUpdate defines if computation must be done even if cache is up to date
  19314. */
  19315. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19316. /**
  19317. * Gets the root pose matrix
  19318. * @returns a matrix
  19319. */
  19320. getPoseMatrix(): Nullable<Matrix>;
  19321. /**
  19322. * Sorts bones per internal index
  19323. */
  19324. sortBones(): void;
  19325. private _sortBones;
  19326. }
  19327. }
  19328. declare module "babylonjs/Bones/bone" {
  19329. import { Skeleton } from "babylonjs/Bones/skeleton";
  19330. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  19331. import { Nullable } from "babylonjs/types";
  19332. import { Animation } from "babylonjs/Animations/animation";
  19333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19335. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19336. import { Node } from "babylonjs/node";
  19337. /**
  19338. * Class used to store bone information
  19339. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19340. */
  19341. export class Bone extends Node {
  19342. /**
  19343. * defines the bone name
  19344. */
  19345. name: string;
  19346. private static _tmpVecs;
  19347. private static _tmpQuat;
  19348. private static _tmpMats;
  19349. /**
  19350. * Gets the list of child bones
  19351. */
  19352. children: Bone[];
  19353. /** Gets the animations associated with this bone */
  19354. animations: Animation[];
  19355. /**
  19356. * Gets or sets bone length
  19357. */
  19358. length: number;
  19359. /**
  19360. * @hidden Internal only
  19361. * Set this value to map this bone to a different index in the transform matrices
  19362. * Set this value to -1 to exclude the bone from the transform matrices
  19363. */
  19364. _index: Nullable<number>;
  19365. private _skeleton;
  19366. private _localMatrix;
  19367. private _restPose;
  19368. private _baseMatrix;
  19369. private _absoluteTransform;
  19370. private _invertedAbsoluteTransform;
  19371. private _parent;
  19372. private _scalingDeterminant;
  19373. private _worldTransform;
  19374. private _localScaling;
  19375. private _localRotation;
  19376. private _localPosition;
  19377. private _needToDecompose;
  19378. private _needToCompose;
  19379. /** @hidden */
  19380. _linkedTransformNode: Nullable<TransformNode>;
  19381. /** @hidden */
  19382. /** @hidden */
  19383. _matrix: Matrix;
  19384. /**
  19385. * Create a new bone
  19386. * @param name defines the bone name
  19387. * @param skeleton defines the parent skeleton
  19388. * @param parentBone defines the parent (can be null if the bone is the root)
  19389. * @param localMatrix defines the local matrix
  19390. * @param restPose defines the rest pose matrix
  19391. * @param baseMatrix defines the base matrix
  19392. * @param index defines index of the bone in the hiearchy
  19393. */
  19394. constructor(
  19395. /**
  19396. * defines the bone name
  19397. */
  19398. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  19399. /**
  19400. * Gets the parent skeleton
  19401. * @returns a skeleton
  19402. */
  19403. getSkeleton(): Skeleton;
  19404. /**
  19405. * Gets parent bone
  19406. * @returns a bone or null if the bone is the root of the bone hierarchy
  19407. */
  19408. getParent(): Nullable<Bone>;
  19409. /**
  19410. * Sets the parent bone
  19411. * @param parent defines the parent (can be null if the bone is the root)
  19412. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  19413. */
  19414. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  19415. /**
  19416. * Gets the local matrix
  19417. * @returns a matrix
  19418. */
  19419. getLocalMatrix(): Matrix;
  19420. /**
  19421. * Gets the base matrix (initial matrix which remains unchanged)
  19422. * @returns a matrix
  19423. */
  19424. getBaseMatrix(): Matrix;
  19425. /**
  19426. * Gets the rest pose matrix
  19427. * @returns a matrix
  19428. */
  19429. getRestPose(): Matrix;
  19430. /**
  19431. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  19432. */
  19433. getWorldMatrix(): Matrix;
  19434. /**
  19435. * Sets the local matrix to rest pose matrix
  19436. */
  19437. returnToRest(): void;
  19438. /**
  19439. * Gets the inverse of the absolute transform matrix.
  19440. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  19441. * @returns a matrix
  19442. */
  19443. getInvertedAbsoluteTransform(): Matrix;
  19444. /**
  19445. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  19446. * @returns a matrix
  19447. */
  19448. getAbsoluteTransform(): Matrix;
  19449. /**
  19450. * Links with the given transform node.
  19451. * The local matrix of this bone is copied from the transform node every frame.
  19452. * @param transformNode defines the transform node to link to
  19453. */
  19454. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  19455. /** Gets or sets current position (in local space) */
  19456. position: Vector3;
  19457. /** Gets or sets current rotation (in local space) */
  19458. rotation: Vector3;
  19459. /** Gets or sets current rotation quaternion (in local space) */
  19460. rotationQuaternion: Quaternion;
  19461. /** Gets or sets current scaling (in local space) */
  19462. scaling: Vector3;
  19463. /**
  19464. * Gets the animation properties override
  19465. */
  19466. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19467. private _decompose;
  19468. private _compose;
  19469. /**
  19470. * Update the base and local matrices
  19471. * @param matrix defines the new base or local matrix
  19472. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  19473. * @param updateLocalMatrix defines if the local matrix should be updated
  19474. */
  19475. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  19476. /** @hidden */
  19477. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  19478. /**
  19479. * Flag the bone as dirty (Forcing it to update everything)
  19480. */
  19481. markAsDirty(): void;
  19482. private _markAsDirtyAndCompose;
  19483. private _markAsDirtyAndDecompose;
  19484. /**
  19485. * Copy an animation range from another bone
  19486. * @param source defines the source bone
  19487. * @param rangeName defines the range name to copy
  19488. * @param frameOffset defines the frame offset
  19489. * @param rescaleAsRequired defines if rescaling must be applied if required
  19490. * @param skelDimensionsRatio defines the scaling ratio
  19491. * @returns true if operation was successful
  19492. */
  19493. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  19494. /**
  19495. * Translate the bone in local or world space
  19496. * @param vec The amount to translate the bone
  19497. * @param space The space that the translation is in
  19498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19499. */
  19500. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  19501. /**
  19502. * Set the postion of the bone in local or world space
  19503. * @param position The position to set the bone
  19504. * @param space The space that the position is in
  19505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19506. */
  19507. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  19508. /**
  19509. * Set the absolute position of the bone (world space)
  19510. * @param position The position to set the bone
  19511. * @param mesh The mesh that this bone is attached to
  19512. */
  19513. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  19514. /**
  19515. * Scale the bone on the x, y and z axes (in local space)
  19516. * @param x The amount to scale the bone on the x axis
  19517. * @param y The amount to scale the bone on the y axis
  19518. * @param z The amount to scale the bone on the z axis
  19519. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  19520. */
  19521. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  19522. /**
  19523. * Set the bone scaling in local space
  19524. * @param scale defines the scaling vector
  19525. */
  19526. setScale(scale: Vector3): void;
  19527. /**
  19528. * Gets the current scaling in local space
  19529. * @returns the current scaling vector
  19530. */
  19531. getScale(): Vector3;
  19532. /**
  19533. * Gets the current scaling in local space and stores it in a target vector
  19534. * @param result defines the target vector
  19535. */
  19536. getScaleToRef(result: Vector3): void;
  19537. /**
  19538. * Set the yaw, pitch, and roll of the bone in local or world space
  19539. * @param yaw The rotation of the bone on the y axis
  19540. * @param pitch The rotation of the bone on the x axis
  19541. * @param roll The rotation of the bone on the z axis
  19542. * @param space The space that the axes of rotation are in
  19543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19544. */
  19545. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  19546. /**
  19547. * Add a rotation to the bone on an axis in local or world space
  19548. * @param axis The axis to rotate the bone on
  19549. * @param amount The amount to rotate the bone
  19550. * @param space The space that the axis is in
  19551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19552. */
  19553. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  19554. /**
  19555. * Set the rotation of the bone to a particular axis angle in local or world space
  19556. * @param axis The axis to rotate the bone on
  19557. * @param angle The angle that the bone should be rotated to
  19558. * @param space The space that the axis is in
  19559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19560. */
  19561. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  19562. /**
  19563. * Set the euler rotation of the bone in local of world space
  19564. * @param rotation The euler rotation that the bone should be set to
  19565. * @param space The space that the rotation is in
  19566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19567. */
  19568. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  19569. /**
  19570. * Set the quaternion rotation of the bone in local of world space
  19571. * @param quat The quaternion rotation that the bone should be set to
  19572. * @param space The space that the rotation is in
  19573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19574. */
  19575. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  19576. /**
  19577. * Set the rotation matrix of the bone in local of world space
  19578. * @param rotMat The rotation matrix that the bone should be set to
  19579. * @param space The space that the rotation is in
  19580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19581. */
  19582. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  19583. private _rotateWithMatrix;
  19584. private _getNegativeRotationToRef;
  19585. /**
  19586. * Get the position of the bone in local or world space
  19587. * @param space The space that the returned position is in
  19588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19589. * @returns The position of the bone
  19590. */
  19591. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  19592. /**
  19593. * Copy the position of the bone to a vector3 in local or world space
  19594. * @param space The space that the returned position is in
  19595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19596. * @param result The vector3 to copy the position to
  19597. */
  19598. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  19599. /**
  19600. * Get the absolute position of the bone (world space)
  19601. * @param mesh The mesh that this bone is attached to
  19602. * @returns The absolute position of the bone
  19603. */
  19604. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  19605. /**
  19606. * Copy the absolute position of the bone (world space) to the result param
  19607. * @param mesh The mesh that this bone is attached to
  19608. * @param result The vector3 to copy the absolute position to
  19609. */
  19610. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  19611. /**
  19612. * Compute the absolute transforms of this bone and its children
  19613. */
  19614. computeAbsoluteTransforms(): void;
  19615. /**
  19616. * Get the world direction from an axis that is in the local space of the bone
  19617. * @param localAxis The local direction that is used to compute the world direction
  19618. * @param mesh The mesh that this bone is attached to
  19619. * @returns The world direction
  19620. */
  19621. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  19622. /**
  19623. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  19624. * @param localAxis The local direction that is used to compute the world direction
  19625. * @param mesh The mesh that this bone is attached to
  19626. * @param result The vector3 that the world direction will be copied to
  19627. */
  19628. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  19629. /**
  19630. * Get the euler rotation of the bone in local or world space
  19631. * @param space The space that the rotation should be in
  19632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19633. * @returns The euler rotation
  19634. */
  19635. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  19636. /**
  19637. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  19638. * @param space The space that the rotation should be in
  19639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19640. * @param result The vector3 that the rotation should be copied to
  19641. */
  19642. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  19643. /**
  19644. * Get the quaternion rotation of the bone in either local or world space
  19645. * @param space The space that the rotation should be in
  19646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19647. * @returns The quaternion rotation
  19648. */
  19649. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  19650. /**
  19651. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  19652. * @param space The space that the rotation should be in
  19653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19654. * @param result The quaternion that the rotation should be copied to
  19655. */
  19656. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  19657. /**
  19658. * Get the rotation matrix of the bone in local or world space
  19659. * @param space The space that the rotation should be in
  19660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19661. * @returns The rotation matrix
  19662. */
  19663. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  19664. /**
  19665. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  19666. * @param space The space that the rotation should be in
  19667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  19668. * @param result The quaternion that the rotation should be copied to
  19669. */
  19670. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  19671. /**
  19672. * Get the world position of a point that is in the local space of the bone
  19673. * @param position The local position
  19674. * @param mesh The mesh that this bone is attached to
  19675. * @returns The world position
  19676. */
  19677. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  19678. /**
  19679. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  19680. * @param position The local position
  19681. * @param mesh The mesh that this bone is attached to
  19682. * @param result The vector3 that the world position should be copied to
  19683. */
  19684. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  19685. /**
  19686. * Get the local position of a point that is in world space
  19687. * @param position The world position
  19688. * @param mesh The mesh that this bone is attached to
  19689. * @returns The local position
  19690. */
  19691. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  19692. /**
  19693. * Get the local position of a point that is in world space and copy it to the result param
  19694. * @param position The world position
  19695. * @param mesh The mesh that this bone is attached to
  19696. * @param result The vector3 that the local position should be copied to
  19697. */
  19698. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  19699. }
  19700. }
  19701. declare module "babylonjs/Meshes/transformNode" {
  19702. import { DeepImmutable } from "babylonjs/types";
  19703. import { Observable } from "babylonjs/Misc/observable";
  19704. import { Nullable } from "babylonjs/types";
  19705. import { Camera } from "babylonjs/Cameras/camera";
  19706. import { Scene } from "babylonjs/scene";
  19707. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  19708. import { Node } from "babylonjs/node";
  19709. import { Bone } from "babylonjs/Bones/bone";
  19710. /**
  19711. * 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.
  19712. * @see https://doc.babylonjs.com/how_to/transformnode
  19713. */
  19714. export class TransformNode extends Node {
  19715. /**
  19716. * Object will not rotate to face the camera
  19717. */
  19718. static BILLBOARDMODE_NONE: number;
  19719. /**
  19720. * Object will rotate to face the camera but only on the x axis
  19721. */
  19722. static BILLBOARDMODE_X: number;
  19723. /**
  19724. * Object will rotate to face the camera but only on the y axis
  19725. */
  19726. static BILLBOARDMODE_Y: number;
  19727. /**
  19728. * Object will rotate to face the camera but only on the z axis
  19729. */
  19730. static BILLBOARDMODE_Z: number;
  19731. /**
  19732. * Object will rotate to face the camera
  19733. */
  19734. static BILLBOARDMODE_ALL: number;
  19735. private _forward;
  19736. private _forwardInverted;
  19737. private _up;
  19738. private _right;
  19739. private _rightInverted;
  19740. private _position;
  19741. private _rotation;
  19742. private _rotationQuaternion;
  19743. protected _scaling: Vector3;
  19744. protected _isDirty: boolean;
  19745. private _transformToBoneReferal;
  19746. /**
  19747. * Set the billboard mode. Default is 0.
  19748. *
  19749. * | Value | Type | Description |
  19750. * | --- | --- | --- |
  19751. * | 0 | BILLBOARDMODE_NONE | |
  19752. * | 1 | BILLBOARDMODE_X | |
  19753. * | 2 | BILLBOARDMODE_Y | |
  19754. * | 4 | BILLBOARDMODE_Z | |
  19755. * | 7 | BILLBOARDMODE_ALL | |
  19756. *
  19757. */
  19758. billboardMode: number;
  19759. /**
  19760. * 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
  19761. */
  19762. scalingDeterminant: number;
  19763. /**
  19764. * Sets the distance of the object to max, often used by skybox
  19765. */
  19766. infiniteDistance: boolean;
  19767. /**
  19768. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  19769. * By default the system will update normals to compensate
  19770. */
  19771. ignoreNonUniformScaling: boolean;
  19772. /** @hidden */
  19773. _poseMatrix: Matrix;
  19774. /** @hidden */
  19775. _localMatrix: Matrix;
  19776. private _absolutePosition;
  19777. private _pivotMatrix;
  19778. private _pivotMatrixInverse;
  19779. protected _postMultiplyPivotMatrix: boolean;
  19780. protected _isWorldMatrixFrozen: boolean;
  19781. /** @hidden */
  19782. _indexInSceneTransformNodesArray: number;
  19783. /**
  19784. * An event triggered after the world matrix is updated
  19785. */
  19786. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  19787. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  19788. /**
  19789. * Gets a string identifying the name of the class
  19790. * @returns "TransformNode" string
  19791. */
  19792. getClassName(): string;
  19793. /**
  19794. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  19795. */
  19796. position: Vector3;
  19797. /**
  19798. * 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)).
  19799. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  19800. */
  19801. rotation: Vector3;
  19802. /**
  19803. * 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)).
  19804. */
  19805. scaling: Vector3;
  19806. /**
  19807. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  19808. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  19809. */
  19810. rotationQuaternion: Nullable<Quaternion>;
  19811. /**
  19812. * The forward direction of that transform in world space.
  19813. */
  19814. readonly forward: Vector3;
  19815. /**
  19816. * The up direction of that transform in world space.
  19817. */
  19818. readonly up: Vector3;
  19819. /**
  19820. * The right direction of that transform in world space.
  19821. */
  19822. readonly right: Vector3;
  19823. /**
  19824. * Copies the parameter passed Matrix into the mesh Pose matrix.
  19825. * @param matrix the matrix to copy the pose from
  19826. * @returns this TransformNode.
  19827. */
  19828. updatePoseMatrix(matrix: Matrix): TransformNode;
  19829. /**
  19830. * Returns the mesh Pose matrix.
  19831. * @returns the pose matrix
  19832. */
  19833. getPoseMatrix(): Matrix;
  19834. /** @hidden */
  19835. _isSynchronized(): boolean;
  19836. /** @hidden */
  19837. _initCache(): void;
  19838. /**
  19839. * Flag the transform node as dirty (Forcing it to update everything)
  19840. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  19841. * @returns this transform node
  19842. */
  19843. markAsDirty(property: string): TransformNode;
  19844. /**
  19845. * Returns the current mesh absolute position.
  19846. * Returns a Vector3.
  19847. */
  19848. readonly absolutePosition: Vector3;
  19849. /**
  19850. * Sets a new matrix to apply before all other transformation
  19851. * @param matrix defines the transform matrix
  19852. * @returns the current TransformNode
  19853. */
  19854. setPreTransformMatrix(matrix: Matrix): TransformNode;
  19855. /**
  19856. * Sets a new pivot matrix to the current node
  19857. * @param matrix defines the new pivot matrix to use
  19858. * @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
  19859. * @returns the current TransformNode
  19860. */
  19861. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  19862. /**
  19863. * Returns the mesh pivot matrix.
  19864. * Default : Identity.
  19865. * @returns the matrix
  19866. */
  19867. getPivotMatrix(): Matrix;
  19868. /**
  19869. * Prevents the World matrix to be computed any longer.
  19870. * @returns the TransformNode.
  19871. */
  19872. freezeWorldMatrix(): TransformNode;
  19873. /**
  19874. * Allows back the World matrix computation.
  19875. * @returns the TransformNode.
  19876. */
  19877. unfreezeWorldMatrix(): this;
  19878. /**
  19879. * True if the World matrix has been frozen.
  19880. */
  19881. readonly isWorldMatrixFrozen: boolean;
  19882. /**
  19883. * Retuns the mesh absolute position in the World.
  19884. * @returns a Vector3.
  19885. */
  19886. getAbsolutePosition(): Vector3;
  19887. /**
  19888. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  19889. * @param absolutePosition the absolute position to set
  19890. * @returns the TransformNode.
  19891. */
  19892. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19893. /**
  19894. * Sets the mesh position in its local space.
  19895. * @param vector3 the position to set in localspace
  19896. * @returns the TransformNode.
  19897. */
  19898. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  19899. /**
  19900. * Returns the mesh position in the local space from the current World matrix values.
  19901. * @returns a new Vector3.
  19902. */
  19903. getPositionExpressedInLocalSpace(): Vector3;
  19904. /**
  19905. * Translates the mesh along the passed Vector3 in its local space.
  19906. * @param vector3 the distance to translate in localspace
  19907. * @returns the TransformNode.
  19908. */
  19909. locallyTranslate(vector3: Vector3): TransformNode;
  19910. private static _lookAtVectorCache;
  19911. /**
  19912. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  19913. * @param targetPoint the position (must be in same space as current mesh) to look at
  19914. * @param yawCor optional yaw (y-axis) correction in radians
  19915. * @param pitchCor optional pitch (x-axis) correction in radians
  19916. * @param rollCor optional roll (z-axis) correction in radians
  19917. * @param space the choosen space of the target
  19918. * @returns the TransformNode.
  19919. */
  19920. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  19921. /**
  19922. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  19923. * This Vector3 is expressed in the World space.
  19924. * @param localAxis axis to rotate
  19925. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  19926. */
  19927. getDirection(localAxis: Vector3): Vector3;
  19928. /**
  19929. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  19930. * localAxis is expressed in the mesh local space.
  19931. * result is computed in the Wordl space from the mesh World matrix.
  19932. * @param localAxis axis to rotate
  19933. * @param result the resulting transformnode
  19934. * @returns this TransformNode.
  19935. */
  19936. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  19937. /**
  19938. * Sets a new pivot point to the current node
  19939. * @param point defines the new pivot point to use
  19940. * @param space defines if the point is in world or local space (local by default)
  19941. * @returns the current TransformNode
  19942. */
  19943. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  19944. /**
  19945. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  19946. * @returns the pivot point
  19947. */
  19948. getPivotPoint(): Vector3;
  19949. /**
  19950. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  19951. * @param result the vector3 to store the result
  19952. * @returns this TransformNode.
  19953. */
  19954. getPivotPointToRef(result: Vector3): TransformNode;
  19955. /**
  19956. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  19957. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  19958. */
  19959. getAbsolutePivotPoint(): Vector3;
  19960. /**
  19961. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  19962. * @param result vector3 to store the result
  19963. * @returns this TransformNode.
  19964. */
  19965. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  19966. /**
  19967. * Defines the passed node as the parent of the current node.
  19968. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  19969. * @param node the node ot set as the parent
  19970. * @returns this TransformNode.
  19971. */
  19972. setParent(node: Nullable<Node>): TransformNode;
  19973. private _nonUniformScaling;
  19974. /**
  19975. * True if the scaling property of this object is non uniform eg. (1,2,1)
  19976. */
  19977. readonly nonUniformScaling: boolean;
  19978. /** @hidden */
  19979. _updateNonUniformScalingState(value: boolean): boolean;
  19980. /**
  19981. * Attach the current TransformNode to another TransformNode associated with a bone
  19982. * @param bone Bone affecting the TransformNode
  19983. * @param affectedTransformNode TransformNode associated with the bone
  19984. * @returns this object
  19985. */
  19986. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  19987. /**
  19988. * Detach the transform node if its associated with a bone
  19989. * @returns this object
  19990. */
  19991. detachFromBone(): TransformNode;
  19992. private static _rotationAxisCache;
  19993. /**
  19994. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  19995. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  19996. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  19997. * The passed axis is also normalized.
  19998. * @param axis the axis to rotate around
  19999. * @param amount the amount to rotate in radians
  20000. * @param space Space to rotate in (Default: local)
  20001. * @returns the TransformNode.
  20002. */
  20003. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20004. /**
  20005. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  20006. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  20007. * The passed axis is also normalized. .
  20008. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  20009. * @param point the point to rotate around
  20010. * @param axis the axis to rotate around
  20011. * @param amount the amount to rotate in radians
  20012. * @returns the TransformNode
  20013. */
  20014. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  20015. /**
  20016. * Translates the mesh along the axis vector for the passed distance in the given space.
  20017. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  20018. * @param axis the axis to translate in
  20019. * @param distance the distance to translate
  20020. * @param space Space to rotate in (Default: local)
  20021. * @returns the TransformNode.
  20022. */
  20023. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20024. /**
  20025. * Adds a rotation step to the mesh current rotation.
  20026. * x, y, z are Euler angles expressed in radians.
  20027. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  20028. * This means this rotation is made in the mesh local space only.
  20029. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  20030. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  20031. * ```javascript
  20032. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  20033. * ```
  20034. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  20035. * 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.
  20036. * @param x Rotation to add
  20037. * @param y Rotation to add
  20038. * @param z Rotation to add
  20039. * @returns the TransformNode.
  20040. */
  20041. addRotation(x: number, y: number, z: number): TransformNode;
  20042. /**
  20043. * Computes the world matrix of the node
  20044. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20045. * @returns the world matrix
  20046. */
  20047. computeWorldMatrix(force?: boolean): Matrix;
  20048. protected _afterComputeWorldMatrix(): void;
  20049. /**
  20050. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  20051. * @param func callback function to add
  20052. *
  20053. * @returns the TransformNode.
  20054. */
  20055. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  20056. /**
  20057. * Removes a registered callback function.
  20058. * @param func callback function to remove
  20059. * @returns the TransformNode.
  20060. */
  20061. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  20062. /**
  20063. * Gets the position of the current mesh in camera space
  20064. * @param camera defines the camera to use
  20065. * @returns a position
  20066. */
  20067. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20068. /**
  20069. * Returns the distance from the mesh to the active camera
  20070. * @param camera defines the camera to use
  20071. * @returns the distance
  20072. */
  20073. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20074. /**
  20075. * Clone the current transform node
  20076. * @param name Name of the new clone
  20077. * @param newParent New parent for the clone
  20078. * @param doNotCloneChildren Do not clone children hierarchy
  20079. * @returns the new transform node
  20080. */
  20081. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  20082. /**
  20083. * Serializes the objects information.
  20084. * @param currentSerializationObject defines the object to serialize in
  20085. * @returns the serialized object
  20086. */
  20087. serialize(currentSerializationObject?: any): any;
  20088. /**
  20089. * Returns a new TransformNode object parsed from the source provided.
  20090. * @param parsedTransformNode is the source.
  20091. * @param scene the scne the object belongs to
  20092. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20093. * @returns a new TransformNode object parsed from the source provided.
  20094. */
  20095. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  20096. /**
  20097. * Get all child-transformNodes of this node
  20098. * @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
  20099. * @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
  20100. * @returns an array of TransformNode
  20101. */
  20102. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  20103. /**
  20104. * Releases resources associated with this transform node.
  20105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20107. */
  20108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20109. }
  20110. }
  20111. declare module "babylonjs/Meshes/groundMesh" {
  20112. import { Scene } from "babylonjs/scene";
  20113. import { Vector3 } from "babylonjs/Maths/math";
  20114. import { Mesh } from "babylonjs/Meshes/mesh";
  20115. /**
  20116. * Mesh representing the gorund
  20117. */
  20118. export class GroundMesh extends Mesh {
  20119. /** If octree should be generated */
  20120. generateOctree: boolean;
  20121. private _heightQuads;
  20122. /** @hidden */
  20123. _subdivisionsX: number;
  20124. /** @hidden */
  20125. _subdivisionsY: number;
  20126. /** @hidden */
  20127. _width: number;
  20128. /** @hidden */
  20129. _height: number;
  20130. /** @hidden */
  20131. _minX: number;
  20132. /** @hidden */
  20133. _maxX: number;
  20134. /** @hidden */
  20135. _minZ: number;
  20136. /** @hidden */
  20137. _maxZ: number;
  20138. constructor(name: string, scene: Scene);
  20139. /**
  20140. * "GroundMesh"
  20141. * @returns "GroundMesh"
  20142. */
  20143. getClassName(): string;
  20144. /**
  20145. * The minimum of x and y subdivisions
  20146. */
  20147. readonly subdivisions: number;
  20148. /**
  20149. * X subdivisions
  20150. */
  20151. readonly subdivisionsX: number;
  20152. /**
  20153. * Y subdivisions
  20154. */
  20155. readonly subdivisionsY: number;
  20156. /**
  20157. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20158. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20159. * @param chunksCount the number of subdivisions for x and y
  20160. * @param octreeBlocksSize (Default: 32)
  20161. */
  20162. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20163. /**
  20164. * Returns a height (y) value in the Worl system :
  20165. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20166. * @param x x coordinate
  20167. * @param z z coordinate
  20168. * @returns the ground y position if (x, z) are outside the ground surface.
  20169. */
  20170. getHeightAtCoordinates(x: number, z: number): number;
  20171. /**
  20172. * Returns a normalized vector (Vector3) orthogonal to the ground
  20173. * at the ground coordinates (x, z) expressed in the World system.
  20174. * @param x x coordinate
  20175. * @param z z coordinate
  20176. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20177. */
  20178. getNormalAtCoordinates(x: number, z: number): Vector3;
  20179. /**
  20180. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20181. * at the ground coordinates (x, z) expressed in the World system.
  20182. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20183. * @param x x coordinate
  20184. * @param z z coordinate
  20185. * @param ref vector to store the result
  20186. * @returns the GroundMesh.
  20187. */
  20188. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20189. /**
  20190. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20191. * if the ground has been updated.
  20192. * This can be used in the render loop.
  20193. * @returns the GroundMesh.
  20194. */
  20195. updateCoordinateHeights(): GroundMesh;
  20196. private _getFacetAt;
  20197. private _initHeightQuads;
  20198. private _computeHeightQuads;
  20199. /**
  20200. * Serializes this ground mesh
  20201. * @param serializationObject object to write serialization to
  20202. */
  20203. serialize(serializationObject: any): void;
  20204. /**
  20205. * Parses a serialized ground mesh
  20206. * @param parsedMesh the serialized mesh
  20207. * @param scene the scene to create the ground mesh in
  20208. * @returns the created ground mesh
  20209. */
  20210. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20211. }
  20212. }
  20213. declare module "babylonjs/Meshes/polygonMesh" {
  20214. import { Scene } from "babylonjs/scene";
  20215. import { Vector2, Path2 } from "babylonjs/Maths/math";
  20216. import { Mesh } from "babylonjs/Meshes/mesh";
  20217. /**
  20218. * Polygon
  20219. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20220. */
  20221. export class Polygon {
  20222. /**
  20223. * Creates a rectangle
  20224. * @param xmin bottom X coord
  20225. * @param ymin bottom Y coord
  20226. * @param xmax top X coord
  20227. * @param ymax top Y coord
  20228. * @returns points that make the resulting rectation
  20229. */
  20230. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  20231. /**
  20232. * Creates a circle
  20233. * @param radius radius of circle
  20234. * @param cx scale in x
  20235. * @param cy scale in y
  20236. * @param numberOfSides number of sides that make up the circle
  20237. * @returns points that make the resulting circle
  20238. */
  20239. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  20240. /**
  20241. * Creates a polygon from input string
  20242. * @param input Input polygon data
  20243. * @returns the parsed points
  20244. */
  20245. static Parse(input: string): Vector2[];
  20246. /**
  20247. * Starts building a polygon from x and y coordinates
  20248. * @param x x coordinate
  20249. * @param y y coordinate
  20250. * @returns the started path2
  20251. */
  20252. static StartingAt(x: number, y: number): Path2;
  20253. }
  20254. /**
  20255. * Builds a polygon
  20256. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  20257. */
  20258. export class PolygonMeshBuilder {
  20259. private _points;
  20260. private _outlinepoints;
  20261. private _holes;
  20262. private _name;
  20263. private _scene;
  20264. private _epoints;
  20265. private _eholes;
  20266. private _addToepoint;
  20267. /**
  20268. * Creates a PolygonMeshBuilder
  20269. * @param name name of the builder
  20270. * @param contours Path of the polygon
  20271. * @param scene scene to add to
  20272. */
  20273. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  20274. /**
  20275. * Adds a whole within the polygon
  20276. * @param hole Array of points defining the hole
  20277. * @returns this
  20278. */
  20279. addHole(hole: Vector2[]): PolygonMeshBuilder;
  20280. /**
  20281. * Creates the polygon
  20282. * @param updatable If the mesh should be updatable
  20283. * @param depth The depth of the mesh created
  20284. * @returns the created mesh
  20285. */
  20286. build(updatable?: boolean, depth?: number): Mesh;
  20287. /**
  20288. * Adds a side to the polygon
  20289. * @param positions points that make the polygon
  20290. * @param normals normals of the polygon
  20291. * @param uvs uvs of the polygon
  20292. * @param indices indices of the polygon
  20293. * @param bounds bounds of the polygon
  20294. * @param points points of the polygon
  20295. * @param depth depth of the polygon
  20296. * @param flip flip of the polygon
  20297. */
  20298. private addSide;
  20299. }
  20300. }
  20301. declare module "babylonjs/Meshes/meshBuilder" {
  20302. import { Nullable } from "babylonjs/types";
  20303. import { Scene } from "babylonjs/scene";
  20304. import { Vector3, Vector2, Color3, Color4, Plane, Vector4 } from "babylonjs/Maths/math";
  20305. import { Mesh } from "babylonjs/Meshes/mesh";
  20306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20307. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20308. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20309. /**
  20310. * Class containing static functions to help procedurally build meshes
  20311. */
  20312. export class MeshBuilder {
  20313. private static updateSideOrientation;
  20314. /**
  20315. * Creates a box mesh
  20316. * * The parameter `size` sets the size (float) of each box side (default 1)
  20317. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  20318. * * 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)
  20319. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  20320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20321. * * 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
  20322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20323. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  20324. * @param name defines the name of the mesh
  20325. * @param options defines the options used to create the mesh
  20326. * @param scene defines the hosting scene
  20327. * @returns the box mesh
  20328. */
  20329. static CreateBox(name: string, options: {
  20330. size?: number;
  20331. width?: number;
  20332. height?: number;
  20333. depth?: number;
  20334. faceUV?: Vector4[];
  20335. faceColors?: Color4[];
  20336. sideOrientation?: number;
  20337. frontUVs?: Vector4;
  20338. backUVs?: Vector4;
  20339. updatable?: boolean;
  20340. }, scene?: Nullable<Scene>): Mesh;
  20341. /**
  20342. * Creates a sphere mesh
  20343. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  20344. * * 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`)
  20345. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  20346. * * 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
  20347. * * 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)
  20348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20349. * * 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
  20350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20351. * @param name defines the name of the mesh
  20352. * @param options defines the options used to create the mesh
  20353. * @param scene defines the hosting scene
  20354. * @returns the sphere mesh
  20355. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  20356. */
  20357. static CreateSphere(name: string, options: {
  20358. segments?: number;
  20359. diameter?: number;
  20360. diameterX?: number;
  20361. diameterY?: number;
  20362. diameterZ?: number;
  20363. arc?: number;
  20364. slice?: number;
  20365. sideOrientation?: number;
  20366. frontUVs?: Vector4;
  20367. backUVs?: Vector4;
  20368. updatable?: boolean;
  20369. }, scene: any): Mesh;
  20370. /**
  20371. * Creates a plane polygonal mesh. By default, this is a disc
  20372. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  20373. * * 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
  20374. * * 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
  20375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20376. * * 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
  20377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20378. * @param name defines the name of the mesh
  20379. * @param options defines the options used to create the mesh
  20380. * @param scene defines the hosting scene
  20381. * @returns the plane polygonal mesh
  20382. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20383. */
  20384. static CreateDisc(name: string, options: {
  20385. radius?: number;
  20386. tessellation?: number;
  20387. arc?: number;
  20388. updatable?: boolean;
  20389. sideOrientation?: number;
  20390. frontUVs?: Vector4;
  20391. backUVs?: Vector4;
  20392. }, scene?: Nullable<Scene>): Mesh;
  20393. /**
  20394. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20395. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20396. * * 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`)
  20397. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20398. * * 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
  20399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20400. * * 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
  20401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20402. * @param name defines the name of the mesh
  20403. * @param options defines the options used to create the mesh
  20404. * @param scene defines the hosting scene
  20405. * @returns the icosahedron mesh
  20406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20407. */
  20408. static CreateIcoSphere(name: string, options: {
  20409. radius?: number;
  20410. radiusX?: number;
  20411. radiusY?: number;
  20412. radiusZ?: number;
  20413. flat?: boolean;
  20414. subdivisions?: number;
  20415. sideOrientation?: number;
  20416. frontUVs?: Vector4;
  20417. backUVs?: Vector4;
  20418. updatable?: boolean;
  20419. }, scene: Scene): Mesh;
  20420. /**
  20421. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  20422. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  20423. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  20424. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  20425. * * 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
  20426. * * 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
  20427. * * 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
  20428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20429. * * 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
  20430. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  20431. * * 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
  20432. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  20433. * * 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
  20434. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  20435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20436. * @param name defines the name of the mesh
  20437. * @param options defines the options used to create the mesh
  20438. * @param scene defines the hosting scene
  20439. * @returns the ribbon mesh
  20440. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  20441. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  20442. */
  20443. static CreateRibbon(name: string, options: {
  20444. pathArray: Vector3[][];
  20445. closeArray?: boolean;
  20446. closePath?: boolean;
  20447. offset?: number;
  20448. updatable?: boolean;
  20449. sideOrientation?: number;
  20450. frontUVs?: Vector4;
  20451. backUVs?: Vector4;
  20452. instance?: Mesh;
  20453. invertUV?: boolean;
  20454. uvs?: Vector2[];
  20455. colors?: Color4[];
  20456. }, scene?: Nullable<Scene>): Mesh;
  20457. /**
  20458. * Creates a cylinder or a cone mesh
  20459. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20460. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20461. * * 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.
  20462. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20463. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20464. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  20465. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  20466. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  20467. * * 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).
  20468. * * 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
  20469. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  20470. * * 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
  20471. * * 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.
  20472. * * If `enclose` is false, a ring surface is one element.
  20473. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  20474. * * 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
  20475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20476. * * 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
  20477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20478. * @param name defines the name of the mesh
  20479. * @param options defines the options used to create the mesh
  20480. * @param scene defines the hosting scene
  20481. * @returns the cylinder mesh
  20482. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20483. */
  20484. static CreateCylinder(name: string, options: {
  20485. height?: number;
  20486. diameterTop?: number;
  20487. diameterBottom?: number;
  20488. diameter?: number;
  20489. tessellation?: number;
  20490. subdivisions?: number;
  20491. arc?: number;
  20492. faceColors?: Color4[];
  20493. faceUV?: Vector4[];
  20494. updatable?: boolean;
  20495. hasRings?: boolean;
  20496. enclose?: boolean;
  20497. sideOrientation?: number;
  20498. frontUVs?: Vector4;
  20499. backUVs?: Vector4;
  20500. }, scene: any): Mesh;
  20501. /**
  20502. * Creates a torus mesh
  20503. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  20504. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  20505. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  20506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20507. * * 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
  20508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20509. * @param name defines the name of the mesh
  20510. * @param options defines the options used to create the mesh
  20511. * @param scene defines the hosting scene
  20512. * @returns the torus mesh
  20513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  20514. */
  20515. static CreateTorus(name: string, options: {
  20516. diameter?: number;
  20517. thickness?: number;
  20518. tessellation?: number;
  20519. updatable?: boolean;
  20520. sideOrientation?: number;
  20521. frontUVs?: Vector4;
  20522. backUVs?: Vector4;
  20523. }, scene: any): Mesh;
  20524. /**
  20525. * Creates a torus knot mesh
  20526. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  20527. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  20528. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  20529. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  20530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20531. * * 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
  20532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20533. * @param name defines the name of the mesh
  20534. * @param options defines the options used to create the mesh
  20535. * @param scene defines the hosting scene
  20536. * @returns the torus knot mesh
  20537. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20538. */
  20539. static CreateTorusKnot(name: string, options: {
  20540. radius?: number;
  20541. tube?: number;
  20542. radialSegments?: number;
  20543. tubularSegments?: number;
  20544. p?: number;
  20545. q?: number;
  20546. updatable?: boolean;
  20547. sideOrientation?: number;
  20548. frontUVs?: Vector4;
  20549. backUVs?: Vector4;
  20550. }, scene: any): Mesh;
  20551. /**
  20552. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  20553. * * 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
  20554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  20555. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  20556. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  20557. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  20558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  20559. * * 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
  20560. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  20561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  20563. * @param name defines the name of the new line system
  20564. * @param options defines the options used to create the line system
  20565. * @param scene defines the hosting scene
  20566. * @returns a new line system mesh
  20567. */
  20568. static CreateLineSystem(name: string, options: {
  20569. lines: Vector3[][];
  20570. updatable?: boolean;
  20571. instance?: Nullable<LinesMesh>;
  20572. colors?: Nullable<Color4[][]>;
  20573. useVertexAlpha?: boolean;
  20574. }, scene: Nullable<Scene>): LinesMesh;
  20575. /**
  20576. * Creates a line mesh
  20577. * 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
  20578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  20579. * * The parameter `points` is an array successive Vector3
  20580. * * 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
  20581. * * The optional parameter `colors` is an array of successive Color4, one per line point
  20582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  20583. * * When updating an instance, remember that only point positions can change, not the number of points
  20584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  20586. * @param name defines the name of the new line system
  20587. * @param options defines the options used to create the line system
  20588. * @param scene defines the hosting scene
  20589. * @returns a new line mesh
  20590. */
  20591. static CreateLines(name: string, options: {
  20592. points: Vector3[];
  20593. updatable?: boolean;
  20594. instance?: Nullable<LinesMesh>;
  20595. colors?: Color4[];
  20596. useVertexAlpha?: boolean;
  20597. }, scene?: Nullable<Scene>): LinesMesh;
  20598. /**
  20599. * Creates a dashed line mesh
  20600. * * 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
  20601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  20602. * * The parameter `points` is an array successive Vector3
  20603. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  20604. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  20605. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20606. * * 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
  20607. * * When updating an instance, remember that only point positions can change, not the number of points
  20608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20609. * @param name defines the name of the mesh
  20610. * @param options defines the options used to create the mesh
  20611. * @param scene defines the hosting scene
  20612. * @returns the dashed line mesh
  20613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  20614. */
  20615. static CreateDashedLines(name: string, options: {
  20616. points: Vector3[];
  20617. dashSize?: number;
  20618. gapSize?: number;
  20619. dashNb?: number;
  20620. updatable?: boolean;
  20621. instance?: LinesMesh;
  20622. }, scene?: Nullable<Scene>): LinesMesh;
  20623. /**
  20624. * 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.
  20625. * * 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.
  20626. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20627. * * 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.
  20628. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  20629. * * 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
  20630. * * 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
  20631. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20633. * * 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
  20634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  20635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20636. * @param name defines the name of the mesh
  20637. * @param options defines the options used to create the mesh
  20638. * @param scene defines the hosting scene
  20639. * @returns the extruded shape mesh
  20640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  20641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20642. */
  20643. static ExtrudeShape(name: string, options: {
  20644. shape: Vector3[];
  20645. path: Vector3[];
  20646. scale?: number;
  20647. rotation?: number;
  20648. cap?: number;
  20649. updatable?: boolean;
  20650. sideOrientation?: number;
  20651. frontUVs?: Vector4;
  20652. backUVs?: Vector4;
  20653. instance?: Mesh;
  20654. invertUV?: boolean;
  20655. }, scene?: Nullable<Scene>): Mesh;
  20656. /**
  20657. * Creates an custom extruded shape mesh.
  20658. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  20659. * * 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.
  20660. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20661. * * 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
  20662. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20663. * * 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
  20664. * * It must returns a float value that will be the scale value applied to the shape on each path point
  20665. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20666. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  20667. * * 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
  20668. * * 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
  20669. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  20670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20671. * * 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
  20672. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  20673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20674. * @param name defines the name of the mesh
  20675. * @param options defines the options used to create the mesh
  20676. * @param scene defines the hosting scene
  20677. * @returns the custom extruded shape mesh
  20678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  20679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  20680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20681. */
  20682. static ExtrudeShapeCustom(name: string, options: {
  20683. shape: Vector3[];
  20684. path: Vector3[];
  20685. scaleFunction?: any;
  20686. rotationFunction?: any;
  20687. ribbonCloseArray?: boolean;
  20688. ribbonClosePath?: boolean;
  20689. cap?: number;
  20690. updatable?: boolean;
  20691. sideOrientation?: number;
  20692. frontUVs?: Vector4;
  20693. backUVs?: Vector4;
  20694. instance?: Mesh;
  20695. invertUV?: boolean;
  20696. }, scene: Scene): Mesh;
  20697. /**
  20698. * Creates lathe mesh.
  20699. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  20700. * * 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
  20701. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  20702. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  20703. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  20704. * * 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
  20705. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  20706. * * 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
  20707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20708. * * 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
  20709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  20710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20711. * @param name defines the name of the mesh
  20712. * @param options defines the options used to create the mesh
  20713. * @param scene defines the hosting scene
  20714. * @returns the lathe mesh
  20715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  20716. */
  20717. static CreateLathe(name: string, options: {
  20718. shape: Vector3[];
  20719. radius?: number;
  20720. tessellation?: number;
  20721. clip?: number;
  20722. arc?: number;
  20723. closed?: boolean;
  20724. updatable?: boolean;
  20725. sideOrientation?: number;
  20726. frontUVs?: Vector4;
  20727. backUVs?: Vector4;
  20728. cap?: number;
  20729. invertUV?: boolean;
  20730. }, scene: Scene): Mesh;
  20731. /**
  20732. * Creates a plane mesh
  20733. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  20734. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  20735. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  20736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20737. * * 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
  20738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20739. * @param name defines the name of the mesh
  20740. * @param options defines the options used to create the mesh
  20741. * @param scene defines the hosting scene
  20742. * @returns the plane mesh
  20743. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  20744. */
  20745. static CreatePlane(name: string, options: {
  20746. size?: number;
  20747. width?: number;
  20748. height?: number;
  20749. sideOrientation?: number;
  20750. frontUVs?: Vector4;
  20751. backUVs?: Vector4;
  20752. updatable?: boolean;
  20753. sourcePlane?: Plane;
  20754. }, scene: Scene): Mesh;
  20755. /**
  20756. * Creates a ground mesh
  20757. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  20758. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  20759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20760. * @param name defines the name of the mesh
  20761. * @param options defines the options used to create the mesh
  20762. * @param scene defines the hosting scene
  20763. * @returns the ground mesh
  20764. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  20765. */
  20766. static CreateGround(name: string, options: {
  20767. width?: number;
  20768. height?: number;
  20769. subdivisions?: number;
  20770. subdivisionsX?: number;
  20771. subdivisionsY?: number;
  20772. updatable?: boolean;
  20773. }, scene: any): Mesh;
  20774. /**
  20775. * Creates a tiled ground mesh
  20776. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  20777. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  20778. * * 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
  20779. * * 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
  20780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20781. * @param name defines the name of the mesh
  20782. * @param options defines the options used to create the mesh
  20783. * @param scene defines the hosting scene
  20784. * @returns the tiled ground mesh
  20785. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20786. */
  20787. static CreateTiledGround(name: string, options: {
  20788. xmin: number;
  20789. zmin: number;
  20790. xmax: number;
  20791. zmax: number;
  20792. subdivisions?: {
  20793. w: number;
  20794. h: number;
  20795. };
  20796. precision?: {
  20797. w: number;
  20798. h: number;
  20799. };
  20800. updatable?: boolean;
  20801. }, scene: Scene): Mesh;
  20802. /**
  20803. * Creates a ground mesh from a height map
  20804. * * The parameter `url` sets the URL of the height map image resource.
  20805. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20806. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20807. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20808. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20809. * * 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.
  20810. * * 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).
  20811. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20813. * @param name defines the name of the mesh
  20814. * @param url defines the url to the height map
  20815. * @param options defines the options used to create the mesh
  20816. * @param scene defines the hosting scene
  20817. * @returns the ground mesh
  20818. * @see https://doc.babylonjs.com/babylon101/height_map
  20819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  20820. */
  20821. static CreateGroundFromHeightMap(name: string, url: string, options: {
  20822. width?: number;
  20823. height?: number;
  20824. subdivisions?: number;
  20825. minHeight?: number;
  20826. maxHeight?: number;
  20827. colorFilter?: Color3;
  20828. alphaFilter?: number;
  20829. updatable?: boolean;
  20830. onReady?: (mesh: GroundMesh) => void;
  20831. }, scene: Scene): GroundMesh;
  20832. /**
  20833. * Creates a polygon mesh
  20834. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  20835. * * 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
  20836. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20838. * * 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)
  20839. * * Remember you can only change the shape positions, not their number when updating a polygon
  20840. * @param name defines the name of the mesh
  20841. * @param options defines the options used to create the mesh
  20842. * @param scene defines the hosting scene
  20843. * @returns the polygon mesh
  20844. */
  20845. static CreatePolygon(name: string, options: {
  20846. shape: Vector3[];
  20847. holes?: Vector3[][];
  20848. depth?: number;
  20849. faceUV?: Vector4[];
  20850. faceColors?: Color4[];
  20851. updatable?: boolean;
  20852. sideOrientation?: number;
  20853. frontUVs?: Vector4;
  20854. backUVs?: Vector4;
  20855. }, scene: Scene): Mesh;
  20856. /**
  20857. * Creates an extruded polygon mesh, with depth in the Y direction.
  20858. * * 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)
  20859. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  20860. * @param name defines the name of the mesh
  20861. * @param options defines the options used to create the mesh
  20862. * @param scene defines the hosting scene
  20863. * @returns the polygon mesh
  20864. */
  20865. static ExtrudePolygon(name: string, options: {
  20866. shape: Vector3[];
  20867. holes?: Vector3[][];
  20868. depth?: number;
  20869. faceUV?: Vector4[];
  20870. faceColors?: Color4[];
  20871. updatable?: boolean;
  20872. sideOrientation?: number;
  20873. frontUVs?: Vector4;
  20874. backUVs?: Vector4;
  20875. }, scene: Scene): Mesh;
  20876. /**
  20877. * Creates a tube mesh.
  20878. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  20879. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  20880. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  20881. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  20882. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  20883. * * 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)
  20884. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  20885. * * 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
  20886. * * 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
  20887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20888. * * 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
  20889. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  20890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20891. * @param name defines the name of the mesh
  20892. * @param options defines the options used to create the mesh
  20893. * @param scene defines the hosting scene
  20894. * @returns the tube mesh
  20895. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  20896. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  20897. */
  20898. static CreateTube(name: string, options: {
  20899. path: Vector3[];
  20900. radius?: number;
  20901. tessellation?: number;
  20902. radiusFunction?: {
  20903. (i: number, distance: number): number;
  20904. };
  20905. cap?: number;
  20906. arc?: number;
  20907. updatable?: boolean;
  20908. sideOrientation?: number;
  20909. frontUVs?: Vector4;
  20910. backUVs?: Vector4;
  20911. instance?: Mesh;
  20912. invertUV?: boolean;
  20913. }, scene: Scene): Mesh;
  20914. /**
  20915. * Creates a polyhedron mesh
  20916. * * 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
  20917. * * The parameter `size` (positive float, default 1) sets the polygon size
  20918. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20919. * * 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`
  20920. * * 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
  20921. * * 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)`)
  20922. * * 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
  20923. * * 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
  20924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20925. * * 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
  20926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20927. * @param name defines the name of the mesh
  20928. * @param options defines the options used to create the mesh
  20929. * @param scene defines the hosting scene
  20930. * @returns the polyhedron mesh
  20931. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  20932. */
  20933. static CreatePolyhedron(name: string, options: {
  20934. type?: number;
  20935. size?: number;
  20936. sizeX?: number;
  20937. sizeY?: number;
  20938. sizeZ?: number;
  20939. custom?: any;
  20940. faceUV?: Vector4[];
  20941. faceColors?: Color4[];
  20942. flat?: boolean;
  20943. updatable?: boolean;
  20944. sideOrientation?: number;
  20945. frontUVs?: Vector4;
  20946. backUVs?: Vector4;
  20947. }, scene: Scene): Mesh;
  20948. /**
  20949. * Creates a decal mesh.
  20950. * 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
  20951. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  20952. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  20953. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  20954. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  20955. * @param name defines the name of the mesh
  20956. * @param sourceMesh defines the mesh where the decal must be applied
  20957. * @param options defines the options used to create the mesh
  20958. * @param scene defines the hosting scene
  20959. * @returns the decal mesh
  20960. * @see https://doc.babylonjs.com/how_to/decals
  20961. */
  20962. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  20963. position?: Vector3;
  20964. normal?: Vector3;
  20965. size?: Vector3;
  20966. angle?: number;
  20967. }): Mesh;
  20968. private static _ExtrudeShapeGeneric;
  20969. }
  20970. }
  20971. declare module "babylonjs/Particles/solidParticleSystem" {
  20972. import { Vector3 } from "babylonjs/Maths/math";
  20973. import { Mesh } from "babylonjs/Meshes/mesh";
  20974. import { Scene, IDisposable } from "babylonjs/scene";
  20975. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  20976. /**
  20977. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  20978. *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.
  20979. * The SPS is also a particle system. It provides some methods to manage the particles.
  20980. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  20981. *
  20982. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  20983. */
  20984. export class SolidParticleSystem implements IDisposable {
  20985. /**
  20986. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  20987. * Example : var p = SPS.particles[i];
  20988. */
  20989. particles: SolidParticle[];
  20990. /**
  20991. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  20992. */
  20993. nbParticles: number;
  20994. /**
  20995. * If the particles must ever face the camera (default false). Useful for planar particles.
  20996. */
  20997. billboard: boolean;
  20998. /**
  20999. * Recompute normals when adding a shape
  21000. */
  21001. recomputeNormals: boolean;
  21002. /**
  21003. * This a counter ofr your own usage. It's not set by any SPS functions.
  21004. */
  21005. counter: number;
  21006. /**
  21007. * The SPS name. This name is also given to the underlying mesh.
  21008. */
  21009. name: string;
  21010. /**
  21011. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21012. */
  21013. mesh: Mesh;
  21014. /**
  21015. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21016. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21017. */
  21018. vars: any;
  21019. /**
  21020. * This array is populated when the SPS is set as 'pickable'.
  21021. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21022. * Each element of this array is an object `{idx: int, faceId: int}`.
  21023. * `idx` is the picked particle index in the `SPS.particles` array
  21024. * `faceId` is the picked face index counted within this particle.
  21025. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21026. */
  21027. pickedParticles: {
  21028. idx: number;
  21029. faceId: number;
  21030. }[];
  21031. /**
  21032. * This array is populated when `enableDepthSort` is set to true.
  21033. * Each element of this array is an instance of the class DepthSortedParticle.
  21034. */
  21035. depthSortedParticles: DepthSortedParticle[];
  21036. /**
  21037. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21038. * @hidden
  21039. */
  21040. _bSphereOnly: boolean;
  21041. /**
  21042. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21043. * @hidden
  21044. */
  21045. _bSphereRadiusFactor: number;
  21046. private _scene;
  21047. private _positions;
  21048. private _indices;
  21049. private _normals;
  21050. private _colors;
  21051. private _uvs;
  21052. private _indices32;
  21053. private _positions32;
  21054. private _normals32;
  21055. private _fixedNormal32;
  21056. private _colors32;
  21057. private _uvs32;
  21058. private _index;
  21059. private _updatable;
  21060. private _pickable;
  21061. private _isVisibilityBoxLocked;
  21062. private _alwaysVisible;
  21063. private _depthSort;
  21064. private _shapeCounter;
  21065. private _copy;
  21066. private _color;
  21067. private _computeParticleColor;
  21068. private _computeParticleTexture;
  21069. private _computeParticleRotation;
  21070. private _computeParticleVertex;
  21071. private _computeBoundingBox;
  21072. private _depthSortParticles;
  21073. private _camera;
  21074. private _mustUnrotateFixedNormals;
  21075. private _particlesIntersect;
  21076. private _needs32Bits;
  21077. /**
  21078. * Creates a SPS (Solid Particle System) object.
  21079. * @param name (String) is the SPS name, this will be the underlying mesh name.
  21080. * @param scene (Scene) is the scene in which the SPS is added.
  21081. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  21082. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  21083. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  21084. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  21085. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  21086. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  21087. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  21088. */
  21089. constructor(name: string, scene: Scene, options?: {
  21090. updatable?: boolean;
  21091. isPickable?: boolean;
  21092. enableDepthSort?: boolean;
  21093. particleIntersection?: boolean;
  21094. boundingSphereOnly?: boolean;
  21095. bSphereRadiusFactor?: number;
  21096. });
  21097. /**
  21098. * Builds the SPS underlying mesh. Returns a standard Mesh.
  21099. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  21100. * @returns the created mesh
  21101. */
  21102. buildMesh(): Mesh;
  21103. /**
  21104. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  21105. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  21106. * Thus the particles generated from `digest()` have their property `position` set yet.
  21107. * @param mesh ( Mesh ) is the mesh to be digested
  21108. * @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
  21109. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  21110. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  21111. * @returns the current SPS
  21112. */
  21113. digest(mesh: Mesh, options?: {
  21114. facetNb?: number;
  21115. number?: number;
  21116. delta?: number;
  21117. }): SolidParticleSystem;
  21118. private _unrotateFixedNormals;
  21119. private _resetCopy;
  21120. private _meshBuilder;
  21121. private _posToShape;
  21122. private _uvsToShapeUV;
  21123. private _addParticle;
  21124. /**
  21125. * Adds some particles to the SPS from the model shape. Returns the shape id.
  21126. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  21127. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  21128. * @param nb (positive integer) the number of particles to be created from this model
  21129. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  21130. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  21131. * @returns the number of shapes in the system
  21132. */
  21133. addShape(mesh: Mesh, nb: number, options?: {
  21134. positionFunction?: any;
  21135. vertexFunction?: any;
  21136. }): number;
  21137. private _rebuildParticle;
  21138. /**
  21139. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  21140. * @returns the SPS.
  21141. */
  21142. rebuildMesh(): SolidParticleSystem;
  21143. /**
  21144. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  21145. * This method calls `updateParticle()` for each particle of the SPS.
  21146. * For an animated SPS, it is usually called within the render loop.
  21147. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  21148. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  21149. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  21150. * @returns the SPS.
  21151. */
  21152. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  21153. /**
  21154. * Disposes the SPS.
  21155. */
  21156. dispose(): void;
  21157. /**
  21158. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  21159. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21160. * @returns the SPS.
  21161. */
  21162. refreshVisibleSize(): SolidParticleSystem;
  21163. /**
  21164. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  21165. * @param size the size (float) of the visibility box
  21166. * note : this doesn't lock the SPS mesh bounding box.
  21167. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21168. */
  21169. setVisibilityBox(size: number): void;
  21170. /**
  21171. * Gets whether the SPS as always visible or not
  21172. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21173. */
  21174. /**
  21175. * Sets the SPS as always visible or not
  21176. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21177. */
  21178. isAlwaysVisible: boolean;
  21179. /**
  21180. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21181. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21182. */
  21183. /**
  21184. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21185. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21186. */
  21187. isVisibilityBoxLocked: boolean;
  21188. /**
  21189. * Tells to `setParticles()` to compute the particle rotations or not.
  21190. * Default value : true. The SPS is faster when it's set to false.
  21191. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21192. */
  21193. /**
  21194. * Gets if `setParticles()` computes the particle rotations or not.
  21195. * Default value : true. The SPS is faster when it's set to false.
  21196. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21197. */
  21198. computeParticleRotation: boolean;
  21199. /**
  21200. * Tells to `setParticles()` to compute the particle colors or not.
  21201. * Default value : true. The SPS is faster when it's set to false.
  21202. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21203. */
  21204. /**
  21205. * Gets if `setParticles()` computes the particle colors or not.
  21206. * Default value : true. The SPS is faster when it's set to false.
  21207. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21208. */
  21209. computeParticleColor: boolean;
  21210. /**
  21211. * Gets if `setParticles()` computes the particle textures or not.
  21212. * Default value : true. The SPS is faster when it's set to false.
  21213. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  21214. */
  21215. computeParticleTexture: boolean;
  21216. /**
  21217. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  21218. * Default value : false. The SPS is faster when it's set to false.
  21219. * Note : the particle custom vertex positions aren't stored values.
  21220. */
  21221. /**
  21222. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  21223. * Default value : false. The SPS is faster when it's set to false.
  21224. * Note : the particle custom vertex positions aren't stored values.
  21225. */
  21226. computeParticleVertex: boolean;
  21227. /**
  21228. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  21229. */
  21230. /**
  21231. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  21232. */
  21233. computeBoundingBox: boolean;
  21234. /**
  21235. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  21236. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21237. * Default : `true`
  21238. */
  21239. /**
  21240. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  21241. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21242. * Default : `true`
  21243. */
  21244. depthSortParticles: boolean;
  21245. /**
  21246. * This function does nothing. It may be overwritten to set all the particle first values.
  21247. * The SPS doesn't call this function, you may have to call it by your own.
  21248. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21249. */
  21250. initParticles(): void;
  21251. /**
  21252. * This function does nothing. It may be overwritten to recycle a particle.
  21253. * The SPS doesn't call this function, you may have to call it by your own.
  21254. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21255. * @param particle The particle to recycle
  21256. * @returns the recycled particle
  21257. */
  21258. recycleParticle(particle: SolidParticle): SolidParticle;
  21259. /**
  21260. * Updates a particle : this function should be overwritten by the user.
  21261. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  21262. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21263. * @example : just set a particle position or velocity and recycle conditions
  21264. * @param particle The particle to update
  21265. * @returns the updated particle
  21266. */
  21267. updateParticle(particle: SolidParticle): SolidParticle;
  21268. /**
  21269. * Updates a vertex of a particle : it can be overwritten by the user.
  21270. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  21271. * @param particle the current particle
  21272. * @param vertex the current index of the current particle
  21273. * @param pt the index of the current vertex in the particle shape
  21274. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  21275. * @example : just set a vertex particle position
  21276. * @returns the updated vertex
  21277. */
  21278. updateParticleVertex(vertex: Vector3): Vector3;
  21279. /**
  21280. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  21281. * This does nothing and may be overwritten by the user.
  21282. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21283. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21284. * @param update the boolean update value actually passed to setParticles()
  21285. */
  21286. beforeUpdateParticles(): void;
  21287. /**
  21288. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  21289. * This will be passed three parameters.
  21290. * This does nothing and may be overwritten by the user.
  21291. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21292. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21293. * @param update the boolean update value actually passed to setParticles()
  21294. */
  21295. afterUpdateParticles(): void;
  21296. }
  21297. }
  21298. declare module "babylonjs/Particles/solidParticle" {
  21299. import { Nullable } from "babylonjs/types";
  21300. import { Color4, Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math";
  21301. import { Mesh } from "babylonjs/Meshes/mesh";
  21302. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21303. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  21304. /**
  21305. * Represents one particle of a solid particle system.
  21306. */
  21307. export class SolidParticle {
  21308. /**
  21309. * particle global index
  21310. */
  21311. idx: number;
  21312. /**
  21313. * The color of the particle
  21314. */
  21315. color: Nullable<Color4>;
  21316. /**
  21317. * The world space position of the particle.
  21318. */
  21319. position: Vector3;
  21320. /**
  21321. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  21322. */
  21323. rotation: Vector3;
  21324. /**
  21325. * The world space rotation quaternion of the particle.
  21326. */
  21327. rotationQuaternion: Nullable<Quaternion>;
  21328. /**
  21329. * The scaling of the particle.
  21330. */
  21331. scaling: Vector3;
  21332. /**
  21333. * The uvs of the particle.
  21334. */
  21335. uvs: Vector4;
  21336. /**
  21337. * The current speed of the particle.
  21338. */
  21339. velocity: Vector3;
  21340. /**
  21341. * The pivot point in the particle local space.
  21342. */
  21343. pivot: Vector3;
  21344. /**
  21345. * Must the particle be translated from its pivot point in its local space ?
  21346. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  21347. * Default : false
  21348. */
  21349. translateFromPivot: boolean;
  21350. /**
  21351. * Is the particle active or not ?
  21352. */
  21353. alive: boolean;
  21354. /**
  21355. * Is the particle visible or not ?
  21356. */
  21357. isVisible: boolean;
  21358. /**
  21359. * Index of this particle in the global "positions" array (Internal use)
  21360. * @hidden
  21361. */
  21362. _pos: number;
  21363. /**
  21364. * @hidden Index of this particle in the global "indices" array (Internal use)
  21365. */
  21366. _ind: number;
  21367. /**
  21368. * @hidden ModelShape of this particle (Internal use)
  21369. */
  21370. _model: ModelShape;
  21371. /**
  21372. * ModelShape id of this particle
  21373. */
  21374. shapeId: number;
  21375. /**
  21376. * Index of the particle in its shape id (Internal use)
  21377. */
  21378. idxInShape: number;
  21379. /**
  21380. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  21381. */
  21382. _modelBoundingInfo: BoundingInfo;
  21383. /**
  21384. * @hidden Particle BoundingInfo object (Internal use)
  21385. */
  21386. _boundingInfo: BoundingInfo;
  21387. /**
  21388. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  21389. */
  21390. _sps: SolidParticleSystem;
  21391. /**
  21392. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  21393. */
  21394. _stillInvisible: boolean;
  21395. /**
  21396. * @hidden Last computed particle rotation matrix
  21397. */
  21398. _rotationMatrix: number[];
  21399. /**
  21400. * Parent particle Id, if any.
  21401. * Default null.
  21402. */
  21403. parentId: Nullable<number>;
  21404. /**
  21405. * @hidden Internal global position in the SPS.
  21406. */
  21407. _globalPosition: Vector3;
  21408. /**
  21409. * Creates a Solid Particle object.
  21410. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  21411. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  21412. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  21413. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  21414. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  21415. * @param shapeId (integer) is the model shape identifier in the SPS.
  21416. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  21417. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  21418. */
  21419. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  21420. /**
  21421. * Legacy support, changed scale to scaling
  21422. */
  21423. /**
  21424. * Legacy support, changed scale to scaling
  21425. */
  21426. scale: Vector3;
  21427. /**
  21428. * Legacy support, changed quaternion to rotationQuaternion
  21429. */
  21430. /**
  21431. * Legacy support, changed quaternion to rotationQuaternion
  21432. */
  21433. quaternion: Nullable<Quaternion>;
  21434. /**
  21435. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  21436. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  21437. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  21438. * @returns true if it intersects
  21439. */
  21440. intersectsMesh(target: Mesh | SolidParticle): boolean;
  21441. /**
  21442. * get the rotation matrix of the particle
  21443. * @hidden
  21444. */
  21445. getRotationMatrix(m: Matrix): void;
  21446. }
  21447. /**
  21448. * Represents the shape of the model used by one particle of a solid particle system.
  21449. * SPS internal tool, don't use it manually.
  21450. */
  21451. export class ModelShape {
  21452. /**
  21453. * The shape id
  21454. * @hidden
  21455. */
  21456. shapeID: number;
  21457. /**
  21458. * flat array of model positions (internal use)
  21459. * @hidden
  21460. */
  21461. _shape: Vector3[];
  21462. /**
  21463. * flat array of model UVs (internal use)
  21464. * @hidden
  21465. */
  21466. _shapeUV: number[];
  21467. /**
  21468. * length of the shape in the model indices array (internal use)
  21469. * @hidden
  21470. */
  21471. _indicesLength: number;
  21472. /**
  21473. * Custom position function (internal use)
  21474. * @hidden
  21475. */
  21476. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  21477. /**
  21478. * Custom vertex function (internal use)
  21479. * @hidden
  21480. */
  21481. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  21482. /**
  21483. * 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.
  21484. * SPS internal tool, don't use it manually.
  21485. * @hidden
  21486. */
  21487. 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>);
  21488. }
  21489. /**
  21490. * Represents a Depth Sorted Particle in the solid particle system.
  21491. */
  21492. export class DepthSortedParticle {
  21493. /**
  21494. * Index of the particle in the "indices" array
  21495. */
  21496. ind: number;
  21497. /**
  21498. * Length of the particle shape in the "indices" array
  21499. */
  21500. indicesLength: number;
  21501. /**
  21502. * Squared distance from the particle to the camera
  21503. */
  21504. sqDistance: number;
  21505. }
  21506. }
  21507. declare module "babylonjs/Meshes/abstractMesh" {
  21508. import { Observable } from "babylonjs/Misc/observable";
  21509. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  21510. import { Camera } from "babylonjs/Cameras/camera";
  21511. import { Scene, IDisposable } from "babylonjs/scene";
  21512. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  21513. import { Node } from "babylonjs/node";
  21514. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  21516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  21518. import { Collider } from "babylonjs/Collisions/collider";
  21519. import { Ray } from "babylonjs/Culling/ray";
  21520. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21521. import { Material } from "babylonjs/Materials/material";
  21522. import { Light } from "babylonjs/Lights/light";
  21523. import { ActionManager } from "babylonjs/Actions/actionManager";
  21524. import { Skeleton } from "babylonjs/Bones/skeleton";
  21525. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  21526. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  21527. /**
  21528. * Class used to store all common mesh properties
  21529. */
  21530. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  21531. /** No occlusion */
  21532. static OCCLUSION_TYPE_NONE: number;
  21533. /** Occlusion set to optimisitic */
  21534. static OCCLUSION_TYPE_OPTIMISTIC: number;
  21535. /** Occlusion set to strict */
  21536. static OCCLUSION_TYPE_STRICT: number;
  21537. /** Use an accurante occlusion algorithm */
  21538. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  21539. /** Use a conservative occlusion algorithm */
  21540. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  21541. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  21542. static readonly CULLINGSTRATEGY_STANDARD: number;
  21543. /** Culling strategy with bounding sphere only and then frustum culling */
  21544. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  21545. /**
  21546. * No billboard
  21547. */
  21548. static readonly BILLBOARDMODE_NONE: number;
  21549. /** Billboard on X axis */
  21550. static readonly BILLBOARDMODE_X: number;
  21551. /** Billboard on Y axis */
  21552. static readonly BILLBOARDMODE_Y: number;
  21553. /** Billboard on Z axis */
  21554. static readonly BILLBOARDMODE_Z: number;
  21555. /** Billboard on all axes */
  21556. static readonly BILLBOARDMODE_ALL: number;
  21557. private _facetData;
  21558. /** Gets ot sets the culling strategy to use to find visible meshes */
  21559. cullingStrategy: number;
  21560. /**
  21561. * Gets the number of facets in the mesh
  21562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  21563. */
  21564. readonly facetNb: number;
  21565. /**
  21566. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  21567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  21568. */
  21569. partitioningSubdivisions: number;
  21570. /**
  21571. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  21572. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  21573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  21574. */
  21575. partitioningBBoxRatio: number;
  21576. /**
  21577. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  21578. * Works only for updatable meshes.
  21579. * Doesn't work with multi-materials
  21580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  21581. */
  21582. mustDepthSortFacets: boolean;
  21583. /**
  21584. * The location (Vector3) where the facet depth sort must be computed from.
  21585. * By default, the active camera position.
  21586. * Used only when facet depth sort is enabled
  21587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  21588. */
  21589. facetDepthSortFrom: Vector3;
  21590. /**
  21591. * gets a boolean indicating if facetData is enabled
  21592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  21593. */
  21594. readonly isFacetDataEnabled: boolean;
  21595. /** @hidden */
  21596. _updateNonUniformScalingState(value: boolean): boolean;
  21597. /**
  21598. * An event triggered when this mesh collides with another one
  21599. */
  21600. onCollideObservable: Observable<AbstractMesh>;
  21601. private _onCollideObserver;
  21602. /** Set a function to call when this mesh collides with another one */
  21603. onCollide: () => void;
  21604. /**
  21605. * An event triggered when the collision's position changes
  21606. */
  21607. onCollisionPositionChangeObservable: Observable<Vector3>;
  21608. private _onCollisionPositionChangeObserver;
  21609. /** Set a function to call when the collision's position changes */
  21610. onCollisionPositionChange: () => void;
  21611. /**
  21612. * An event triggered when material is changed
  21613. */
  21614. onMaterialChangedObservable: Observable<AbstractMesh>;
  21615. /**
  21616. * Gets or sets the orientation for POV movement & rotation
  21617. */
  21618. definedFacingForward: boolean;
  21619. /** @hidden */
  21620. _occlusionQuery: Nullable<WebGLQuery>;
  21621. private _visibility;
  21622. /**
  21623. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  21624. */
  21625. /**
  21626. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  21627. */
  21628. visibility: number;
  21629. /** Gets or sets the alpha index used to sort transparent meshes
  21630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  21631. */
  21632. alphaIndex: number;
  21633. /**
  21634. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  21635. */
  21636. isVisible: boolean;
  21637. /**
  21638. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  21639. */
  21640. isPickable: boolean;
  21641. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  21642. showSubMeshesBoundingBox: boolean;
  21643. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  21644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  21645. */
  21646. isBlocker: boolean;
  21647. /**
  21648. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  21649. */
  21650. enablePointerMoveEvents: boolean;
  21651. /**
  21652. * Specifies the rendering group id for this mesh (0 by default)
  21653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  21654. */
  21655. renderingGroupId: number;
  21656. private _material;
  21657. /** Gets or sets current material */
  21658. material: Nullable<Material>;
  21659. private _receiveShadows;
  21660. /**
  21661. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  21662. * @see http://doc.babylonjs.com/babylon101/shadows
  21663. */
  21664. receiveShadows: boolean;
  21665. /** Defines color to use when rendering outline */
  21666. outlineColor: Color3;
  21667. /** Define width to use when rendering outline */
  21668. outlineWidth: number;
  21669. /** Defines color to use when rendering overlay */
  21670. overlayColor: Color3;
  21671. /** Defines alpha to use when rendering overlay */
  21672. overlayAlpha: number;
  21673. private _hasVertexAlpha;
  21674. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  21675. hasVertexAlpha: boolean;
  21676. private _useVertexColors;
  21677. /** 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) */
  21678. useVertexColors: boolean;
  21679. private _computeBonesUsingShaders;
  21680. /**
  21681. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  21682. */
  21683. computeBonesUsingShaders: boolean;
  21684. private _numBoneInfluencers;
  21685. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  21686. numBoneInfluencers: number;
  21687. private _applyFog;
  21688. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  21689. applyFog: boolean;
  21690. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  21691. useOctreeForRenderingSelection: boolean;
  21692. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  21693. useOctreeForPicking: boolean;
  21694. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  21695. useOctreeForCollisions: boolean;
  21696. private _layerMask;
  21697. /**
  21698. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  21699. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  21700. */
  21701. layerMask: number;
  21702. /**
  21703. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  21704. */
  21705. alwaysSelectAsActiveMesh: boolean;
  21706. /**
  21707. * Gets or sets the current action manager
  21708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21709. */
  21710. actionManager: Nullable<ActionManager>;
  21711. private _checkCollisions;
  21712. private _collisionMask;
  21713. private _collisionGroup;
  21714. /**
  21715. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  21716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21717. */
  21718. ellipsoid: Vector3;
  21719. /**
  21720. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  21721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21722. */
  21723. ellipsoidOffset: Vector3;
  21724. private _collider;
  21725. private _oldPositionForCollisions;
  21726. private _diffPositionForCollisions;
  21727. /**
  21728. * Gets or sets a collision mask used to mask collisions (default is -1).
  21729. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  21730. */
  21731. collisionMask: number;
  21732. /**
  21733. * Gets or sets the current collision group mask (-1 by default).
  21734. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  21735. */
  21736. collisionGroup: number;
  21737. /**
  21738. * Defines edge width used when edgesRenderer is enabled
  21739. * @see https://www.babylonjs-playground.com/#10OJSG#13
  21740. */
  21741. edgesWidth: number;
  21742. /**
  21743. * Defines edge color used when edgesRenderer is enabled
  21744. * @see https://www.babylonjs-playground.com/#10OJSG#13
  21745. */
  21746. edgesColor: Color4;
  21747. /** @hidden */
  21748. _edgesRenderer: Nullable<IEdgesRenderer>;
  21749. /** @hidden */
  21750. _masterMesh: Nullable<AbstractMesh>;
  21751. /** @hidden */
  21752. _boundingInfo: Nullable<BoundingInfo>;
  21753. /** @hidden */
  21754. _renderId: number;
  21755. /**
  21756. * Gets or sets the list of subMeshes
  21757. * @see http://doc.babylonjs.com/how_to/multi_materials
  21758. */
  21759. subMeshes: SubMesh[];
  21760. /** @hidden */
  21761. _intersectionsInProgress: AbstractMesh[];
  21762. /** @hidden */
  21763. _unIndexed: boolean;
  21764. /** @hidden */
  21765. _lightSources: Light[];
  21766. /** @hidden */
  21767. readonly _positions: Nullable<Vector3[]>;
  21768. /** @hidden */
  21769. _waitingActions: any;
  21770. /** @hidden */
  21771. _waitingFreezeWorldMatrix: Nullable<boolean>;
  21772. private _skeleton;
  21773. /** @hidden */
  21774. _bonesTransformMatrices: Nullable<Float32Array>;
  21775. /**
  21776. * Gets or sets a skeleton to apply skining transformations
  21777. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  21778. */
  21779. skeleton: Nullable<Skeleton>;
  21780. /**
  21781. * An event triggered when the mesh is rebuilt.
  21782. */
  21783. onRebuildObservable: Observable<AbstractMesh>;
  21784. /**
  21785. * Creates a new AbstractMesh
  21786. * @param name defines the name of the mesh
  21787. * @param scene defines the hosting scene
  21788. */
  21789. constructor(name: string, scene?: Nullable<Scene>);
  21790. /**
  21791. * Returns the string "AbstractMesh"
  21792. * @returns "AbstractMesh"
  21793. */
  21794. getClassName(): string;
  21795. /**
  21796. * Gets a string representation of the current mesh
  21797. * @param fullDetails defines a boolean indicating if full details must be included
  21798. * @returns a string representation of the current mesh
  21799. */
  21800. toString(fullDetails?: boolean): string;
  21801. /** @hidden */
  21802. _rebuild(): void;
  21803. /** @hidden */
  21804. _resyncLightSources(): void;
  21805. /** @hidden */
  21806. _resyncLighSource(light: Light): void;
  21807. /** @hidden */
  21808. _unBindEffect(): void;
  21809. /** @hidden */
  21810. _removeLightSource(light: Light): void;
  21811. private _markSubMeshesAsDirty;
  21812. /** @hidden */
  21813. _markSubMeshesAsLightDirty(): void;
  21814. /** @hidden */
  21815. _markSubMeshesAsAttributesDirty(): void;
  21816. /** @hidden */
  21817. _markSubMeshesAsMiscDirty(): void;
  21818. /**
  21819. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  21820. */
  21821. scaling: Vector3;
  21822. /**
  21823. * Returns true if the mesh is blocked. Implemented by child classes
  21824. */
  21825. readonly isBlocked: boolean;
  21826. /**
  21827. * Returns the mesh itself by default. Implemented by child classes
  21828. * @param camera defines the camera to use to pick the right LOD level
  21829. * @returns the currentAbstractMesh
  21830. */
  21831. getLOD(camera: Camera): Nullable<AbstractMesh>;
  21832. /**
  21833. * Returns 0 by default. Implemented by child classes
  21834. * @returns an integer
  21835. */
  21836. getTotalVertices(): number;
  21837. /**
  21838. * Returns a positive integer : the total number of indices in this mesh geometry.
  21839. * @returns the numner of indices or zero if the mesh has no geometry.
  21840. */
  21841. getTotalIndices(): number;
  21842. /**
  21843. * Returns null by default. Implemented by child classes
  21844. * @returns null
  21845. */
  21846. getIndices(): Nullable<IndicesArray>;
  21847. /**
  21848. * Returns the array of the requested vertex data kind. Implemented by child classes
  21849. * @param kind defines the vertex data kind to use
  21850. * @returns null
  21851. */
  21852. getVerticesData(kind: string): Nullable<FloatArray>;
  21853. /**
  21854. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21855. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21856. * Note that a new underlying VertexBuffer object is created each call.
  21857. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21858. * @param kind defines vertex data kind:
  21859. * * VertexBuffer.PositionKind
  21860. * * VertexBuffer.UVKind
  21861. * * VertexBuffer.UV2Kind
  21862. * * VertexBuffer.UV3Kind
  21863. * * VertexBuffer.UV4Kind
  21864. * * VertexBuffer.UV5Kind
  21865. * * VertexBuffer.UV6Kind
  21866. * * VertexBuffer.ColorKind
  21867. * * VertexBuffer.MatricesIndicesKind
  21868. * * VertexBuffer.MatricesIndicesExtraKind
  21869. * * VertexBuffer.MatricesWeightsKind
  21870. * * VertexBuffer.MatricesWeightsExtraKind
  21871. * @param data defines the data source
  21872. * @param updatable defines if the data must be flagged as updatable (or static)
  21873. * @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
  21874. * @returns the current mesh
  21875. */
  21876. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  21877. /**
  21878. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21879. * If the mesh has no geometry, it is simply returned as it is.
  21880. * @param kind defines vertex data kind:
  21881. * * VertexBuffer.PositionKind
  21882. * * VertexBuffer.UVKind
  21883. * * VertexBuffer.UV2Kind
  21884. * * VertexBuffer.UV3Kind
  21885. * * VertexBuffer.UV4Kind
  21886. * * VertexBuffer.UV5Kind
  21887. * * VertexBuffer.UV6Kind
  21888. * * VertexBuffer.ColorKind
  21889. * * VertexBuffer.MatricesIndicesKind
  21890. * * VertexBuffer.MatricesIndicesExtraKind
  21891. * * VertexBuffer.MatricesWeightsKind
  21892. * * VertexBuffer.MatricesWeightsExtraKind
  21893. * @param data defines the data source
  21894. * @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
  21895. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  21896. * @returns the current mesh
  21897. */
  21898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  21899. /**
  21900. * Sets the mesh indices,
  21901. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21902. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21903. * @param totalVertices Defines the total number of vertices
  21904. * @returns the current mesh
  21905. */
  21906. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  21907. /**
  21908. * Gets a boolean indicating if specific vertex data is present
  21909. * @param kind defines the vertex data kind to use
  21910. * @returns true is data kind is present
  21911. */
  21912. isVerticesDataPresent(kind: string): boolean;
  21913. /**
  21914. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  21915. * @returns a BoundingInfo
  21916. */
  21917. getBoundingInfo(): BoundingInfo;
  21918. /**
  21919. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  21920. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  21921. * @returns the current mesh
  21922. */
  21923. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  21924. /**
  21925. * Overwrite the current bounding info
  21926. * @param boundingInfo defines the new bounding info
  21927. * @returns the current mesh
  21928. */
  21929. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  21930. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  21931. readonly useBones: boolean;
  21932. /** @hidden */
  21933. _preActivate(): void;
  21934. /** @hidden */
  21935. _preActivateForIntermediateRendering(renderId: number): void;
  21936. /** @hidden */
  21937. _activate(renderId: number): void;
  21938. /**
  21939. * Gets the current world matrix
  21940. * @returns a Matrix
  21941. */
  21942. getWorldMatrix(): Matrix;
  21943. /** @hidden */
  21944. _getWorldMatrixDeterminant(): number;
  21945. /**
  21946. * Perform relative position change from the point of view of behind the front of the mesh.
  21947. * This is performed taking into account the meshes current rotation, so you do not have to care.
  21948. * Supports definition of mesh facing forward or backward
  21949. * @param amountRight defines the distance on the right axis
  21950. * @param amountUp defines the distance on the up axis
  21951. * @param amountForward defines the distance on the forward axis
  21952. * @returns the current mesh
  21953. */
  21954. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  21955. /**
  21956. * Calculate relative position change from the point of view of behind the front of the mesh.
  21957. * This is performed taking into account the meshes current rotation, so you do not have to care.
  21958. * Supports definition of mesh facing forward or backward
  21959. * @param amountRight defines the distance on the right axis
  21960. * @param amountUp defines the distance on the up axis
  21961. * @param amountForward defines the distance on the forward axis
  21962. * @returns the new displacement vector
  21963. */
  21964. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  21965. /**
  21966. * Perform relative rotation change from the point of view of behind the front of the mesh.
  21967. * Supports definition of mesh facing forward or backward
  21968. * @param flipBack defines the flip
  21969. * @param twirlClockwise defines the twirl
  21970. * @param tiltRight defines the tilt
  21971. * @returns the current mesh
  21972. */
  21973. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  21974. /**
  21975. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  21976. * Supports definition of mesh facing forward or backward.
  21977. * @param flipBack defines the flip
  21978. * @param twirlClockwise defines the twirl
  21979. * @param tiltRight defines the tilt
  21980. * @returns the new rotation vector
  21981. */
  21982. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  21983. /**
  21984. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  21985. * @param includeDescendants Include bounding info from descendants as well (true by default)
  21986. * @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
  21987. * @returns the new bounding vectors
  21988. */
  21989. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  21990. min: Vector3;
  21991. max: Vector3;
  21992. };
  21993. /**
  21994. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21995. * This means the mesh underlying bounding box and sphere are recomputed.
  21996. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21997. * @returns the current mesh
  21998. */
  21999. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  22000. /** @hidden */
  22001. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  22002. /** @hidden */
  22003. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  22004. /** @hidden */
  22005. _updateBoundingInfo(): AbstractMesh;
  22006. /** @hidden */
  22007. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  22008. /** @hidden */
  22009. protected _afterComputeWorldMatrix(): void;
  22010. /**
  22011. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22012. * A mesh is in the frustum if its bounding box intersects the frustum
  22013. * @param frustumPlanes defines the frustum to test
  22014. * @returns true if the mesh is in the frustum planes
  22015. */
  22016. isInFrustum(frustumPlanes: Plane[]): boolean;
  22017. /**
  22018. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22019. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  22020. * @param frustumPlanes defines the frustum to test
  22021. * @returns true if the mesh is completely in the frustum planes
  22022. */
  22023. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22024. /**
  22025. * True if the mesh intersects another mesh or a SolidParticle object
  22026. * @param mesh defines a target mesh or SolidParticle to test
  22027. * @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)
  22028. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  22029. * @returns true if there is an intersection
  22030. */
  22031. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  22032. /**
  22033. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  22034. * @param point defines the point to test
  22035. * @returns true if there is an intersection
  22036. */
  22037. intersectsPoint(point: Vector3): boolean;
  22038. /**
  22039. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  22040. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22041. */
  22042. checkCollisions: boolean;
  22043. /**
  22044. * Gets Collider object used to compute collisions (not physics)
  22045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22046. */
  22047. readonly collider: Collider;
  22048. /**
  22049. * Move the mesh using collision engine
  22050. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22051. * @param displacement defines the requested displacement vector
  22052. * @returns the current mesh
  22053. */
  22054. moveWithCollisions(displacement: Vector3): AbstractMesh;
  22055. private _onCollisionPositionChange;
  22056. /** @hidden */
  22057. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  22058. /** @hidden */
  22059. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  22060. /** @hidden */
  22061. _checkCollision(collider: Collider): AbstractMesh;
  22062. /** @hidden */
  22063. _generatePointsArray(): boolean;
  22064. /**
  22065. * Checks if the passed Ray intersects with the mesh
  22066. * @param ray defines the ray to use
  22067. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  22068. * @returns the picking info
  22069. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  22070. */
  22071. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  22072. /**
  22073. * Clones the current mesh
  22074. * @param name defines the mesh name
  22075. * @param newParent defines the new mesh parent
  22076. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  22077. * @returns the new mesh
  22078. */
  22079. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  22080. /**
  22081. * Disposes all the submeshes of the current meshnp
  22082. * @returns the current mesh
  22083. */
  22084. releaseSubMeshes(): AbstractMesh;
  22085. /**
  22086. * Releases resources associated with this abstract mesh.
  22087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22089. */
  22090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22091. /**
  22092. * Adds the passed mesh as a child to the current mesh
  22093. * @param mesh defines the child mesh
  22094. * @returns the current mesh
  22095. */
  22096. addChild(mesh: AbstractMesh): AbstractMesh;
  22097. /**
  22098. * Removes the passed mesh from the current mesh children list
  22099. * @param mesh defines the child mesh
  22100. * @returns the current mesh
  22101. */
  22102. removeChild(mesh: AbstractMesh): AbstractMesh;
  22103. /** @hidden */
  22104. private _initFacetData;
  22105. /**
  22106. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  22107. * This method can be called within the render loop.
  22108. * 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
  22109. * @returns the current mesh
  22110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22111. */
  22112. updateFacetData(): AbstractMesh;
  22113. /**
  22114. * Returns the facetLocalNormals array.
  22115. * The normals are expressed in the mesh local spac
  22116. * @returns an array of Vector3
  22117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22118. */
  22119. getFacetLocalNormals(): Vector3[];
  22120. /**
  22121. * Returns the facetLocalPositions array.
  22122. * The facet positions are expressed in the mesh local space
  22123. * @returns an array of Vector3
  22124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22125. */
  22126. getFacetLocalPositions(): Vector3[];
  22127. /**
  22128. * Returns the facetLocalPartioning array
  22129. * @returns an array of array of numbers
  22130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22131. */
  22132. getFacetLocalPartitioning(): number[][];
  22133. /**
  22134. * Returns the i-th facet position in the world system.
  22135. * This method allocates a new Vector3 per call
  22136. * @param i defines the facet index
  22137. * @returns a new Vector3
  22138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22139. */
  22140. getFacetPosition(i: number): Vector3;
  22141. /**
  22142. * Sets the reference Vector3 with the i-th facet position in the world system
  22143. * @param i defines the facet index
  22144. * @param ref defines the target vector
  22145. * @returns the current mesh
  22146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22147. */
  22148. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  22149. /**
  22150. * Returns the i-th facet normal in the world system.
  22151. * This method allocates a new Vector3 per call
  22152. * @param i defines the facet index
  22153. * @returns a new Vector3
  22154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22155. */
  22156. getFacetNormal(i: number): Vector3;
  22157. /**
  22158. * Sets the reference Vector3 with the i-th facet normal in the world system
  22159. * @param i defines the facet index
  22160. * @param ref defines the target vector
  22161. * @returns the current mesh
  22162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22163. */
  22164. getFacetNormalToRef(i: number, ref: Vector3): this;
  22165. /**
  22166. * 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)
  22167. * @param x defines x coordinate
  22168. * @param y defines y coordinate
  22169. * @param z defines z coordinate
  22170. * @returns the array of facet indexes
  22171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22172. */
  22173. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  22174. /**
  22175. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  22176. * @param projected sets as the (x,y,z) world projection on the facet
  22177. * @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
  22178. * @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
  22179. * @param x defines x coordinate
  22180. * @param y defines y coordinate
  22181. * @param z defines z coordinate
  22182. * @returns the face index if found (or null instead)
  22183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22184. */
  22185. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22186. /**
  22187. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  22188. * @param projected sets as the (x,y,z) local projection on the facet
  22189. * @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
  22190. * @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
  22191. * @param x defines x coordinate
  22192. * @param y defines y coordinate
  22193. * @param z defines z coordinate
  22194. * @returns the face index if found (or null instead)
  22195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22196. */
  22197. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22198. /**
  22199. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  22200. * @returns the parameters
  22201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22202. */
  22203. getFacetDataParameters(): any;
  22204. /**
  22205. * Disables the feature FacetData and frees the related memory
  22206. * @returns the current mesh
  22207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22208. */
  22209. disableFacetData(): AbstractMesh;
  22210. /**
  22211. * Updates the AbstractMesh indices array
  22212. * @param indices defines the data source
  22213. * @returns the current mesh
  22214. */
  22215. updateIndices(indices: IndicesArray): AbstractMesh;
  22216. /**
  22217. * Creates new normals data for the mesh
  22218. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  22219. * @returns the current mesh
  22220. */
  22221. createNormals(updatable: boolean): AbstractMesh;
  22222. /**
  22223. * Align the mesh with a normal
  22224. * @param normal defines the normal to use
  22225. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  22226. * @returns the current mesh
  22227. */
  22228. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  22229. /** @hidden */
  22230. _checkOcclusionQuery(): boolean;
  22231. }
  22232. }
  22233. declare module "babylonjs/Collisions/collider" {
  22234. import { Nullable, IndicesArray } from "babylonjs/types";
  22235. import { Vector3, Plane } from "babylonjs/Maths/math";
  22236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22237. /** @hidden */
  22238. export class Collider {
  22239. /** Define if a collision was found */
  22240. collisionFound: boolean;
  22241. /**
  22242. * Define last intersection point in local space
  22243. */
  22244. intersectionPoint: Vector3;
  22245. /**
  22246. * Define last collided mesh
  22247. */
  22248. collidedMesh: Nullable<AbstractMesh>;
  22249. private _collisionPoint;
  22250. private _planeIntersectionPoint;
  22251. private _tempVector;
  22252. private _tempVector2;
  22253. private _tempVector3;
  22254. private _tempVector4;
  22255. private _edge;
  22256. private _baseToVertex;
  22257. private _destinationPoint;
  22258. private _slidePlaneNormal;
  22259. private _displacementVector;
  22260. /** @hidden */
  22261. _radius: Vector3;
  22262. /** @hidden */
  22263. _retry: number;
  22264. private _velocity;
  22265. private _basePoint;
  22266. private _epsilon;
  22267. /** @hidden */
  22268. _velocityWorldLength: number;
  22269. /** @hidden */
  22270. _basePointWorld: Vector3;
  22271. private _velocityWorld;
  22272. private _normalizedVelocity;
  22273. /** @hidden */
  22274. _initialVelocity: Vector3;
  22275. /** @hidden */
  22276. _initialPosition: Vector3;
  22277. private _nearestDistance;
  22278. private _collisionMask;
  22279. collisionMask: number;
  22280. /**
  22281. * Gets the plane normal used to compute the sliding response (in local space)
  22282. */
  22283. readonly slidePlaneNormal: Vector3;
  22284. /** @hidden */
  22285. _initialize(source: Vector3, dir: Vector3, e: number): void;
  22286. /** @hidden */
  22287. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  22288. /** @hidden */
  22289. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  22290. /** @hidden */
  22291. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  22292. /** @hidden */
  22293. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  22294. /** @hidden */
  22295. _getResponse(pos: Vector3, vel: Vector3): void;
  22296. }
  22297. }
  22298. declare module "babylonjs/Materials/multiMaterial" {
  22299. import { Nullable } from "babylonjs/types";
  22300. import { Scene } from "babylonjs/scene";
  22301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22302. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22304. import { Material } from "babylonjs/Materials/material";
  22305. /**
  22306. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22307. * separate meshes. This can be use to improve performances.
  22308. * @see http://doc.babylonjs.com/how_to/multi_materials
  22309. */
  22310. export class MultiMaterial extends Material {
  22311. private _subMaterials;
  22312. /**
  22313. * Gets or Sets the list of Materials used within the multi material.
  22314. * They need to be ordered according to the submeshes order in the associated mesh
  22315. */
  22316. subMaterials: Nullable<Material>[];
  22317. /**
  22318. * Function used to align with Node.getChildren()
  22319. * @returns the list of Materials used within the multi material
  22320. */
  22321. getChildren(): Nullable<Material>[];
  22322. /**
  22323. * Instantiates a new Multi Material
  22324. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22325. * separate meshes. This can be use to improve performances.
  22326. * @see http://doc.babylonjs.com/how_to/multi_materials
  22327. * @param name Define the name in the scene
  22328. * @param scene Define the scene the material belongs to
  22329. */
  22330. constructor(name: string, scene: Scene);
  22331. private _hookArray;
  22332. /**
  22333. * Get one of the submaterial by its index in the submaterials array
  22334. * @param index The index to look the sub material at
  22335. * @returns The Material if the index has been defined
  22336. */
  22337. getSubMaterial(index: number): Nullable<Material>;
  22338. /**
  22339. * Get the list of active textures for the whole sub materials list.
  22340. * @returns All the textures that will be used during the rendering
  22341. */
  22342. getActiveTextures(): BaseTexture[];
  22343. /**
  22344. * Gets the current class name of the material e.g. "MultiMaterial"
  22345. * Mainly use in serialization.
  22346. * @returns the class name
  22347. */
  22348. getClassName(): string;
  22349. /**
  22350. * Checks if the material is ready to render the requested sub mesh
  22351. * @param mesh Define the mesh the submesh belongs to
  22352. * @param subMesh Define the sub mesh to look readyness for
  22353. * @param useInstances Define whether or not the material is used with instances
  22354. * @returns true if ready, otherwise false
  22355. */
  22356. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22357. /**
  22358. * Clones the current material and its related sub materials
  22359. * @param name Define the name of the newly cloned material
  22360. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22361. * @returns the cloned material
  22362. */
  22363. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22364. /**
  22365. * Serializes the materials into a JSON representation.
  22366. * @returns the JSON representation
  22367. */
  22368. serialize(): any;
  22369. /**
  22370. * Dispose the material and release its associated resources
  22371. * @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)
  22372. * @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)
  22373. */
  22374. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22375. /**
  22376. * Creates a MultiMaterial from parsed MultiMaterial data.
  22377. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22378. * @param scene defines the hosting scene
  22379. * @returns a new MultiMaterial
  22380. */
  22381. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22382. }
  22383. }
  22384. declare module "babylonjs/Meshes/subMesh" {
  22385. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22386. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22387. import { Engine } from "babylonjs/Engines/engine";
  22388. import { Collider } from "babylonjs/Collisions/collider";
  22389. import { IntersectionInfo } from "babylonjs/Collisions/pickingInfo";
  22390. import { Ray } from "babylonjs/Culling/ray";
  22391. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22392. import { Effect } from "babylonjs/Materials/effect";
  22393. import { Material } from "babylonjs/Materials/material";
  22394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22396. import { Mesh } from "babylonjs/Meshes/mesh";
  22397. /**
  22398. * Base class for submeshes
  22399. */
  22400. export class BaseSubMesh {
  22401. /** @hidden */
  22402. _materialDefines: Nullable<MaterialDefines>;
  22403. /** @hidden */
  22404. _materialEffect: Nullable<Effect>;
  22405. /**
  22406. * Gets associated effect
  22407. */
  22408. readonly effect: Nullable<Effect>;
  22409. /**
  22410. * Sets associated effect (effect used to render this submesh)
  22411. * @param effect defines the effect to associate with
  22412. * @param defines defines the set of defines used to compile this effect
  22413. */
  22414. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22415. }
  22416. /**
  22417. * Defines a subdivision inside a mesh
  22418. */
  22419. export class SubMesh extends BaseSubMesh implements ICullable {
  22420. /** the material index to use */
  22421. materialIndex: number;
  22422. /** vertex index start */
  22423. verticesStart: number;
  22424. /** vertices count */
  22425. verticesCount: number;
  22426. /** index start */
  22427. indexStart: number;
  22428. /** indices count */
  22429. indexCount: number;
  22430. /** @hidden */
  22431. _linesIndexCount: number;
  22432. private _mesh;
  22433. private _renderingMesh;
  22434. private _boundingInfo;
  22435. private _linesIndexBuffer;
  22436. /** @hidden */
  22437. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22438. /** @hidden */
  22439. _trianglePlanes: Plane[];
  22440. /** @hidden */
  22441. _lastColliderTransformMatrix: Matrix;
  22442. /** @hidden */
  22443. _renderId: number;
  22444. /** @hidden */
  22445. _alphaIndex: number;
  22446. /** @hidden */
  22447. _distanceToCamera: number;
  22448. /** @hidden */
  22449. _id: number;
  22450. private _currentMaterial;
  22451. /**
  22452. * Add a new submesh to a mesh
  22453. * @param materialIndex defines the material index to use
  22454. * @param verticesStart defines vertex index start
  22455. * @param verticesCount defines vertices count
  22456. * @param indexStart defines index start
  22457. * @param indexCount defines indices count
  22458. * @param mesh defines the parent mesh
  22459. * @param renderingMesh defines an optional rendering mesh
  22460. * @param createBoundingBox defines if bounding box should be created for this submesh
  22461. * @returns the new submesh
  22462. */
  22463. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22464. /**
  22465. * Creates a new submesh
  22466. * @param materialIndex defines the material index to use
  22467. * @param verticesStart defines vertex index start
  22468. * @param verticesCount defines vertices count
  22469. * @param indexStart defines index start
  22470. * @param indexCount defines indices count
  22471. * @param mesh defines the parent mesh
  22472. * @param renderingMesh defines an optional rendering mesh
  22473. * @param createBoundingBox defines if bounding box should be created for this submesh
  22474. */
  22475. constructor(
  22476. /** the material index to use */
  22477. materialIndex: number,
  22478. /** vertex index start */
  22479. verticesStart: number,
  22480. /** vertices count */
  22481. verticesCount: number,
  22482. /** index start */
  22483. indexStart: number,
  22484. /** indices count */
  22485. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22486. /**
  22487. * Returns true if this submesh covers the entire parent mesh
  22488. * @ignorenaming
  22489. */
  22490. readonly IsGlobal: boolean;
  22491. /**
  22492. * Returns the submesh BoudingInfo object
  22493. * @returns current bounding info (or mesh's one if the submesh is global)
  22494. */
  22495. getBoundingInfo(): BoundingInfo;
  22496. /**
  22497. * Sets the submesh BoundingInfo
  22498. * @param boundingInfo defines the new bounding info to use
  22499. * @returns the SubMesh
  22500. */
  22501. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22502. /**
  22503. * Returns the mesh of the current submesh
  22504. * @return the parent mesh
  22505. */
  22506. getMesh(): AbstractMesh;
  22507. /**
  22508. * Returns the rendering mesh of the submesh
  22509. * @returns the rendering mesh (could be different from parent mesh)
  22510. */
  22511. getRenderingMesh(): Mesh;
  22512. /**
  22513. * Returns the submesh material
  22514. * @returns null or the current material
  22515. */
  22516. getMaterial(): Nullable<Material>;
  22517. /**
  22518. * Sets a new updated BoundingInfo object to the submesh
  22519. * @returns the SubMesh
  22520. */
  22521. refreshBoundingInfo(): SubMesh;
  22522. /** @hidden */
  22523. _checkCollision(collider: Collider): boolean;
  22524. /**
  22525. * Updates the submesh BoundingInfo
  22526. * @param world defines the world matrix to use to update the bounding info
  22527. * @returns the submesh
  22528. */
  22529. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22530. /**
  22531. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22532. * @param frustumPlanes defines the frustum planes
  22533. * @returns true if the submesh is intersecting with the frustum
  22534. */
  22535. isInFrustum(frustumPlanes: Plane[]): boolean;
  22536. /**
  22537. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22538. * @param frustumPlanes defines the frustum planes
  22539. * @returns true if the submesh is inside the frustum
  22540. */
  22541. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22542. /**
  22543. * Renders the submesh
  22544. * @param enableAlphaMode defines if alpha needs to be used
  22545. * @returns the submesh
  22546. */
  22547. render(enableAlphaMode: boolean): SubMesh;
  22548. /**
  22549. * @hidden
  22550. */
  22551. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22552. /**
  22553. * Checks if the submesh intersects with a ray
  22554. * @param ray defines the ray to test
  22555. * @returns true is the passed ray intersects the submesh bounding box
  22556. */
  22557. canIntersects(ray: Ray): boolean;
  22558. /**
  22559. * Intersects current submesh with a ray
  22560. * @param ray defines the ray to test
  22561. * @param positions defines mesh's positions array
  22562. * @param indices defines mesh's indices array
  22563. * @param fastCheck defines if only bounding info should be used
  22564. * @returns intersection info or null if no intersection
  22565. */
  22566. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22567. /** @hidden */
  22568. private _intersectLines;
  22569. /** @hidden */
  22570. private _intersectTriangles;
  22571. /** @hidden */
  22572. _rebuild(): void;
  22573. /**
  22574. * Creates a new submesh from the passed mesh
  22575. * @param newMesh defines the new hosting mesh
  22576. * @param newRenderingMesh defines an optional rendering mesh
  22577. * @returns the new submesh
  22578. */
  22579. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22580. /**
  22581. * Release associated resources
  22582. */
  22583. dispose(): void;
  22584. /**
  22585. * Gets the class name
  22586. * @returns the string "SubMesh".
  22587. */
  22588. getClassName(): string;
  22589. /**
  22590. * Creates a new submesh from indices data
  22591. * @param materialIndex the index of the main mesh material
  22592. * @param startIndex the index where to start the copy in the mesh indices array
  22593. * @param indexCount the number of indices to copy then from the startIndex
  22594. * @param mesh the main mesh to create the submesh from
  22595. * @param renderingMesh the optional rendering mesh
  22596. * @returns a new submesh
  22597. */
  22598. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22599. }
  22600. }
  22601. declare module "babylonjs/Misc/filesInput" {
  22602. import { Engine } from "babylonjs/Engines/engine";
  22603. import { Scene } from "babylonjs/scene";
  22604. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  22605. /**
  22606. * Class used to help managing file picking and drag'n'drop
  22607. */
  22608. export class FilesInput {
  22609. /**
  22610. * List of files ready to be loaded
  22611. */
  22612. static FilesToLoad: {
  22613. [key: string]: File;
  22614. };
  22615. /**
  22616. * Callback called when a file is processed
  22617. */
  22618. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  22619. private _engine;
  22620. private _currentScene;
  22621. private _sceneLoadedCallback;
  22622. private _progressCallback;
  22623. private _additionalRenderLoopLogicCallback;
  22624. private _textureLoadingCallback;
  22625. private _startingProcessingFilesCallback;
  22626. private _onReloadCallback;
  22627. private _errorCallback;
  22628. private _elementToMonitor;
  22629. private _sceneFileToLoad;
  22630. private _filesToLoad;
  22631. /**
  22632. * Creates a new FilesInput
  22633. * @param engine defines the rendering engine
  22634. * @param scene defines the hosting scene
  22635. * @param sceneLoadedCallback callback called when scene is loaded
  22636. * @param progressCallback callback called to track progress
  22637. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  22638. * @param textureLoadingCallback callback called when a texture is loading
  22639. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  22640. * @param onReloadCallback callback called when a reload is requested
  22641. * @param errorCallback callback call if an error occurs
  22642. */
  22643. 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);
  22644. private _dragEnterHandler;
  22645. private _dragOverHandler;
  22646. private _dropHandler;
  22647. /**
  22648. * Calls this function to listen to drag'n'drop events on a specific DOM element
  22649. * @param elementToMonitor defines the DOM element to track
  22650. */
  22651. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  22652. /**
  22653. * Release all associated resources
  22654. */
  22655. dispose(): void;
  22656. private renderFunction;
  22657. private drag;
  22658. private drop;
  22659. private _traverseFolder;
  22660. private _processFiles;
  22661. /**
  22662. * Load files from a drop event
  22663. * @param event defines the drop event to use as source
  22664. */
  22665. loadFiles(event: any): void;
  22666. private _processReload;
  22667. /**
  22668. * Reload the current scene from the loaded files
  22669. */
  22670. reload(): void;
  22671. }
  22672. }
  22673. declare module "babylonjs/Animations/animationGroup" {
  22674. import { Animatable } from "babylonjs/Animations/animatable";
  22675. import { Animation } from "babylonjs/Animations/animation";
  22676. import { Scene, IDisposable } from "babylonjs/scene";
  22677. import { Observable } from "babylonjs/Misc/observable";
  22678. import { Nullable } from "babylonjs/types";
  22679. /**
  22680. * This class defines the direct association between an animation and a target
  22681. */
  22682. export class TargetedAnimation {
  22683. /**
  22684. * Animation to perform
  22685. */
  22686. animation: Animation;
  22687. /**
  22688. * Target to animate
  22689. */
  22690. target: any;
  22691. }
  22692. /**
  22693. * Use this class to create coordinated animations on multiple targets
  22694. */
  22695. export class AnimationGroup implements IDisposable {
  22696. /** The name of the animation group */
  22697. name: string;
  22698. private _scene;
  22699. private _targetedAnimations;
  22700. private _animatables;
  22701. private _from;
  22702. private _to;
  22703. private _isStarted;
  22704. private _isPaused;
  22705. private _speedRatio;
  22706. /**
  22707. * Gets or sets the unique id of the node
  22708. */
  22709. uniqueId: number;
  22710. /**
  22711. * This observable will notify when one animation have ended.
  22712. */
  22713. onAnimationEndObservable: Observable<TargetedAnimation>;
  22714. /**
  22715. * This observable will notify when all animations have ended.
  22716. */
  22717. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  22718. /**
  22719. * This observable will notify when all animations have paused.
  22720. */
  22721. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  22722. /**
  22723. * This observable will notify when all animations are playing.
  22724. */
  22725. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  22726. /**
  22727. * Gets the first frame
  22728. */
  22729. readonly from: number;
  22730. /**
  22731. * Gets the last frame
  22732. */
  22733. readonly to: number;
  22734. /**
  22735. * Define if the animations are started
  22736. */
  22737. readonly isStarted: boolean;
  22738. /**
  22739. * Gets a value indicating that the current group is playing
  22740. */
  22741. readonly isPlaying: boolean;
  22742. /**
  22743. * Gets or sets the speed ratio to use for all animations
  22744. */
  22745. /**
  22746. * Gets or sets the speed ratio to use for all animations
  22747. */
  22748. speedRatio: number;
  22749. /**
  22750. * Gets the targeted animations for this animation group
  22751. */
  22752. readonly targetedAnimations: Array<TargetedAnimation>;
  22753. /**
  22754. * returning the list of animatables controlled by this animation group.
  22755. */
  22756. readonly animatables: Array<Animatable>;
  22757. /**
  22758. * Instantiates a new Animation Group.
  22759. * This helps managing several animations at once.
  22760. * @see http://doc.babylonjs.com/how_to/group
  22761. * @param name Defines the name of the group
  22762. * @param scene Defines the scene the group belongs to
  22763. */
  22764. constructor(
  22765. /** The name of the animation group */
  22766. name: string, scene?: Nullable<Scene>);
  22767. /**
  22768. * Add an animation (with its target) in the group
  22769. * @param animation defines the animation we want to add
  22770. * @param target defines the target of the animation
  22771. * @returns the TargetedAnimation object
  22772. */
  22773. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  22774. /**
  22775. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  22776. * It can add constant keys at begin or end
  22777. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  22778. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  22779. * @returns the animation group
  22780. */
  22781. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  22782. /**
  22783. * Start all animations on given targets
  22784. * @param loop defines if animations must loop
  22785. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  22786. * @param from defines the from key (optional)
  22787. * @param to defines the to key (optional)
  22788. * @returns the current animation group
  22789. */
  22790. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  22791. /**
  22792. * Pause all animations
  22793. * @returns the animation group
  22794. */
  22795. pause(): AnimationGroup;
  22796. /**
  22797. * Play all animations to initial state
  22798. * This function will start() the animations if they were not started or will restart() them if they were paused
  22799. * @param loop defines if animations must loop
  22800. * @returns the animation group
  22801. */
  22802. play(loop?: boolean): AnimationGroup;
  22803. /**
  22804. * Reset all animations to initial state
  22805. * @returns the animation group
  22806. */
  22807. reset(): AnimationGroup;
  22808. /**
  22809. * Restart animations from key 0
  22810. * @returns the animation group
  22811. */
  22812. restart(): AnimationGroup;
  22813. /**
  22814. * Stop all animations
  22815. * @returns the animation group
  22816. */
  22817. stop(): AnimationGroup;
  22818. /**
  22819. * Set animation weight for all animatables
  22820. * @param weight defines the weight to use
  22821. * @return the animationGroup
  22822. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  22823. */
  22824. setWeightForAllAnimatables(weight: number): AnimationGroup;
  22825. /**
  22826. * Synchronize and normalize all animatables with a source animatable
  22827. * @param root defines the root animatable to synchronize with
  22828. * @return the animationGroup
  22829. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  22830. */
  22831. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  22832. /**
  22833. * Goes to a specific frame in this animation group
  22834. * @param frame the frame number to go to
  22835. * @return the animationGroup
  22836. */
  22837. goToFrame(frame: number): AnimationGroup;
  22838. /**
  22839. * Dispose all associated resources
  22840. */
  22841. dispose(): void;
  22842. private _checkAnimationGroupEnded;
  22843. /**
  22844. * Returns a new AnimationGroup object parsed from the source provided.
  22845. * @param parsedAnimationGroup defines the source
  22846. * @param scene defines the scene that will receive the animationGroup
  22847. * @returns a new AnimationGroup
  22848. */
  22849. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  22850. /**
  22851. * Returns the string "AnimationGroup"
  22852. * @returns "AnimationGroup"
  22853. */
  22854. getClassName(): string;
  22855. /**
  22856. * Creates a detailled string about the object
  22857. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  22858. * @returns a string representing the object
  22859. */
  22860. toString(fullDetails?: boolean): string;
  22861. }
  22862. }
  22863. declare module "babylonjs/Offline/IOfflineProvider" {
  22864. /**
  22865. * Class used to enable access to offline support
  22866. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  22867. */
  22868. export interface IOfflineProvider {
  22869. /**
  22870. * Gets a boolean indicating if scene must be saved in the database
  22871. */
  22872. enableSceneOffline: boolean;
  22873. /**
  22874. * Gets a boolean indicating if textures must be saved in the database
  22875. */
  22876. enableTexturesOffline: boolean;
  22877. /**
  22878. * Open the offline support and make it available
  22879. * @param successCallback defines the callback to call on success
  22880. * @param errorCallback defines the callback to call on error
  22881. */
  22882. open(successCallback: () => void, errorCallback: () => void): void;
  22883. /**
  22884. * Loads an image from the offline support
  22885. * @param url defines the url to load from
  22886. * @param image defines the target DOM image
  22887. */
  22888. loadImage(url: string, image: HTMLImageElement): void;
  22889. /**
  22890. * Loads a file from offline support
  22891. * @param url defines the URL to load from
  22892. * @param sceneLoaded defines a callback to call on success
  22893. * @param progressCallBack defines a callback to call when progress changed
  22894. * @param errorCallback defines a callback to call on error
  22895. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  22896. */
  22897. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  22898. }
  22899. }
  22900. declare module "babylonjs/assetContainer" {
  22901. import { AbstractScene } from "babylonjs/abstractScene";
  22902. import { Scene } from "babylonjs/scene";
  22903. import { Mesh } from "babylonjs/Meshes/mesh";
  22904. /**
  22905. * Set of assets to keep when moving a scene into an asset container.
  22906. */
  22907. export class KeepAssets extends AbstractScene {
  22908. }
  22909. /**
  22910. * Container with a set of assets that can be added or removed from a scene.
  22911. */
  22912. export class AssetContainer extends AbstractScene {
  22913. /**
  22914. * The scene the AssetContainer belongs to.
  22915. */
  22916. scene: Scene;
  22917. /**
  22918. * Instantiates an AssetContainer.
  22919. * @param scene The scene the AssetContainer belongs to.
  22920. */
  22921. constructor(scene: Scene);
  22922. /**
  22923. * Adds all the assets from the container to the scene.
  22924. */
  22925. addAllToScene(): void;
  22926. /**
  22927. * Removes all the assets in the container from the scene
  22928. */
  22929. removeAllFromScene(): void;
  22930. /**
  22931. * Disposes all the assets in the container
  22932. */
  22933. dispose(): void;
  22934. private _moveAssets;
  22935. /**
  22936. * Removes all the assets contained in the scene and adds them to the container.
  22937. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  22938. */
  22939. moveAllFromScene(keepAssets?: KeepAssets): void;
  22940. /**
  22941. * 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.
  22942. * @returns the root mesh
  22943. */
  22944. createRootMesh(): Mesh;
  22945. }
  22946. }
  22947. declare module "babylonjs/Loading/sceneLoader" {
  22948. import { Observable } from "babylonjs/Misc/observable";
  22949. import { Nullable } from "babylonjs/types";
  22950. import { Scene } from "babylonjs/scene";
  22951. import { Engine } from "babylonjs/Engines/engine";
  22952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22953. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  22954. import { AssetContainer } from "babylonjs/assetContainer";
  22955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22956. import { Skeleton } from "babylonjs/Bones/skeleton";
  22957. /**
  22958. * Class used to represent data loading progression
  22959. */
  22960. export class SceneLoaderProgressEvent {
  22961. /** defines if data length to load can be evaluated */
  22962. readonly lengthComputable: boolean;
  22963. /** defines the loaded data length */
  22964. readonly loaded: number;
  22965. /** defines the data length to load */
  22966. readonly total: number;
  22967. /**
  22968. * Create a new progress event
  22969. * @param lengthComputable defines if data length to load can be evaluated
  22970. * @param loaded defines the loaded data length
  22971. * @param total defines the data length to load
  22972. */
  22973. constructor(
  22974. /** defines if data length to load can be evaluated */
  22975. lengthComputable: boolean,
  22976. /** defines the loaded data length */
  22977. loaded: number,
  22978. /** defines the data length to load */
  22979. total: number);
  22980. /**
  22981. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  22982. * @param event defines the source event
  22983. * @returns a new SceneLoaderProgressEvent
  22984. */
  22985. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  22986. }
  22987. /**
  22988. * Interface used by SceneLoader plugins to define supported file extensions
  22989. */
  22990. export interface ISceneLoaderPluginExtensions {
  22991. /**
  22992. * Defines the list of supported extensions
  22993. */
  22994. [extension: string]: {
  22995. isBinary: boolean;
  22996. };
  22997. }
  22998. /**
  22999. * Interface used by SceneLoader plugin factory
  23000. */
  23001. export interface ISceneLoaderPluginFactory {
  23002. /**
  23003. * Defines the name of the factory
  23004. */
  23005. name: string;
  23006. /**
  23007. * Function called to create a new plugin
  23008. * @return the new plugin
  23009. */
  23010. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  23011. /**
  23012. * Boolean indicating if the plugin can direct load specific data
  23013. */
  23014. canDirectLoad?: (data: string) => boolean;
  23015. }
  23016. /**
  23017. * Interface used to define a SceneLoader plugin
  23018. */
  23019. export interface ISceneLoaderPlugin {
  23020. /**
  23021. * The friendly name of this plugin.
  23022. */
  23023. name: string;
  23024. /**
  23025. * The file extensions supported by this plugin.
  23026. */
  23027. extensions: string | ISceneLoaderPluginExtensions;
  23028. /**
  23029. * Import meshes into a scene.
  23030. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  23031. * @param scene The scene to import into
  23032. * @param data The data to import
  23033. * @param rootUrl The root url for scene and resources
  23034. * @param meshes The meshes array to import into
  23035. * @param particleSystems The particle systems array to import into
  23036. * @param skeletons The skeletons array to import into
  23037. * @param onError The callback when import fails
  23038. * @returns True if successful or false otherwise
  23039. */
  23040. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  23041. /**
  23042. * Load into a scene.
  23043. * @param scene The scene to load into
  23044. * @param data The data to import
  23045. * @param rootUrl The root url for scene and resources
  23046. * @param onError The callback when import fails
  23047. * @returns true if successful or false otherwise
  23048. */
  23049. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  23050. /**
  23051. * The callback that returns true if the data can be directly loaded.
  23052. */
  23053. canDirectLoad?: (data: string) => boolean;
  23054. /**
  23055. * The callback that allows custom handling of the root url based on the response url.
  23056. */
  23057. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  23058. /**
  23059. * Load into an asset container.
  23060. * @param scene The scene to load into
  23061. * @param data The data to import
  23062. * @param rootUrl The root url for scene and resources
  23063. * @param onError The callback when import fails
  23064. * @returns The loaded asset container
  23065. */
  23066. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  23067. }
  23068. /**
  23069. * Interface used to define an async SceneLoader plugin
  23070. */
  23071. export interface ISceneLoaderPluginAsync {
  23072. /**
  23073. * The friendly name of this plugin.
  23074. */
  23075. name: string;
  23076. /**
  23077. * The file extensions supported by this plugin.
  23078. */
  23079. extensions: string | ISceneLoaderPluginExtensions;
  23080. /**
  23081. * Import meshes into a scene.
  23082. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  23083. * @param scene The scene to import into
  23084. * @param data The data to import
  23085. * @param rootUrl The root url for scene and resources
  23086. * @param onProgress The callback when the load progresses
  23087. * @param fileName Defines the name of the file to load
  23088. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  23089. */
  23090. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  23091. meshes: AbstractMesh[];
  23092. particleSystems: IParticleSystem[];
  23093. skeletons: Skeleton[];
  23094. animationGroups: AnimationGroup[];
  23095. }>;
  23096. /**
  23097. * Load into a scene.
  23098. * @param scene The scene to load into
  23099. * @param data The data to import
  23100. * @param rootUrl The root url for scene and resources
  23101. * @param onProgress The callback when the load progresses
  23102. * @param fileName Defines the name of the file to load
  23103. * @returns Nothing
  23104. */
  23105. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  23106. /**
  23107. * The callback that returns true if the data can be directly loaded.
  23108. */
  23109. canDirectLoad?: (data: string) => boolean;
  23110. /**
  23111. * The callback that allows custom handling of the root url based on the response url.
  23112. */
  23113. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  23114. /**
  23115. * Load into an asset container.
  23116. * @param scene The scene to load into
  23117. * @param data The data to import
  23118. * @param rootUrl The root url for scene and resources
  23119. * @param onProgress The callback when the load progresses
  23120. * @param fileName Defines the name of the file to load
  23121. * @returns The loaded asset container
  23122. */
  23123. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  23124. }
  23125. /**
  23126. * Class used to load scene from various file formats using registered plugins
  23127. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  23128. */
  23129. export class SceneLoader {
  23130. private static _ForceFullSceneLoadingForIncremental;
  23131. private static _ShowLoadingScreen;
  23132. private static _CleanBoneMatrixWeights;
  23133. /**
  23134. * No logging while loading
  23135. */
  23136. static readonly NO_LOGGING: number;
  23137. /**
  23138. * Minimal logging while loading
  23139. */
  23140. static readonly MINIMAL_LOGGING: number;
  23141. /**
  23142. * Summary logging while loading
  23143. */
  23144. static readonly SUMMARY_LOGGING: number;
  23145. /**
  23146. * Detailled logging while loading
  23147. */
  23148. static readonly DETAILED_LOGGING: number;
  23149. private static _loggingLevel;
  23150. /**
  23151. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  23152. */
  23153. static ForceFullSceneLoadingForIncremental: boolean;
  23154. /**
  23155. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  23156. */
  23157. static ShowLoadingScreen: boolean;
  23158. /**
  23159. * Defines the current logging level (while loading the scene)
  23160. * @ignorenaming
  23161. */
  23162. static loggingLevel: number;
  23163. /**
  23164. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  23165. */
  23166. static CleanBoneMatrixWeights: boolean;
  23167. /**
  23168. * Event raised when a plugin is used to load a scene
  23169. */
  23170. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  23171. private static _registeredPlugins;
  23172. private static _getDefaultPlugin;
  23173. private static _getPluginForExtension;
  23174. private static _getPluginForDirectLoad;
  23175. private static _getPluginForFilename;
  23176. private static _getDirectLoad;
  23177. private static _loadData;
  23178. private static _getFileInfo;
  23179. /**
  23180. * Gets a plugin that can load the given extension
  23181. * @param extension defines the extension to load
  23182. * @returns a plugin or null if none works
  23183. */
  23184. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  23185. /**
  23186. * Gets a boolean indicating that the given extension can be loaded
  23187. * @param extension defines the extension to load
  23188. * @returns true if the extension is supported
  23189. */
  23190. static IsPluginForExtensionAvailable(extension: string): boolean;
  23191. /**
  23192. * Adds a new plugin to the list of registered plugins
  23193. * @param plugin defines the plugin to add
  23194. */
  23195. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  23196. /**
  23197. * Import meshes into a scene
  23198. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  23199. * @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)
  23200. * @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)
  23201. * @param scene the instance of BABYLON.Scene to append to
  23202. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  23203. * @param onProgress a callback with a progress event for each file being loaded
  23204. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  23205. * @param pluginExtension the extension used to determine the plugin
  23206. * @returns The loaded plugin
  23207. */
  23208. 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>;
  23209. /**
  23210. * Import meshes into a scene
  23211. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  23212. * @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)
  23213. * @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)
  23214. * @param scene the instance of BABYLON.Scene to append to
  23215. * @param onProgress a callback with a progress event for each file being loaded
  23216. * @param pluginExtension the extension used to determine the plugin
  23217. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  23218. */
  23219. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  23220. meshes: AbstractMesh[];
  23221. particleSystems: IParticleSystem[];
  23222. skeletons: Skeleton[];
  23223. animationGroups: AnimationGroup[];
  23224. }>;
  23225. /**
  23226. * Load a scene
  23227. * @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)
  23228. * @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)
  23229. * @param engine is the instance of BABYLON.Engine to use to create the scene
  23230. * @param onSuccess a callback with the scene when import succeeds
  23231. * @param onProgress a callback with a progress event for each file being loaded
  23232. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  23233. * @param pluginExtension the extension used to determine the plugin
  23234. * @returns The loaded plugin
  23235. */
  23236. 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>;
  23237. /**
  23238. * Load a scene
  23239. * @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)
  23240. * @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)
  23241. * @param engine is the instance of BABYLON.Engine to use to create the scene
  23242. * @param onProgress a callback with a progress event for each file being loaded
  23243. * @param pluginExtension the extension used to determine the plugin
  23244. * @returns The loaded scene
  23245. */
  23246. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  23247. /**
  23248. * Append a scene
  23249. * @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)
  23250. * @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)
  23251. * @param scene is the instance of BABYLON.Scene to append to
  23252. * @param onSuccess a callback with the scene when import succeeds
  23253. * @param onProgress a callback with a progress event for each file being loaded
  23254. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  23255. * @param pluginExtension the extension used to determine the plugin
  23256. * @returns The loaded plugin
  23257. */
  23258. 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>;
  23259. /**
  23260. * Append a scene
  23261. * @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)
  23262. * @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)
  23263. * @param scene is the instance of BABYLON.Scene to append to
  23264. * @param onProgress a callback with a progress event for each file being loaded
  23265. * @param pluginExtension the extension used to determine the plugin
  23266. * @returns The given scene
  23267. */
  23268. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  23269. /**
  23270. * Load a scene into an asset container
  23271. * @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)
  23272. * @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)
  23273. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  23274. * @param onSuccess a callback with the scene when import succeeds
  23275. * @param onProgress a callback with a progress event for each file being loaded
  23276. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  23277. * @param pluginExtension the extension used to determine the plugin
  23278. * @returns The loaded plugin
  23279. */
  23280. 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>;
  23281. /**
  23282. * Load a scene into an asset container
  23283. * @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)
  23284. * @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)
  23285. * @param scene is the instance of Scene to append to
  23286. * @param onProgress a callback with a progress event for each file being loaded
  23287. * @param pluginExtension the extension used to determine the plugin
  23288. * @returns The loaded asset container
  23289. */
  23290. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  23291. }
  23292. }
  23293. declare module "babylonjs/Meshes/geometry" {
  23294. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23295. import { Scene } from "babylonjs/scene";
  23296. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23297. import { Engine } from "babylonjs/Engines/engine";
  23298. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23299. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23300. import { Mesh } from "babylonjs/Meshes/mesh";
  23301. import { Effect } from "babylonjs/Materials/effect";
  23302. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23303. /**
  23304. * Class used to store geometry data (vertex buffers + index buffer)
  23305. */
  23306. export class Geometry implements IGetSetVerticesData {
  23307. /**
  23308. * Gets or sets the ID of the geometry
  23309. */
  23310. id: string;
  23311. /**
  23312. * Gets or sets the unique ID of the geometry
  23313. */
  23314. uniqueId: number;
  23315. /**
  23316. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23317. */
  23318. delayLoadState: number;
  23319. /**
  23320. * Gets the file containing the data to load when running in delay load state
  23321. */
  23322. delayLoadingFile: Nullable<string>;
  23323. /**
  23324. * Callback called when the geometry is updated
  23325. */
  23326. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23327. private _scene;
  23328. private _engine;
  23329. private _meshes;
  23330. private _totalVertices;
  23331. /** @hidden */
  23332. _indices: IndicesArray;
  23333. /** @hidden */
  23334. _vertexBuffers: {
  23335. [key: string]: VertexBuffer;
  23336. };
  23337. private _isDisposed;
  23338. private _extend;
  23339. private _boundingBias;
  23340. /** @hidden */
  23341. _delayInfo: Array<string>;
  23342. private _indexBuffer;
  23343. private _indexBufferIsUpdatable;
  23344. /** @hidden */
  23345. _boundingInfo: Nullable<BoundingInfo>;
  23346. /** @hidden */
  23347. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23348. /** @hidden */
  23349. _softwareSkinningFrameId: number;
  23350. private _vertexArrayObjects;
  23351. private _updatable;
  23352. /** @hidden */
  23353. _positions: Nullable<Vector3[]>;
  23354. /**
  23355. * 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
  23356. */
  23357. /**
  23358. * 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
  23359. */
  23360. boundingBias: Vector2;
  23361. /**
  23362. * Static function used to attach a new empty geometry to a mesh
  23363. * @param mesh defines the mesh to attach the geometry to
  23364. * @returns the new Geometry
  23365. */
  23366. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23367. /**
  23368. * Creates a new geometry
  23369. * @param id defines the unique ID
  23370. * @param scene defines the hosting scene
  23371. * @param vertexData defines the VertexData used to get geometry data
  23372. * @param updatable defines if geometry must be updatable (false by default)
  23373. * @param mesh defines the mesh that will be associated with the geometry
  23374. */
  23375. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23376. /**
  23377. * Gets the current extend of the geometry
  23378. */
  23379. readonly extend: {
  23380. minimum: Vector3;
  23381. maximum: Vector3;
  23382. };
  23383. /**
  23384. * Gets the hosting scene
  23385. * @returns the hosting Scene
  23386. */
  23387. getScene(): Scene;
  23388. /**
  23389. * Gets the hosting engine
  23390. * @returns the hosting Engine
  23391. */
  23392. getEngine(): Engine;
  23393. /**
  23394. * Defines if the geometry is ready to use
  23395. * @returns true if the geometry is ready to be used
  23396. */
  23397. isReady(): boolean;
  23398. /**
  23399. * Gets a value indicating that the geometry should not be serialized
  23400. */
  23401. readonly doNotSerialize: boolean;
  23402. /** @hidden */
  23403. _rebuild(): void;
  23404. /**
  23405. * Affects all geometry data in one call
  23406. * @param vertexData defines the geometry data
  23407. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23408. */
  23409. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23410. /**
  23411. * Set specific vertex data
  23412. * @param kind defines the data kind (Position, normal, etc...)
  23413. * @param data defines the vertex data to use
  23414. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23415. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23416. */
  23417. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23418. /**
  23419. * Removes a specific vertex data
  23420. * @param kind defines the data kind (Position, normal, etc...)
  23421. */
  23422. removeVerticesData(kind: string): void;
  23423. /**
  23424. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23425. * @param buffer defines the vertex buffer to use
  23426. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23427. */
  23428. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23429. /**
  23430. * Update a specific vertex buffer
  23431. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23432. * It will do nothing if the buffer is not updatable
  23433. * @param kind defines the data kind (Position, normal, etc...)
  23434. * @param data defines the data to use
  23435. * @param offset defines the offset in the target buffer where to store the data
  23436. * @param useBytes set to true if the offset is in bytes
  23437. */
  23438. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23439. /**
  23440. * Update a specific vertex buffer
  23441. * This function will create a new buffer if the current one is not updatable
  23442. * @param kind defines the data kind (Position, normal, etc...)
  23443. * @param data defines the data to use
  23444. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23445. */
  23446. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23447. private _updateBoundingInfo;
  23448. /** @hidden */
  23449. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23450. /**
  23451. * Gets total number of vertices
  23452. * @returns the total number of vertices
  23453. */
  23454. getTotalVertices(): number;
  23455. /**
  23456. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23457. * @param kind defines the data kind (Position, normal, etc...)
  23458. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23460. * @returns a float array containing vertex data
  23461. */
  23462. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23463. /**
  23464. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23465. * @param kind defines the data kind (Position, normal, etc...)
  23466. * @returns true if the vertex buffer with the specified kind is updatable
  23467. */
  23468. isVertexBufferUpdatable(kind: string): boolean;
  23469. /**
  23470. * Gets a specific vertex buffer
  23471. * @param kind defines the data kind (Position, normal, etc...)
  23472. * @returns a VertexBuffer
  23473. */
  23474. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23475. /**
  23476. * Returns all vertex buffers
  23477. * @return an object holding all vertex buffers indexed by kind
  23478. */
  23479. getVertexBuffers(): Nullable<{
  23480. [key: string]: VertexBuffer;
  23481. }>;
  23482. /**
  23483. * Gets a boolean indicating if specific vertex buffer is present
  23484. * @param kind defines the data kind (Position, normal, etc...)
  23485. * @returns true if data is present
  23486. */
  23487. isVerticesDataPresent(kind: string): boolean;
  23488. /**
  23489. * Gets a list of all attached data kinds (Position, normal, etc...)
  23490. * @returns a list of string containing all kinds
  23491. */
  23492. getVerticesDataKinds(): string[];
  23493. /**
  23494. * Update index buffer
  23495. * @param indices defines the indices to store in the index buffer
  23496. * @param offset defines the offset in the target buffer where to store the data
  23497. */
  23498. updateIndices(indices: IndicesArray, offset?: number): void;
  23499. /**
  23500. * Creates a new index buffer
  23501. * @param indices defines the indices to store in the index buffer
  23502. * @param totalVertices defines the total number of vertices (could be null)
  23503. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23504. */
  23505. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23506. /**
  23507. * Return the total number of indices
  23508. * @returns the total number of indices
  23509. */
  23510. getTotalIndices(): number;
  23511. /**
  23512. * Gets the index buffer array
  23513. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23514. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23515. * @returns the index buffer array
  23516. */
  23517. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23518. /**
  23519. * Gets the index buffer
  23520. * @return the index buffer
  23521. */
  23522. getIndexBuffer(): Nullable<WebGLBuffer>;
  23523. /** @hidden */
  23524. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23525. /**
  23526. * Release the associated resources for a specific mesh
  23527. * @param mesh defines the source mesh
  23528. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23529. */
  23530. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23531. /**
  23532. * Apply current geometry to a given mesh
  23533. * @param mesh defines the mesh to apply geometry to
  23534. */
  23535. applyToMesh(mesh: Mesh): void;
  23536. private _updateExtend;
  23537. private _applyToMesh;
  23538. private notifyUpdate;
  23539. /**
  23540. * Load the geometry if it was flagged as delay loaded
  23541. * @param scene defines the hosting scene
  23542. * @param onLoaded defines a callback called when the geometry is loaded
  23543. */
  23544. load(scene: Scene, onLoaded?: () => void): void;
  23545. private _queueLoad;
  23546. /**
  23547. * Invert the geometry to move from a right handed system to a left handed one.
  23548. */
  23549. toLeftHanded(): void;
  23550. /** @hidden */
  23551. _resetPointsArrayCache(): void;
  23552. /** @hidden */
  23553. _generatePointsArray(): boolean;
  23554. /**
  23555. * Gets a value indicating if the geometry is disposed
  23556. * @returns true if the geometry was disposed
  23557. */
  23558. isDisposed(): boolean;
  23559. private _disposeVertexArrayObjects;
  23560. /**
  23561. * Free all associated resources
  23562. */
  23563. dispose(): void;
  23564. /**
  23565. * Clone the current geometry into a new geometry
  23566. * @param id defines the unique ID of the new geometry
  23567. * @returns a new geometry object
  23568. */
  23569. copy(id: string): Geometry;
  23570. /**
  23571. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23572. * @return a JSON representation of the current geometry data (without the vertices data)
  23573. */
  23574. serialize(): any;
  23575. private toNumberArray;
  23576. /**
  23577. * Serialize all vertices data into a JSON oject
  23578. * @returns a JSON representation of the current geometry data
  23579. */
  23580. serializeVerticeData(): any;
  23581. /**
  23582. * Extracts a clone of a mesh geometry
  23583. * @param mesh defines the source mesh
  23584. * @param id defines the unique ID of the new geometry object
  23585. * @returns the new geometry object
  23586. */
  23587. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23588. /**
  23589. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23590. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23591. * Be aware Math.random() could cause collisions, but:
  23592. * "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"
  23593. * @returns a string containing a new GUID
  23594. */
  23595. static RandomId(): string;
  23596. /** @hidden */
  23597. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23598. private static _CleanMatricesWeights;
  23599. /**
  23600. * Create a new geometry from persisted data (Using .babylon file format)
  23601. * @param parsedVertexData defines the persisted data
  23602. * @param scene defines the hosting scene
  23603. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23604. * @returns the new geometry object
  23605. */
  23606. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23607. }
  23608. /**
  23609. * Abstract class used to provide common services for all typed geometries
  23610. * @hidden
  23611. */
  23612. export class _PrimitiveGeometry extends Geometry {
  23613. private _canBeRegenerated;
  23614. private _beingRegenerated;
  23615. /**
  23616. * Creates a new typed geometry
  23617. * @param id defines the unique ID of the geometry
  23618. * @param scene defines the hosting scene
  23619. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23620. * @param mesh defines the hosting mesh (can be null)
  23621. */
  23622. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23623. /**
  23624. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  23625. * @returns true if the geometry can be regenerated
  23626. */
  23627. canBeRegenerated(): boolean;
  23628. /**
  23629. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  23630. */
  23631. regenerate(): void;
  23632. /**
  23633. * Clone the geometry
  23634. * @param id defines the unique ID of the new geometry
  23635. * @returns the new geometry
  23636. */
  23637. asNewGeometry(id: string): Geometry;
  23638. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23639. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  23640. /** @hidden */
  23641. _regenerateVertexData(): VertexData;
  23642. copy(id: string): Geometry;
  23643. serialize(): any;
  23644. }
  23645. /**
  23646. * Creates a ribbon geometry
  23647. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  23648. */
  23649. export class RibbonGeometry extends _PrimitiveGeometry {
  23650. /**
  23651. * Defines the array of paths to use
  23652. */
  23653. pathArray: Vector3[][];
  23654. /**
  23655. * Defines if the last and first points of each path in your pathArray must be joined
  23656. */
  23657. closeArray: boolean;
  23658. /**
  23659. * Defines if the last and first points of each path in your pathArray must be joined
  23660. */
  23661. closePath: boolean;
  23662. /**
  23663. * Defines the offset between points
  23664. */
  23665. offset: number;
  23666. /**
  23667. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23668. */
  23669. side: number;
  23670. /**
  23671. * Creates a ribbon geometry
  23672. * @param id defines the unique ID of the geometry
  23673. * @param scene defines the hosting scene
  23674. * @param pathArray defines the array of paths to use
  23675. * @param closeArray defines if the last path and the first path must be joined
  23676. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  23677. * @param offset defines the offset between points
  23678. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23679. * @param mesh defines the hosting mesh (can be null)
  23680. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23681. */
  23682. constructor(id: string, scene: Scene,
  23683. /**
  23684. * Defines the array of paths to use
  23685. */
  23686. pathArray: Vector3[][],
  23687. /**
  23688. * Defines if the last and first points of each path in your pathArray must be joined
  23689. */
  23690. closeArray: boolean,
  23691. /**
  23692. * Defines if the last and first points of each path in your pathArray must be joined
  23693. */
  23694. closePath: boolean,
  23695. /**
  23696. * Defines the offset between points
  23697. */
  23698. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  23699. /**
  23700. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23701. */
  23702. side?: number);
  23703. /** @hidden */
  23704. _regenerateVertexData(): VertexData;
  23705. copy(id: string): Geometry;
  23706. }
  23707. /**
  23708. * Creates a box geometry
  23709. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  23710. */
  23711. export class BoxGeometry extends _PrimitiveGeometry {
  23712. /**
  23713. * Defines the zise of the box (width, height and depth are the same)
  23714. */
  23715. size: number;
  23716. /**
  23717. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23718. */
  23719. side: number;
  23720. /**
  23721. * Creates a box geometry
  23722. * @param id defines the unique ID of the geometry
  23723. * @param scene defines the hosting scene
  23724. * @param size defines the zise of the box (width, height and depth are the same)
  23725. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23726. * @param mesh defines the hosting mesh (can be null)
  23727. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23728. */
  23729. constructor(id: string, scene: Scene,
  23730. /**
  23731. * Defines the zise of the box (width, height and depth are the same)
  23732. */
  23733. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23734. /**
  23735. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23736. */
  23737. side?: number);
  23738. /** @hidden */
  23739. _regenerateVertexData(): VertexData;
  23740. copy(id: string): Geometry;
  23741. serialize(): any;
  23742. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  23743. }
  23744. /**
  23745. * Creates a sphere geometry
  23746. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  23747. */
  23748. export class SphereGeometry extends _PrimitiveGeometry {
  23749. /**
  23750. * Defines the number of segments to use to create the sphere
  23751. */
  23752. segments: number;
  23753. /**
  23754. * Defines the diameter of the sphere
  23755. */
  23756. diameter: number;
  23757. /**
  23758. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23759. */
  23760. side: number;
  23761. /**
  23762. * Create a new sphere geometry
  23763. * @param id defines the unique ID of the geometry
  23764. * @param scene defines the hosting scene
  23765. * @param segments defines the number of segments to use to create the sphere
  23766. * @param diameter defines the diameter of the sphere
  23767. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23768. * @param mesh defines the hosting mesh (can be null)
  23769. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23770. */
  23771. constructor(id: string, scene: Scene,
  23772. /**
  23773. * Defines the number of segments to use to create the sphere
  23774. */
  23775. segments: number,
  23776. /**
  23777. * Defines the diameter of the sphere
  23778. */
  23779. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23780. /**
  23781. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23782. */
  23783. side?: number);
  23784. /** @hidden */
  23785. _regenerateVertexData(): VertexData;
  23786. copy(id: string): Geometry;
  23787. serialize(): any;
  23788. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  23789. }
  23790. /**
  23791. * Creates a disc geometry
  23792. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23793. */
  23794. export class DiscGeometry extends _PrimitiveGeometry {
  23795. /**
  23796. * Defines the radius of the disc
  23797. */
  23798. radius: number;
  23799. /**
  23800. * Defines the tesselation factor to apply to the disc
  23801. */
  23802. tessellation: number;
  23803. /**
  23804. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23805. */
  23806. side: number;
  23807. /**
  23808. * Creates a new disc geometry
  23809. * @param id defines the unique ID of the geometry
  23810. * @param scene defines the hosting scene
  23811. * @param radius defines the radius of the disc
  23812. * @param tessellation defines the tesselation factor to apply to the disc
  23813. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23814. * @param mesh defines the hosting mesh (can be null)
  23815. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23816. */
  23817. constructor(id: string, scene: Scene,
  23818. /**
  23819. * Defines the radius of the disc
  23820. */
  23821. radius: number,
  23822. /**
  23823. * Defines the tesselation factor to apply to the disc
  23824. */
  23825. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23826. /**
  23827. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23828. */
  23829. side?: number);
  23830. /** @hidden */
  23831. _regenerateVertexData(): VertexData;
  23832. copy(id: string): Geometry;
  23833. }
  23834. /**
  23835. * Creates a new cylinder geometry
  23836. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23837. */
  23838. export class CylinderGeometry extends _PrimitiveGeometry {
  23839. /**
  23840. * Defines the height of the cylinder
  23841. */
  23842. height: number;
  23843. /**
  23844. * Defines the diameter of the cylinder's top cap
  23845. */
  23846. diameterTop: number;
  23847. /**
  23848. * Defines the diameter of the cylinder's bottom cap
  23849. */
  23850. diameterBottom: number;
  23851. /**
  23852. * Defines the tessellation factor to apply to the cylinder
  23853. */
  23854. tessellation: number;
  23855. /**
  23856. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  23857. */
  23858. subdivisions: number;
  23859. /**
  23860. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23861. */
  23862. side: number;
  23863. /**
  23864. * Creates a new cylinder geometry
  23865. * @param id defines the unique ID of the geometry
  23866. * @param scene defines the hosting scene
  23867. * @param height defines the height of the cylinder
  23868. * @param diameterTop defines the diameter of the cylinder's top cap
  23869. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  23870. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  23871. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  23872. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23873. * @param mesh defines the hosting mesh (can be null)
  23874. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23875. */
  23876. constructor(id: string, scene: Scene,
  23877. /**
  23878. * Defines the height of the cylinder
  23879. */
  23880. height: number,
  23881. /**
  23882. * Defines the diameter of the cylinder's top cap
  23883. */
  23884. diameterTop: number,
  23885. /**
  23886. * Defines the diameter of the cylinder's bottom cap
  23887. */
  23888. diameterBottom: number,
  23889. /**
  23890. * Defines the tessellation factor to apply to the cylinder
  23891. */
  23892. tessellation: number,
  23893. /**
  23894. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  23895. */
  23896. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23897. /**
  23898. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23899. */
  23900. side?: number);
  23901. /** @hidden */
  23902. _regenerateVertexData(): VertexData;
  23903. copy(id: string): Geometry;
  23904. serialize(): any;
  23905. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  23906. }
  23907. /**
  23908. * Creates a new torus geometry
  23909. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  23910. */
  23911. export class TorusGeometry extends _PrimitiveGeometry {
  23912. /**
  23913. * Defines the diameter of the torus
  23914. */
  23915. diameter: number;
  23916. /**
  23917. * Defines the thickness of the torus (ie. internal diameter)
  23918. */
  23919. thickness: number;
  23920. /**
  23921. * Defines the tesselation factor to apply to the torus
  23922. */
  23923. tessellation: number;
  23924. /**
  23925. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23926. */
  23927. side: number;
  23928. /**
  23929. * Creates a new torus geometry
  23930. * @param id defines the unique ID of the geometry
  23931. * @param scene defines the hosting scene
  23932. * @param diameter defines the diameter of the torus
  23933. * @param thickness defines the thickness of the torus (ie. internal diameter)
  23934. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  23935. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23936. * @param mesh defines the hosting mesh (can be null)
  23937. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23938. */
  23939. constructor(id: string, scene: Scene,
  23940. /**
  23941. * Defines the diameter of the torus
  23942. */
  23943. diameter: number,
  23944. /**
  23945. * Defines the thickness of the torus (ie. internal diameter)
  23946. */
  23947. thickness: number,
  23948. /**
  23949. * Defines the tesselation factor to apply to the torus
  23950. */
  23951. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23952. /**
  23953. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23954. */
  23955. side?: number);
  23956. /** @hidden */
  23957. _regenerateVertexData(): VertexData;
  23958. copy(id: string): Geometry;
  23959. serialize(): any;
  23960. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  23961. }
  23962. /**
  23963. * Creates a new ground geometry
  23964. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  23965. */
  23966. export class GroundGeometry extends _PrimitiveGeometry {
  23967. /**
  23968. * Defines the width of the ground
  23969. */
  23970. width: number;
  23971. /**
  23972. * Defines the height of the ground
  23973. */
  23974. height: number;
  23975. /**
  23976. * Defines the subdivisions to apply to the ground
  23977. */
  23978. subdivisions: number;
  23979. /**
  23980. * Creates a new ground geometry
  23981. * @param id defines the unique ID of the geometry
  23982. * @param scene defines the hosting scene
  23983. * @param width defines the width of the ground
  23984. * @param height defines the height of the ground
  23985. * @param subdivisions defines the subdivisions to apply to the ground
  23986. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23987. * @param mesh defines the hosting mesh (can be null)
  23988. */
  23989. constructor(id: string, scene: Scene,
  23990. /**
  23991. * Defines the width of the ground
  23992. */
  23993. width: number,
  23994. /**
  23995. * Defines the height of the ground
  23996. */
  23997. height: number,
  23998. /**
  23999. * Defines the subdivisions to apply to the ground
  24000. */
  24001. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24002. /** @hidden */
  24003. _regenerateVertexData(): VertexData;
  24004. copy(id: string): Geometry;
  24005. serialize(): any;
  24006. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  24007. }
  24008. /**
  24009. * Creates a tiled ground geometry
  24010. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  24011. */
  24012. export class TiledGroundGeometry extends _PrimitiveGeometry {
  24013. /**
  24014. * Defines the minimum value on X axis
  24015. */
  24016. xmin: number;
  24017. /**
  24018. * Defines the minimum value on Z axis
  24019. */
  24020. zmin: number;
  24021. /**
  24022. * Defines the maximum value on X axis
  24023. */
  24024. xmax: number;
  24025. /**
  24026. * Defines the maximum value on Z axis
  24027. */
  24028. zmax: number;
  24029. /**
  24030. * Defines the subdivisions to apply to the ground
  24031. */
  24032. subdivisions: {
  24033. w: number;
  24034. h: number;
  24035. };
  24036. /**
  24037. * Defines the precision to use when computing the tiles
  24038. */
  24039. precision: {
  24040. w: number;
  24041. h: number;
  24042. };
  24043. /**
  24044. * Creates a tiled ground geometry
  24045. * @param id defines the unique ID of the geometry
  24046. * @param scene defines the hosting scene
  24047. * @param xmin defines the minimum value on X axis
  24048. * @param zmin defines the minimum value on Z axis
  24049. * @param xmax defines the maximum value on X axis
  24050. * @param zmax defines the maximum value on Z axis
  24051. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  24052. * @param precision defines the precision to use when computing the tiles
  24053. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24054. * @param mesh defines the hosting mesh (can be null)
  24055. */
  24056. constructor(id: string, scene: Scene,
  24057. /**
  24058. * Defines the minimum value on X axis
  24059. */
  24060. xmin: number,
  24061. /**
  24062. * Defines the minimum value on Z axis
  24063. */
  24064. zmin: number,
  24065. /**
  24066. * Defines the maximum value on X axis
  24067. */
  24068. xmax: number,
  24069. /**
  24070. * Defines the maximum value on Z axis
  24071. */
  24072. zmax: number,
  24073. /**
  24074. * Defines the subdivisions to apply to the ground
  24075. */
  24076. subdivisions: {
  24077. w: number;
  24078. h: number;
  24079. },
  24080. /**
  24081. * Defines the precision to use when computing the tiles
  24082. */
  24083. precision: {
  24084. w: number;
  24085. h: number;
  24086. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24087. /** @hidden */
  24088. _regenerateVertexData(): VertexData;
  24089. copy(id: string): Geometry;
  24090. }
  24091. /**
  24092. * Creates a plane geometry
  24093. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  24094. */
  24095. export class PlaneGeometry extends _PrimitiveGeometry {
  24096. /**
  24097. * Defines the size of the plane (width === height)
  24098. */
  24099. size: number;
  24100. /**
  24101. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  24102. */
  24103. side: number;
  24104. /**
  24105. * Creates a plane geometry
  24106. * @param id defines the unique ID of the geometry
  24107. * @param scene defines the hosting scene
  24108. * @param size defines the size of the plane (width === height)
  24109. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24110. * @param mesh defines the hosting mesh (can be null)
  24111. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  24112. */
  24113. constructor(id: string, scene: Scene,
  24114. /**
  24115. * Defines the size of the plane (width === height)
  24116. */
  24117. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24118. /**
  24119. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  24120. */
  24121. side?: number);
  24122. /** @hidden */
  24123. _regenerateVertexData(): VertexData;
  24124. copy(id: string): Geometry;
  24125. serialize(): any;
  24126. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  24127. }
  24128. /**
  24129. * Creates a torus knot geometry
  24130. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  24131. */
  24132. export class TorusKnotGeometry extends _PrimitiveGeometry {
  24133. /**
  24134. * Defines the radius of the torus knot
  24135. */
  24136. radius: number;
  24137. /**
  24138. * Defines the thickness of the torus knot tube
  24139. */
  24140. tube: number;
  24141. /**
  24142. * Defines the number of radial segments
  24143. */
  24144. radialSegments: number;
  24145. /**
  24146. * Defines the number of tubular segments
  24147. */
  24148. tubularSegments: number;
  24149. /**
  24150. * Defines the first number of windings
  24151. */
  24152. p: number;
  24153. /**
  24154. * Defines the second number of windings
  24155. */
  24156. q: number;
  24157. /**
  24158. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  24159. */
  24160. side: number;
  24161. /**
  24162. * Creates a torus knot geometry
  24163. * @param id defines the unique ID of the geometry
  24164. * @param scene defines the hosting scene
  24165. * @param radius defines the radius of the torus knot
  24166. * @param tube defines the thickness of the torus knot tube
  24167. * @param radialSegments defines the number of radial segments
  24168. * @param tubularSegments defines the number of tubular segments
  24169. * @param p defines the first number of windings
  24170. * @param q defines the second number of windings
  24171. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24172. * @param mesh defines the hosting mesh (can be null)
  24173. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  24174. */
  24175. constructor(id: string, scene: Scene,
  24176. /**
  24177. * Defines the radius of the torus knot
  24178. */
  24179. radius: number,
  24180. /**
  24181. * Defines the thickness of the torus knot tube
  24182. */
  24183. tube: number,
  24184. /**
  24185. * Defines the number of radial segments
  24186. */
  24187. radialSegments: number,
  24188. /**
  24189. * Defines the number of tubular segments
  24190. */
  24191. tubularSegments: number,
  24192. /**
  24193. * Defines the first number of windings
  24194. */
  24195. p: number,
  24196. /**
  24197. * Defines the second number of windings
  24198. */
  24199. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24200. /**
  24201. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  24202. */
  24203. side?: number);
  24204. /** @hidden */
  24205. _regenerateVertexData(): VertexData;
  24206. copy(id: string): Geometry;
  24207. serialize(): any;
  24208. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  24209. }
  24210. }
  24211. declare module "babylonjs/Meshes/mesh.vertexData" {
  24212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24213. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  24214. import { Geometry } from "babylonjs/Meshes/geometry";
  24215. import { Mesh } from "babylonjs/Meshes/mesh";
  24216. /**
  24217. * Define an interface for all classes that will get and set the data on vertices
  24218. */
  24219. export interface IGetSetVerticesData {
  24220. /**
  24221. * Gets a boolean indicating if specific vertex data is present
  24222. * @param kind defines the vertex data kind to use
  24223. * @returns true is data kind is present
  24224. */
  24225. isVerticesDataPresent(kind: string): boolean;
  24226. /**
  24227. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24228. * @param kind defines the data kind (Position, normal, etc...)
  24229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24231. * @returns a float array containing vertex data
  24232. */
  24233. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24234. /**
  24235. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24236. * @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.
  24237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24238. * @returns the indices array or an empty array if the mesh has no geometry
  24239. */
  24240. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24241. /**
  24242. * Set specific vertex data
  24243. * @param kind defines the data kind (Position, normal, etc...)
  24244. * @param data defines the vertex data to use
  24245. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24246. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24247. */
  24248. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24249. /**
  24250. * Update a specific associated vertex buffer
  24251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24252. * - VertexBuffer.PositionKind
  24253. * - VertexBuffer.UVKind
  24254. * - VertexBuffer.UV2Kind
  24255. * - VertexBuffer.UV3Kind
  24256. * - VertexBuffer.UV4Kind
  24257. * - VertexBuffer.UV5Kind
  24258. * - VertexBuffer.UV6Kind
  24259. * - VertexBuffer.ColorKind
  24260. * - VertexBuffer.MatricesIndicesKind
  24261. * - VertexBuffer.MatricesIndicesExtraKind
  24262. * - VertexBuffer.MatricesWeightsKind
  24263. * - VertexBuffer.MatricesWeightsExtraKind
  24264. * @param data defines the data source
  24265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24266. * @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)
  24267. */
  24268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24269. /**
  24270. * Creates a new index buffer
  24271. * @param indices defines the indices to store in the index buffer
  24272. * @param totalVertices defines the total number of vertices (could be null)
  24273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24274. */
  24275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24276. }
  24277. /**
  24278. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24279. */
  24280. export class VertexData {
  24281. /**
  24282. * Mesh side orientation : usually the external or front surface
  24283. */
  24284. static readonly FRONTSIDE: number;
  24285. /**
  24286. * Mesh side orientation : usually the internal or back surface
  24287. */
  24288. static readonly BACKSIDE: number;
  24289. /**
  24290. * Mesh side orientation : both internal and external or front and back surfaces
  24291. */
  24292. static readonly DOUBLESIDE: number;
  24293. /**
  24294. * Mesh side orientation : by default, `FRONTSIDE`
  24295. */
  24296. static readonly DEFAULTSIDE: number;
  24297. /**
  24298. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24299. */
  24300. positions: Nullable<FloatArray>;
  24301. /**
  24302. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24303. */
  24304. normals: Nullable<FloatArray>;
  24305. /**
  24306. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24307. */
  24308. tangents: Nullable<FloatArray>;
  24309. /**
  24310. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24311. */
  24312. uvs: Nullable<FloatArray>;
  24313. /**
  24314. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24315. */
  24316. uvs2: Nullable<FloatArray>;
  24317. /**
  24318. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24319. */
  24320. uvs3: Nullable<FloatArray>;
  24321. /**
  24322. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24323. */
  24324. uvs4: Nullable<FloatArray>;
  24325. /**
  24326. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24327. */
  24328. uvs5: Nullable<FloatArray>;
  24329. /**
  24330. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24331. */
  24332. uvs6: Nullable<FloatArray>;
  24333. /**
  24334. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  24335. */
  24336. colors: Nullable<FloatArray>;
  24337. /**
  24338. * 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).
  24339. */
  24340. matricesIndices: Nullable<FloatArray>;
  24341. /**
  24342. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  24343. */
  24344. matricesWeights: Nullable<FloatArray>;
  24345. /**
  24346. * An array extending the number of possible indices
  24347. */
  24348. matricesIndicesExtra: Nullable<FloatArray>;
  24349. /**
  24350. * An array extending the number of possible weights when the number of indices is extended
  24351. */
  24352. matricesWeightsExtra: Nullable<FloatArray>;
  24353. /**
  24354. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  24355. */
  24356. indices: Nullable<IndicesArray>;
  24357. /**
  24358. * Uses the passed data array to set the set the values for the specified kind of data
  24359. * @param data a linear array of floating numbers
  24360. * @param kind the type of data that is being set, eg positions, colors etc
  24361. */
  24362. set(data: FloatArray, kind: string): void;
  24363. /**
  24364. * Associates the vertexData to the passed Mesh.
  24365. * Sets it as updatable or not (default `false`)
  24366. * @param mesh the mesh the vertexData is applied to
  24367. * @param updatable when used and having the value true allows new data to update the vertexData
  24368. * @returns the VertexData
  24369. */
  24370. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24371. /**
  24372. * Associates the vertexData to the passed Geometry.
  24373. * Sets it as updatable or not (default `false`)
  24374. * @param geometry the geometry the vertexData is applied to
  24375. * @param updatable when used and having the value true allows new data to update the vertexData
  24376. * @returns VertexData
  24377. */
  24378. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24379. /**
  24380. * Updates the associated mesh
  24381. * @param mesh the mesh to be updated
  24382. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24383. * @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
  24384. * @returns VertexData
  24385. */
  24386. updateMesh(mesh: Mesh): VertexData;
  24387. /**
  24388. * Updates the associated geometry
  24389. * @param geometry the geometry to be updated
  24390. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24391. * @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
  24392. * @returns VertexData.
  24393. */
  24394. updateGeometry(geometry: Geometry): VertexData;
  24395. private _applyTo;
  24396. private _update;
  24397. /**
  24398. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24399. * @param matrix the transforming matrix
  24400. * @returns the VertexData
  24401. */
  24402. transform(matrix: Matrix): VertexData;
  24403. /**
  24404. * Merges the passed VertexData into the current one
  24405. * @param other the VertexData to be merged into the current one
  24406. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24407. * @returns the modified VertexData
  24408. */
  24409. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24410. private _mergeElement;
  24411. private _validate;
  24412. /**
  24413. * Serializes the VertexData
  24414. * @returns a serialized object
  24415. */
  24416. serialize(): any;
  24417. /**
  24418. * Extracts the vertexData from a mesh
  24419. * @param mesh the mesh from which to extract the VertexData
  24420. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24422. * @returns the object VertexData associated to the passed mesh
  24423. */
  24424. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24425. /**
  24426. * Extracts the vertexData from the geometry
  24427. * @param geometry the geometry from which to extract the VertexData
  24428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24430. * @returns the object VertexData associated to the passed mesh
  24431. */
  24432. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24433. private static _ExtractFrom;
  24434. /**
  24435. * Creates the VertexData for a Ribbon
  24436. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24437. * * pathArray array of paths, each of which an array of successive Vector3
  24438. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24439. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24440. * * 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
  24441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24442. * * 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)
  24443. * * 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)
  24444. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24445. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24446. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24447. * @returns the VertexData of the ribbon
  24448. */
  24449. static CreateRibbon(options: {
  24450. pathArray: Vector3[][];
  24451. closeArray?: boolean;
  24452. closePath?: boolean;
  24453. offset?: number;
  24454. sideOrientation?: number;
  24455. frontUVs?: Vector4;
  24456. backUVs?: Vector4;
  24457. invertUV?: boolean;
  24458. uvs?: Vector2[];
  24459. colors?: Color4[];
  24460. }): VertexData;
  24461. /**
  24462. * Creates the VertexData for a box
  24463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24464. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24465. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24466. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24467. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24468. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24469. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24471. * * 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)
  24472. * * 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)
  24473. * @returns the VertexData of the box
  24474. */
  24475. static CreateBox(options: {
  24476. size?: number;
  24477. width?: number;
  24478. height?: number;
  24479. depth?: number;
  24480. faceUV?: Vector4[];
  24481. faceColors?: Color4[];
  24482. sideOrientation?: number;
  24483. frontUVs?: Vector4;
  24484. backUVs?: Vector4;
  24485. }): VertexData;
  24486. /**
  24487. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24489. * * segments sets the number of horizontal strips optional, default 32
  24490. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24491. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24492. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24493. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24494. * * 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
  24495. * * 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
  24496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24497. * * 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)
  24498. * * 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)
  24499. * @returns the VertexData of the ellipsoid
  24500. */
  24501. static CreateSphere(options: {
  24502. segments?: number;
  24503. diameter?: number;
  24504. diameterX?: number;
  24505. diameterY?: number;
  24506. diameterZ?: number;
  24507. arc?: number;
  24508. slice?: number;
  24509. sideOrientation?: number;
  24510. frontUVs?: Vector4;
  24511. backUVs?: Vector4;
  24512. }): VertexData;
  24513. /**
  24514. * Creates the VertexData for a cylinder, cone or prism
  24515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24516. * * height sets the height (y direction) of the cylinder, optional, default 2
  24517. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24518. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24519. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24520. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24521. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24522. * * 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
  24523. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24525. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24526. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24528. * * 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)
  24529. * * 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)
  24530. * @returns the VertexData of the cylinder, cone or prism
  24531. */
  24532. static CreateCylinder(options: {
  24533. height?: number;
  24534. diameterTop?: number;
  24535. diameterBottom?: number;
  24536. diameter?: number;
  24537. tessellation?: number;
  24538. subdivisions?: number;
  24539. arc?: number;
  24540. faceColors?: Color4[];
  24541. faceUV?: Vector4[];
  24542. hasRings?: boolean;
  24543. enclose?: boolean;
  24544. sideOrientation?: number;
  24545. frontUVs?: Vector4;
  24546. backUVs?: Vector4;
  24547. }): VertexData;
  24548. /**
  24549. * Creates the VertexData for a torus
  24550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24551. * * diameter the diameter of the torus, optional default 1
  24552. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24553. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24555. * * 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)
  24556. * * 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)
  24557. * @returns the VertexData of the torus
  24558. */
  24559. static CreateTorus(options: {
  24560. diameter?: number;
  24561. thickness?: number;
  24562. tessellation?: number;
  24563. sideOrientation?: number;
  24564. frontUVs?: Vector4;
  24565. backUVs?: Vector4;
  24566. }): VertexData;
  24567. /**
  24568. * Creates the VertexData of the LineSystem
  24569. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24570. * - lines an array of lines, each line being an array of successive Vector3
  24571. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24572. * @returns the VertexData of the LineSystem
  24573. */
  24574. static CreateLineSystem(options: {
  24575. lines: Vector3[][];
  24576. colors?: Nullable<Color4[][]>;
  24577. }): VertexData;
  24578. /**
  24579. * Create the VertexData for a DashedLines
  24580. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24581. * - points an array successive Vector3
  24582. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24583. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24584. * - dashNb the intended total number of dashes, optional, default 200
  24585. * @returns the VertexData for the DashedLines
  24586. */
  24587. static CreateDashedLines(options: {
  24588. points: Vector3[];
  24589. dashSize?: number;
  24590. gapSize?: number;
  24591. dashNb?: number;
  24592. }): VertexData;
  24593. /**
  24594. * Creates the VertexData for a Ground
  24595. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24596. * - width the width (x direction) of the ground, optional, default 1
  24597. * - height the height (z direction) of the ground, optional, default 1
  24598. * - subdivisions the number of subdivisions per side, optional, default 1
  24599. * @returns the VertexData of the Ground
  24600. */
  24601. static CreateGround(options: {
  24602. width?: number;
  24603. height?: number;
  24604. subdivisions?: number;
  24605. subdivisionsX?: number;
  24606. subdivisionsY?: number;
  24607. }): VertexData;
  24608. /**
  24609. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24610. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24611. * * xmin the ground minimum X coordinate, optional, default -1
  24612. * * zmin the ground minimum Z coordinate, optional, default -1
  24613. * * xmax the ground maximum X coordinate, optional, default 1
  24614. * * zmax the ground maximum Z coordinate, optional, default 1
  24615. * * 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}
  24616. * * 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}
  24617. * @returns the VertexData of the TiledGround
  24618. */
  24619. static CreateTiledGround(options: {
  24620. xmin: number;
  24621. zmin: number;
  24622. xmax: number;
  24623. zmax: number;
  24624. subdivisions?: {
  24625. w: number;
  24626. h: number;
  24627. };
  24628. precision?: {
  24629. w: number;
  24630. h: number;
  24631. };
  24632. }): VertexData;
  24633. /**
  24634. * Creates the VertexData of the Ground designed from a heightmap
  24635. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24636. * * width the width (x direction) of the ground
  24637. * * height the height (z direction) of the ground
  24638. * * subdivisions the number of subdivisions per side
  24639. * * minHeight the minimum altitude on the ground, optional, default 0
  24640. * * maxHeight the maximum altitude on the ground, optional default 1
  24641. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24642. * * buffer the array holding the image color data
  24643. * * bufferWidth the width of image
  24644. * * bufferHeight the height of image
  24645. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24646. * @returns the VertexData of the Ground designed from a heightmap
  24647. */
  24648. static CreateGroundFromHeightMap(options: {
  24649. width: number;
  24650. height: number;
  24651. subdivisions: number;
  24652. minHeight: number;
  24653. maxHeight: number;
  24654. colorFilter: Color3;
  24655. buffer: Uint8Array;
  24656. bufferWidth: number;
  24657. bufferHeight: number;
  24658. alphaFilter: number;
  24659. }): VertexData;
  24660. /**
  24661. * Creates the VertexData for a Plane
  24662. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24663. * * size sets the width and height of the plane to the value of size, optional default 1
  24664. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24665. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24667. * * 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)
  24668. * * 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)
  24669. * @returns the VertexData of the box
  24670. */
  24671. static CreatePlane(options: {
  24672. size?: number;
  24673. width?: number;
  24674. height?: number;
  24675. sideOrientation?: number;
  24676. frontUVs?: Vector4;
  24677. backUVs?: Vector4;
  24678. }): VertexData;
  24679. /**
  24680. * Creates the VertexData of the Disc or regular Polygon
  24681. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24682. * * radius the radius of the disc, optional default 0.5
  24683. * * tessellation the number of polygon sides, optional, default 64
  24684. * * 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
  24685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24686. * * 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)
  24687. * * 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)
  24688. * @returns the VertexData of the box
  24689. */
  24690. static CreateDisc(options: {
  24691. radius?: number;
  24692. tessellation?: number;
  24693. arc?: number;
  24694. sideOrientation?: number;
  24695. frontUVs?: Vector4;
  24696. backUVs?: Vector4;
  24697. }): VertexData;
  24698. /**
  24699. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24700. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24701. * @param polygon a mesh built from polygonTriangulation.build()
  24702. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24703. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24704. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24705. * @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)
  24706. * @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)
  24707. * @returns the VertexData of the Polygon
  24708. */
  24709. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24710. /**
  24711. * Creates the VertexData of the IcoSphere
  24712. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24713. * * radius the radius of the IcoSphere, optional default 1
  24714. * * radiusX allows stretching in the x direction, optional, default radius
  24715. * * radiusY allows stretching in the y direction, optional, default radius
  24716. * * radiusZ allows stretching in the z direction, optional, default radius
  24717. * * flat when true creates a flat shaded mesh, optional, default true
  24718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24720. * * 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)
  24721. * * 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)
  24722. * @returns the VertexData of the IcoSphere
  24723. */
  24724. static CreateIcoSphere(options: {
  24725. radius?: number;
  24726. radiusX?: number;
  24727. radiusY?: number;
  24728. radiusZ?: number;
  24729. flat?: boolean;
  24730. subdivisions?: number;
  24731. sideOrientation?: number;
  24732. frontUVs?: Vector4;
  24733. backUVs?: Vector4;
  24734. }): VertexData;
  24735. /**
  24736. * Creates the VertexData for a Polyhedron
  24737. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24738. * * type provided types are:
  24739. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24740. * * 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)
  24741. * * size the size of the IcoSphere, optional default 1
  24742. * * sizeX allows stretching in the x direction, optional, default size
  24743. * * sizeY allows stretching in the y direction, optional, default size
  24744. * * sizeZ allows stretching in the z direction, optional, default size
  24745. * * 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
  24746. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24747. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24748. * * flat when true creates a flat shaded mesh, optional, default true
  24749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24751. * * 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)
  24752. * * 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)
  24753. * @returns the VertexData of the Polyhedron
  24754. */
  24755. static CreatePolyhedron(options: {
  24756. type?: number;
  24757. size?: number;
  24758. sizeX?: number;
  24759. sizeY?: number;
  24760. sizeZ?: number;
  24761. custom?: any;
  24762. faceUV?: Vector4[];
  24763. faceColors?: Color4[];
  24764. flat?: boolean;
  24765. sideOrientation?: number;
  24766. frontUVs?: Vector4;
  24767. backUVs?: Vector4;
  24768. }): VertexData;
  24769. /**
  24770. * Creates the VertexData for a TorusKnot
  24771. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24772. * * radius the radius of the torus knot, optional, default 2
  24773. * * tube the thickness of the tube, optional, default 0.5
  24774. * * radialSegments the number of sides on each tube segments, optional, default 32
  24775. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24776. * * p the number of windings around the z axis, optional, default 2
  24777. * * q the number of windings around the x axis, optional, default 3
  24778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24779. * * 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)
  24780. * * 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)
  24781. * @returns the VertexData of the Torus Knot
  24782. */
  24783. static CreateTorusKnot(options: {
  24784. radius?: number;
  24785. tube?: number;
  24786. radialSegments?: number;
  24787. tubularSegments?: number;
  24788. p?: number;
  24789. q?: number;
  24790. sideOrientation?: number;
  24791. frontUVs?: Vector4;
  24792. backUVs?: Vector4;
  24793. }): VertexData;
  24794. /**
  24795. * Compute normals for given positions and indices
  24796. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24797. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24798. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24799. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24800. * * facetNormals : optional array of facet normals (vector3)
  24801. * * facetPositions : optional array of facet positions (vector3)
  24802. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24803. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24804. * * bInfo : optional bounding info, required for facetPartitioning computation
  24805. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24806. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24807. * * useRightHandedSystem: optional boolean to for right handed system computation
  24808. * * depthSort : optional boolean to enable the facet depth sort computation
  24809. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24810. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24811. */
  24812. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24813. facetNormals?: any;
  24814. facetPositions?: any;
  24815. facetPartitioning?: any;
  24816. ratio?: number;
  24817. bInfo?: any;
  24818. bbSize?: Vector3;
  24819. subDiv?: any;
  24820. useRightHandedSystem?: boolean;
  24821. depthSort?: boolean;
  24822. distanceTo?: Vector3;
  24823. depthSortedFacets?: any;
  24824. }): void;
  24825. private static _ComputeSides;
  24826. /**
  24827. * Applies VertexData created from the imported parameters to the geometry
  24828. * @param parsedVertexData the parsed data from an imported file
  24829. * @param geometry the geometry to apply the VertexData to
  24830. */
  24831. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24832. }
  24833. }
  24834. declare module "babylonjs/Morph/morphTarget" {
  24835. import { IAnimatable } from "babylonjs/Misc/tools";
  24836. import { Observable } from "babylonjs/Misc/observable";
  24837. import { Nullable, FloatArray } from "babylonjs/types";
  24838. import { Scene } from "babylonjs/scene";
  24839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24840. import { Animation } from "babylonjs/Animations/animation";
  24841. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24842. /**
  24843. * Defines a target to use with MorphTargetManager
  24844. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24845. */
  24846. export class MorphTarget implements IAnimatable {
  24847. /** defines the name of the target */
  24848. name: string;
  24849. /**
  24850. * Gets or sets the list of animations
  24851. */
  24852. animations: Animation[];
  24853. private _scene;
  24854. private _positions;
  24855. private _normals;
  24856. private _tangents;
  24857. private _influence;
  24858. /**
  24859. * Observable raised when the influence changes
  24860. */
  24861. onInfluenceChanged: Observable<boolean>;
  24862. /** @hidden */
  24863. _onDataLayoutChanged: Observable<void>;
  24864. /**
  24865. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24866. */
  24867. influence: number;
  24868. /**
  24869. * Gets or sets the id of the morph Target
  24870. */
  24871. id: string;
  24872. private _animationPropertiesOverride;
  24873. /**
  24874. * Gets or sets the animation properties override
  24875. */
  24876. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24877. /**
  24878. * Creates a new MorphTarget
  24879. * @param name defines the name of the target
  24880. * @param influence defines the influence to use
  24881. */
  24882. constructor(
  24883. /** defines the name of the target */
  24884. name: string, influence?: number, scene?: Nullable<Scene>);
  24885. /**
  24886. * Gets a boolean defining if the target contains position data
  24887. */
  24888. readonly hasPositions: boolean;
  24889. /**
  24890. * Gets a boolean defining if the target contains normal data
  24891. */
  24892. readonly hasNormals: boolean;
  24893. /**
  24894. * Gets a boolean defining if the target contains tangent data
  24895. */
  24896. readonly hasTangents: boolean;
  24897. /**
  24898. * Affects position data to this target
  24899. * @param data defines the position data to use
  24900. */
  24901. setPositions(data: Nullable<FloatArray>): void;
  24902. /**
  24903. * Gets the position data stored in this target
  24904. * @returns a FloatArray containing the position data (or null if not present)
  24905. */
  24906. getPositions(): Nullable<FloatArray>;
  24907. /**
  24908. * Affects normal data to this target
  24909. * @param data defines the normal data to use
  24910. */
  24911. setNormals(data: Nullable<FloatArray>): void;
  24912. /**
  24913. * Gets the normal data stored in this target
  24914. * @returns a FloatArray containing the normal data (or null if not present)
  24915. */
  24916. getNormals(): Nullable<FloatArray>;
  24917. /**
  24918. * Affects tangent data to this target
  24919. * @param data defines the tangent data to use
  24920. */
  24921. setTangents(data: Nullable<FloatArray>): void;
  24922. /**
  24923. * Gets the tangent data stored in this target
  24924. * @returns a FloatArray containing the tangent data (or null if not present)
  24925. */
  24926. getTangents(): Nullable<FloatArray>;
  24927. /**
  24928. * Serializes the current target into a Serialization object
  24929. * @returns the serialized object
  24930. */
  24931. serialize(): any;
  24932. /**
  24933. * Returns the string "MorphTarget"
  24934. * @returns "MorphTarget"
  24935. */
  24936. getClassName(): string;
  24937. /**
  24938. * Creates a new target from serialized data
  24939. * @param serializationObject defines the serialized data to use
  24940. * @returns a new MorphTarget
  24941. */
  24942. static Parse(serializationObject: any): MorphTarget;
  24943. /**
  24944. * Creates a MorphTarget from mesh data
  24945. * @param mesh defines the source mesh
  24946. * @param name defines the name to use for the new target
  24947. * @param influence defines the influence to attach to the target
  24948. * @returns a new MorphTarget
  24949. */
  24950. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24951. }
  24952. }
  24953. declare module "babylonjs/Morph/morphTargetManager" {
  24954. import { Nullable } from "babylonjs/types";
  24955. import { Scene } from "babylonjs/scene";
  24956. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  24957. /**
  24958. * This class is used to deform meshes using morphing between different targets
  24959. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24960. */
  24961. export class MorphTargetManager {
  24962. private _targets;
  24963. private _targetInfluenceChangedObservers;
  24964. private _targetDataLayoutChangedObservers;
  24965. private _activeTargets;
  24966. private _scene;
  24967. private _influences;
  24968. private _supportsNormals;
  24969. private _supportsTangents;
  24970. private _vertexCount;
  24971. private _uniqueId;
  24972. private _tempInfluences;
  24973. /**
  24974. * Creates a new MorphTargetManager
  24975. * @param scene defines the current scene
  24976. */
  24977. constructor(scene?: Nullable<Scene>);
  24978. /**
  24979. * Gets the unique ID of this manager
  24980. */
  24981. readonly uniqueId: number;
  24982. /**
  24983. * Gets the number of vertices handled by this manager
  24984. */
  24985. readonly vertexCount: number;
  24986. /**
  24987. * Gets a boolean indicating if this manager supports morphing of normals
  24988. */
  24989. readonly supportsNormals: boolean;
  24990. /**
  24991. * Gets a boolean indicating if this manager supports morphing of tangents
  24992. */
  24993. readonly supportsTangents: boolean;
  24994. /**
  24995. * Gets the number of targets stored in this manager
  24996. */
  24997. readonly numTargets: number;
  24998. /**
  24999. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25000. */
  25001. readonly numInfluencers: number;
  25002. /**
  25003. * Gets the list of influences (one per target)
  25004. */
  25005. readonly influences: Float32Array;
  25006. /**
  25007. * Gets the active target at specified index. An active target is a target with an influence > 0
  25008. * @param index defines the index to check
  25009. * @returns the requested target
  25010. */
  25011. getActiveTarget(index: number): MorphTarget;
  25012. /**
  25013. * Gets the target at specified index
  25014. * @param index defines the index to check
  25015. * @returns the requested target
  25016. */
  25017. getTarget(index: number): MorphTarget;
  25018. /**
  25019. * Add a new target to this manager
  25020. * @param target defines the target to add
  25021. */
  25022. addTarget(target: MorphTarget): void;
  25023. /**
  25024. * Removes a target from the manager
  25025. * @param target defines the target to remove
  25026. */
  25027. removeTarget(target: MorphTarget): void;
  25028. /**
  25029. * Serializes the current manager into a Serialization object
  25030. * @returns the serialized object
  25031. */
  25032. serialize(): any;
  25033. private _syncActiveTargets;
  25034. /**
  25035. * Syncrhonize the targets with all the meshes using this morph target manager
  25036. */
  25037. synchronize(): void;
  25038. /**
  25039. * Creates a new MorphTargetManager from serialized data
  25040. * @param serializationObject defines the serialized data
  25041. * @param scene defines the hosting scene
  25042. * @returns the new MorphTargetManager
  25043. */
  25044. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25045. }
  25046. }
  25047. declare module "babylonjs/Physics/physicsJoint" {
  25048. import { Vector3 } from "babylonjs/Maths/math";
  25049. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  25050. /**
  25051. * Interface for Physics-Joint data
  25052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25053. */
  25054. export interface PhysicsJointData {
  25055. /**
  25056. * The main pivot of the joint
  25057. */
  25058. mainPivot?: Vector3;
  25059. /**
  25060. * The connected pivot of the joint
  25061. */
  25062. connectedPivot?: Vector3;
  25063. /**
  25064. * The main axis of the joint
  25065. */
  25066. mainAxis?: Vector3;
  25067. /**
  25068. * The connected axis of the joint
  25069. */
  25070. connectedAxis?: Vector3;
  25071. /**
  25072. * The collision of the joint
  25073. */
  25074. collision?: boolean;
  25075. /**
  25076. * Native Oimo/Cannon/Energy data
  25077. */
  25078. nativeParams?: any;
  25079. }
  25080. /**
  25081. * This is a holder class for the physics joint created by the physics plugin
  25082. * It holds a set of functions to control the underlying joint
  25083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25084. */
  25085. export class PhysicsJoint {
  25086. /**
  25087. * The type of the physics joint
  25088. */
  25089. type: number;
  25090. /**
  25091. * The data for the physics joint
  25092. */
  25093. jointData: PhysicsJointData;
  25094. private _physicsJoint;
  25095. protected _physicsPlugin: IPhysicsEnginePlugin;
  25096. /**
  25097. * Initializes the physics joint
  25098. * @param type The type of the physics joint
  25099. * @param jointData The data for the physics joint
  25100. */
  25101. constructor(
  25102. /**
  25103. * The type of the physics joint
  25104. */
  25105. type: number,
  25106. /**
  25107. * The data for the physics joint
  25108. */
  25109. jointData: PhysicsJointData);
  25110. /**
  25111. * Gets the physics joint
  25112. */
  25113. /**
  25114. * Sets the physics joint
  25115. */
  25116. physicsJoint: any;
  25117. /**
  25118. * Sets the physics plugin
  25119. */
  25120. physicsPlugin: IPhysicsEnginePlugin;
  25121. /**
  25122. * Execute a function that is physics-plugin specific.
  25123. * @param {Function} func the function that will be executed.
  25124. * It accepts two parameters: the physics world and the physics joint
  25125. */
  25126. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25127. /**
  25128. * Distance-Joint type
  25129. */
  25130. static DistanceJoint: number;
  25131. /**
  25132. * Hinge-Joint type
  25133. */
  25134. static HingeJoint: number;
  25135. /**
  25136. * Ball-and-Socket joint type
  25137. */
  25138. static BallAndSocketJoint: number;
  25139. /**
  25140. * Wheel-Joint type
  25141. */
  25142. static WheelJoint: number;
  25143. /**
  25144. * Slider-Joint type
  25145. */
  25146. static SliderJoint: number;
  25147. /**
  25148. * Prismatic-Joint type
  25149. */
  25150. static PrismaticJoint: number;
  25151. /**
  25152. * Universal-Joint type
  25153. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  25154. */
  25155. static UniversalJoint: number;
  25156. /**
  25157. * Hinge-Joint 2 type
  25158. */
  25159. static Hinge2Joint: number;
  25160. /**
  25161. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  25162. */
  25163. static PointToPointJoint: number;
  25164. /**
  25165. * Spring-Joint type
  25166. */
  25167. static SpringJoint: number;
  25168. /**
  25169. * Lock-Joint type
  25170. */
  25171. static LockJoint: number;
  25172. }
  25173. /**
  25174. * A class representing a physics distance joint
  25175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25176. */
  25177. export class DistanceJoint extends PhysicsJoint {
  25178. /**
  25179. *
  25180. * @param jointData The data for the Distance-Joint
  25181. */
  25182. constructor(jointData: DistanceJointData);
  25183. /**
  25184. * Update the predefined distance.
  25185. * @param maxDistance The maximum preferred distance
  25186. * @param minDistance The minimum preferred distance
  25187. */
  25188. updateDistance(maxDistance: number, minDistance?: number): void;
  25189. }
  25190. /**
  25191. * Represents a Motor-Enabled Joint
  25192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25193. */
  25194. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25195. /**
  25196. * Initializes the Motor-Enabled Joint
  25197. * @param type The type of the joint
  25198. * @param jointData The physica joint data for the joint
  25199. */
  25200. constructor(type: number, jointData: PhysicsJointData);
  25201. /**
  25202. * Set the motor values.
  25203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25204. * @param force the force to apply
  25205. * @param maxForce max force for this motor.
  25206. */
  25207. setMotor(force?: number, maxForce?: number): void;
  25208. /**
  25209. * Set the motor's limits.
  25210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25211. * @param upperLimit The upper limit of the motor
  25212. * @param lowerLimit The lower limit of the motor
  25213. */
  25214. setLimit(upperLimit: number, lowerLimit?: number): void;
  25215. }
  25216. /**
  25217. * This class represents a single physics Hinge-Joint
  25218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25219. */
  25220. export class HingeJoint extends MotorEnabledJoint {
  25221. /**
  25222. * Initializes the Hinge-Joint
  25223. * @param jointData The joint data for the Hinge-Joint
  25224. */
  25225. constructor(jointData: PhysicsJointData);
  25226. /**
  25227. * Set the motor values.
  25228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25229. * @param {number} force the force to apply
  25230. * @param {number} maxForce max force for this motor.
  25231. */
  25232. setMotor(force?: number, maxForce?: number): void;
  25233. /**
  25234. * Set the motor's limits.
  25235. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25236. * @param upperLimit The upper limit of the motor
  25237. * @param lowerLimit The lower limit of the motor
  25238. */
  25239. setLimit(upperLimit: number, lowerLimit?: number): void;
  25240. }
  25241. /**
  25242. * This class represents a dual hinge physics joint (same as wheel joint)
  25243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25244. */
  25245. export class Hinge2Joint extends MotorEnabledJoint {
  25246. /**
  25247. * Initializes the Hinge2-Joint
  25248. * @param jointData The joint data for the Hinge2-Joint
  25249. */
  25250. constructor(jointData: PhysicsJointData);
  25251. /**
  25252. * Set the motor values.
  25253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25254. * @param {number} force the force to apply
  25255. * @param {number} maxForce max force for this motor.
  25256. * @param {motorIndex} the motor's index, 0 or 1.
  25257. */
  25258. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25259. /**
  25260. * Set the motor limits.
  25261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25262. * @param {number} upperLimit the upper limit
  25263. * @param {number} lowerLimit lower limit
  25264. * @param {motorIndex} the motor's index, 0 or 1.
  25265. */
  25266. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25267. }
  25268. /**
  25269. * Interface for a motor enabled joint
  25270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25271. */
  25272. export interface IMotorEnabledJoint {
  25273. /**
  25274. * Physics joint
  25275. */
  25276. physicsJoint: any;
  25277. /**
  25278. * Sets the motor of the motor-enabled joint
  25279. * @param force The force of the motor
  25280. * @param maxForce The maximum force of the motor
  25281. * @param motorIndex The index of the motor
  25282. */
  25283. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25284. /**
  25285. * Sets the limit of the motor
  25286. * @param upperLimit The upper limit of the motor
  25287. * @param lowerLimit The lower limit of the motor
  25288. * @param motorIndex The index of the motor
  25289. */
  25290. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25291. }
  25292. /**
  25293. * Joint data for a Distance-Joint
  25294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25295. */
  25296. export interface DistanceJointData extends PhysicsJointData {
  25297. /**
  25298. * Max distance the 2 joint objects can be apart
  25299. */
  25300. maxDistance: number;
  25301. }
  25302. /**
  25303. * Joint data from a spring joint
  25304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25305. */
  25306. export interface SpringJointData extends PhysicsJointData {
  25307. /**
  25308. * Length of the spring
  25309. */
  25310. length: number;
  25311. /**
  25312. * Stiffness of the spring
  25313. */
  25314. stiffness: number;
  25315. /**
  25316. * Damping of the spring
  25317. */
  25318. damping: number;
  25319. /** this callback will be called when applying the force to the impostors. */
  25320. forceApplicationCallback: () => void;
  25321. }
  25322. }
  25323. declare module "babylonjs/Physics/IPhysicsEngine" {
  25324. import { Nullable } from "babylonjs/types";
  25325. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  25326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25327. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25328. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  25329. /**
  25330. * Interface used to describe a physics joint
  25331. */
  25332. export interface PhysicsImpostorJoint {
  25333. /** Defines the main impostor to which the joint is linked */
  25334. mainImpostor: PhysicsImpostor;
  25335. /** Defines the impostor that is connected to the main impostor using this joint */
  25336. connectedImpostor: PhysicsImpostor;
  25337. /** Defines the joint itself */
  25338. joint: PhysicsJoint;
  25339. }
  25340. /** @hidden */
  25341. export interface IPhysicsEnginePlugin {
  25342. world: any;
  25343. name: string;
  25344. setGravity(gravity: Vector3): void;
  25345. setTimeStep(timeStep: number): void;
  25346. getTimeStep(): number;
  25347. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  25348. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25349. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  25351. removePhysicsBody(impostor: PhysicsImpostor): void;
  25352. generateJoint(joint: PhysicsImpostorJoint): void;
  25353. removeJoint(joint: PhysicsImpostorJoint): void;
  25354. isSupported(): boolean;
  25355. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  25356. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  25357. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25361. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  25362. getBodyMass(impostor: PhysicsImpostor): number;
  25363. getBodyFriction(impostor: PhysicsImpostor): number;
  25364. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  25365. getBodyRestitution(impostor: PhysicsImpostor): number;
  25366. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  25367. sleepBody(impostor: PhysicsImpostor): void;
  25368. wakeUpBody(impostor: PhysicsImpostor): void;
  25369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  25370. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  25371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25372. getRadius(impostor: PhysicsImpostor): number;
  25373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  25374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  25375. dispose(): void;
  25376. }
  25377. /**
  25378. * Interface used to define a physics engine
  25379. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  25380. */
  25381. export interface IPhysicsEngine {
  25382. /**
  25383. * Gets the gravity vector used by the simulation
  25384. */
  25385. gravity: Vector3;
  25386. /**
  25387. * Sets the gravity vector used by the simulation
  25388. * @param gravity defines the gravity vector to use
  25389. */
  25390. setGravity(gravity: Vector3): void;
  25391. /**
  25392. * Set the time step of the physics engine.
  25393. * Default is 1/60.
  25394. * To slow it down, enter 1/600 for example.
  25395. * To speed it up, 1/30
  25396. * @param newTimeStep the new timestep to apply to this world.
  25397. */
  25398. setTimeStep(newTimeStep: number): void;
  25399. /**
  25400. * Get the time step of the physics engine.
  25401. * @returns the current time step
  25402. */
  25403. getTimeStep(): number;
  25404. /**
  25405. * Release all resources
  25406. */
  25407. dispose(): void;
  25408. /**
  25409. * Gets the name of the current physics plugin
  25410. * @returns the name of the plugin
  25411. */
  25412. getPhysicsPluginName(): string;
  25413. /**
  25414. * Adding a new impostor for the impostor tracking.
  25415. * This will be done by the impostor itself.
  25416. * @param impostor the impostor to add
  25417. */
  25418. addImpostor(impostor: PhysicsImpostor): void;
  25419. /**
  25420. * Remove an impostor from the engine.
  25421. * This impostor and its mesh will not longer be updated by the physics engine.
  25422. * @param impostor the impostor to remove
  25423. */
  25424. removeImpostor(impostor: PhysicsImpostor): void;
  25425. /**
  25426. * Add a joint to the physics engine
  25427. * @param mainImpostor defines the main impostor to which the joint is added.
  25428. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  25429. * @param joint defines the joint that will connect both impostors.
  25430. */
  25431. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25432. /**
  25433. * Removes a joint from the simulation
  25434. * @param mainImpostor defines the impostor used with the joint
  25435. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  25436. * @param joint defines the joint to remove
  25437. */
  25438. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25439. /**
  25440. * Gets the current plugin used to run the simulation
  25441. * @returns current plugin
  25442. */
  25443. getPhysicsPlugin(): IPhysicsEnginePlugin;
  25444. /**
  25445. * Gets the list of physic impostors
  25446. * @returns an array of PhysicsImpostor
  25447. */
  25448. getImpostors(): Array<PhysicsImpostor>;
  25449. /**
  25450. * Gets the impostor for a physics enabled object
  25451. * @param object defines the object impersonated by the impostor
  25452. * @returns the PhysicsImpostor or null if not found
  25453. */
  25454. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25455. /**
  25456. * Gets the impostor for a physics body object
  25457. * @param body defines physics body used by the impostor
  25458. * @returns the PhysicsImpostor or null if not found
  25459. */
  25460. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  25461. /**
  25462. * Called by the scene. No need to call it.
  25463. * @param delta defines the timespam between frames
  25464. */
  25465. _step(delta: number): void;
  25466. }
  25467. }
  25468. declare module "babylonjs/Physics/physicsImpostor" {
  25469. import { Nullable, IndicesArray } from "babylonjs/types";
  25470. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  25471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25473. import { Scene } from "babylonjs/scene";
  25474. import { Bone } from "babylonjs/Bones/bone";
  25475. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25476. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  25477. /**
  25478. * The interface for the physics imposter parameters
  25479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25480. */
  25481. export interface PhysicsImpostorParameters {
  25482. /**
  25483. * The mass of the physics imposter
  25484. */
  25485. mass: number;
  25486. /**
  25487. * The friction of the physics imposter
  25488. */
  25489. friction?: number;
  25490. /**
  25491. * The coefficient of restitution of the physics imposter
  25492. */
  25493. restitution?: number;
  25494. /**
  25495. * The native options of the physics imposter
  25496. */
  25497. nativeOptions?: any;
  25498. /**
  25499. * Specifies if the parent should be ignored
  25500. */
  25501. ignoreParent?: boolean;
  25502. /**
  25503. * Specifies if bi-directional transformations should be disabled
  25504. */
  25505. disableBidirectionalTransformation?: boolean;
  25506. }
  25507. /**
  25508. * Interface for a physics-enabled object
  25509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25510. */
  25511. export interface IPhysicsEnabledObject {
  25512. /**
  25513. * The position of the physics-enabled object
  25514. */
  25515. position: Vector3;
  25516. /**
  25517. * The rotation of the physics-enabled object
  25518. */
  25519. rotationQuaternion: Nullable<Quaternion>;
  25520. /**
  25521. * The scale of the physics-enabled object
  25522. */
  25523. scaling: Vector3;
  25524. /**
  25525. * The rotation of the physics-enabled object
  25526. */
  25527. rotation?: Vector3;
  25528. /**
  25529. * The parent of the physics-enabled object
  25530. */
  25531. parent?: any;
  25532. /**
  25533. * The bounding info of the physics-enabled object
  25534. * @returns The bounding info of the physics-enabled object
  25535. */
  25536. getBoundingInfo(): BoundingInfo;
  25537. /**
  25538. * Computes the world matrix
  25539. * @param force Specifies if the world matrix should be computed by force
  25540. * @returns A world matrix
  25541. */
  25542. computeWorldMatrix(force: boolean): Matrix;
  25543. /**
  25544. * Gets the world matrix
  25545. * @returns A world matrix
  25546. */
  25547. getWorldMatrix?(): Matrix;
  25548. /**
  25549. * Gets the child meshes
  25550. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  25551. * @returns An array of abstract meshes
  25552. */
  25553. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  25554. /**
  25555. * Gets the vertex data
  25556. * @param kind The type of vertex data
  25557. * @returns A nullable array of numbers, or a float32 array
  25558. */
  25559. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  25560. /**
  25561. * Gets the indices from the mesh
  25562. * @returns A nullable array of index arrays
  25563. */
  25564. getIndices?(): Nullable<IndicesArray>;
  25565. /**
  25566. * Gets the scene from the mesh
  25567. * @returns the indices array or null
  25568. */
  25569. getScene?(): Scene;
  25570. /**
  25571. * Gets the absolute position from the mesh
  25572. * @returns the absolute position
  25573. */
  25574. getAbsolutePosition(): Vector3;
  25575. /**
  25576. * Gets the absolute pivot point from the mesh
  25577. * @returns the absolute pivot point
  25578. */
  25579. getAbsolutePivotPoint(): Vector3;
  25580. /**
  25581. * Rotates the mesh
  25582. * @param axis The axis of rotation
  25583. * @param amount The amount of rotation
  25584. * @param space The space of the rotation
  25585. * @returns The rotation transform node
  25586. */
  25587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25588. /**
  25589. * Translates the mesh
  25590. * @param axis The axis of translation
  25591. * @param distance The distance of translation
  25592. * @param space The space of the translation
  25593. * @returns The transform node
  25594. */
  25595. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25596. /**
  25597. * Sets the absolute position of the mesh
  25598. * @param absolutePosition The absolute position of the mesh
  25599. * @returns The transform node
  25600. */
  25601. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25602. /**
  25603. * Gets the class name of the mesh
  25604. * @returns The class name
  25605. */
  25606. getClassName(): string;
  25607. }
  25608. /**
  25609. * Represents a physics imposter
  25610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25611. */
  25612. export class PhysicsImpostor {
  25613. /**
  25614. * The physics-enabled object used as the physics imposter
  25615. */
  25616. object: IPhysicsEnabledObject;
  25617. /**
  25618. * The type of the physics imposter
  25619. */
  25620. type: number;
  25621. private _options;
  25622. private _scene?;
  25623. /**
  25624. * The default object size of the imposter
  25625. */
  25626. static DEFAULT_OBJECT_SIZE: Vector3;
  25627. /**
  25628. * The identity quaternion of the imposter
  25629. */
  25630. static IDENTITY_QUATERNION: Quaternion;
  25631. private _physicsEngine;
  25632. private _physicsBody;
  25633. private _bodyUpdateRequired;
  25634. private _onBeforePhysicsStepCallbacks;
  25635. private _onAfterPhysicsStepCallbacks;
  25636. private _onPhysicsCollideCallbacks;
  25637. private _deltaPosition;
  25638. private _deltaRotation;
  25639. private _deltaRotationConjugated;
  25640. private _parent;
  25641. private _isDisposed;
  25642. private static _tmpVecs;
  25643. private static _tmpQuat;
  25644. /**
  25645. * Specifies if the physics imposter is disposed
  25646. */
  25647. readonly isDisposed: boolean;
  25648. /**
  25649. * Gets the mass of the physics imposter
  25650. */
  25651. mass: number;
  25652. /**
  25653. * Gets the coefficient of friction
  25654. */
  25655. /**
  25656. * Sets the coefficient of friction
  25657. */
  25658. friction: number;
  25659. /**
  25660. * Gets the coefficient of restitution
  25661. */
  25662. /**
  25663. * Sets the coefficient of restitution
  25664. */
  25665. restitution: number;
  25666. /**
  25667. * The unique id of the physics imposter
  25668. * set by the physics engine when adding this impostor to the array
  25669. */
  25670. uniqueId: number;
  25671. private _joints;
  25672. /**
  25673. * Initializes the physics imposter
  25674. * @param object The physics-enabled object used as the physics imposter
  25675. * @param type The type of the physics imposter
  25676. * @param _options The options for the physics imposter
  25677. * @param _scene The Babylon scene
  25678. */
  25679. constructor(
  25680. /**
  25681. * The physics-enabled object used as the physics imposter
  25682. */
  25683. object: IPhysicsEnabledObject,
  25684. /**
  25685. * The type of the physics imposter
  25686. */
  25687. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25688. /**
  25689. * This function will completly initialize this impostor.
  25690. * It will create a new body - but only if this mesh has no parent.
  25691. * If it has, this impostor will not be used other than to define the impostor
  25692. * of the child mesh.
  25693. * @hidden
  25694. */
  25695. _init(): void;
  25696. private _getPhysicsParent;
  25697. /**
  25698. * Should a new body be generated.
  25699. * @returns boolean specifying if body initialization is required
  25700. */
  25701. isBodyInitRequired(): boolean;
  25702. /**
  25703. * Sets the updated scaling
  25704. * @param updated Specifies if the scaling is updated
  25705. */
  25706. setScalingUpdated(): void;
  25707. /**
  25708. * Force a regeneration of this or the parent's impostor's body.
  25709. * Use under cautious - This will remove all joints already implemented.
  25710. */
  25711. forceUpdate(): void;
  25712. /**
  25713. * Gets the body that holds this impostor. Either its own, or its parent.
  25714. */
  25715. /**
  25716. * Set the physics body. Used mainly by the physics engine/plugin
  25717. */
  25718. physicsBody: any;
  25719. /**
  25720. * Get the parent of the physics imposter
  25721. * @returns Physics imposter or null
  25722. */
  25723. /**
  25724. * Sets the parent of the physics imposter
  25725. */
  25726. parent: Nullable<PhysicsImpostor>;
  25727. /**
  25728. * Resets the update flags
  25729. */
  25730. resetUpdateFlags(): void;
  25731. /**
  25732. * Gets the object extend size
  25733. * @returns the object extend size
  25734. */
  25735. getObjectExtendSize(): Vector3;
  25736. /**
  25737. * Gets the object center
  25738. * @returns The object center
  25739. */
  25740. getObjectCenter(): Vector3;
  25741. /**
  25742. * Get a specific parametes from the options parameter
  25743. * @param paramName The object parameter name
  25744. * @returns The object parameter
  25745. */
  25746. getParam(paramName: string): any;
  25747. /**
  25748. * Sets a specific parameter in the options given to the physics plugin
  25749. * @param paramName The parameter name
  25750. * @param value The value of the parameter
  25751. */
  25752. setParam(paramName: string, value: number): void;
  25753. /**
  25754. * Specifically change the body's mass option. Won't recreate the physics body object
  25755. * @param mass The mass of the physics imposter
  25756. */
  25757. setMass(mass: number): void;
  25758. /**
  25759. * Gets the linear velocity
  25760. * @returns linear velocity or null
  25761. */
  25762. getLinearVelocity(): Nullable<Vector3>;
  25763. /**
  25764. * Sets the linear velocity
  25765. * @param velocity linear velocity or null
  25766. */
  25767. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25768. /**
  25769. * Gets the angular velocity
  25770. * @returns angular velocity or null
  25771. */
  25772. getAngularVelocity(): Nullable<Vector3>;
  25773. /**
  25774. * Sets the angular velocity
  25775. * @param velocity The velocity or null
  25776. */
  25777. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25778. /**
  25779. * Execute a function with the physics plugin native code
  25780. * Provide a function the will have two variables - the world object and the physics body object
  25781. * @param func The function to execute with the physics plugin native code
  25782. */
  25783. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25784. /**
  25785. * Register a function that will be executed before the physics world is stepping forward
  25786. * @param func The function to execute before the physics world is stepped forward
  25787. */
  25788. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25789. /**
  25790. * Unregister a function that will be executed before the physics world is stepping forward
  25791. * @param func The function to execute before the physics world is stepped forward
  25792. */
  25793. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25794. /**
  25795. * Register a function that will be executed after the physics step
  25796. * @param func The function to execute after physics step
  25797. */
  25798. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25799. /**
  25800. * Unregisters a function that will be executed after the physics step
  25801. * @param func The function to execute after physics step
  25802. */
  25803. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25804. /**
  25805. * register a function that will be executed when this impostor collides against a different body
  25806. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25807. * @param func Callback that is executed on collision
  25808. */
  25809. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25810. /**
  25811. * Unregisters the physics imposter on contact
  25812. * @param collideAgainst The physics object to collide against
  25813. * @param func Callback to execute on collision
  25814. */
  25815. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25816. private _tmpQuat;
  25817. private _tmpQuat2;
  25818. /**
  25819. * Get the parent rotation
  25820. * @returns The parent rotation
  25821. */
  25822. getParentsRotation(): Quaternion;
  25823. /**
  25824. * this function is executed by the physics engine.
  25825. */
  25826. beforeStep: () => void;
  25827. /**
  25828. * this function is executed by the physics engine
  25829. */
  25830. afterStep: () => void;
  25831. /**
  25832. * Legacy collision detection event support
  25833. */
  25834. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25835. /**
  25836. * event and body object due to cannon's event-based architecture.
  25837. */
  25838. onCollide: (e: {
  25839. body: any;
  25840. }) => void;
  25841. /**
  25842. * Apply a force
  25843. * @param force The force to apply
  25844. * @param contactPoint The contact point for the force
  25845. * @returns The physics imposter
  25846. */
  25847. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25848. /**
  25849. * Apply an impulse
  25850. * @param force The impulse force
  25851. * @param contactPoint The contact point for the impulse force
  25852. * @returns The physics imposter
  25853. */
  25854. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25855. /**
  25856. * A help function to create a joint
  25857. * @param otherImpostor A physics imposter used to create a joint
  25858. * @param jointType The type of joint
  25859. * @param jointData The data for the joint
  25860. * @returns The physics imposter
  25861. */
  25862. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25863. /**
  25864. * Add a joint to this impostor with a different impostor
  25865. * @param otherImpostor A physics imposter used to add a joint
  25866. * @param joint The joint to add
  25867. * @returns The physics imposter
  25868. */
  25869. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25870. /**
  25871. * Will keep this body still, in a sleep mode.
  25872. * @returns the physics imposter
  25873. */
  25874. sleep(): PhysicsImpostor;
  25875. /**
  25876. * Wake the body up.
  25877. * @returns The physics imposter
  25878. */
  25879. wakeUp(): PhysicsImpostor;
  25880. /**
  25881. * Clones the physics imposter
  25882. * @param newObject The physics imposter clones to this physics-enabled object
  25883. * @returns A nullable physics imposter
  25884. */
  25885. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25886. /**
  25887. * Disposes the physics imposter
  25888. */
  25889. dispose(): void;
  25890. /**
  25891. * Sets the delta position
  25892. * @param position The delta position amount
  25893. */
  25894. setDeltaPosition(position: Vector3): void;
  25895. /**
  25896. * Sets the delta rotation
  25897. * @param rotation The delta rotation amount
  25898. */
  25899. setDeltaRotation(rotation: Quaternion): void;
  25900. /**
  25901. * Gets the box size of the physics imposter and stores the result in the input parameter
  25902. * @param result Stores the box size
  25903. * @returns The physics imposter
  25904. */
  25905. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25906. /**
  25907. * Gets the radius of the physics imposter
  25908. * @returns Radius of the physics imposter
  25909. */
  25910. getRadius(): number;
  25911. /**
  25912. * Sync a bone with this impostor
  25913. * @param bone The bone to sync to the impostor.
  25914. * @param boneMesh The mesh that the bone is influencing.
  25915. * @param jointPivot The pivot of the joint / bone in local space.
  25916. * @param distToJoint Optional distance from the impostor to the joint.
  25917. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25918. */
  25919. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25920. /**
  25921. * Sync impostor to a bone
  25922. * @param bone The bone that the impostor will be synced to.
  25923. * @param boneMesh The mesh that the bone is influencing.
  25924. * @param jointPivot The pivot of the joint / bone in local space.
  25925. * @param distToJoint Optional distance from the impostor to the joint.
  25926. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25927. * @param boneAxis Optional vector3 axis the bone is aligned with
  25928. */
  25929. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25930. /**
  25931. * No-Imposter type
  25932. */
  25933. static NoImpostor: number;
  25934. /**
  25935. * Sphere-Imposter type
  25936. */
  25937. static SphereImpostor: number;
  25938. /**
  25939. * Box-Imposter type
  25940. */
  25941. static BoxImpostor: number;
  25942. /**
  25943. * Plane-Imposter type
  25944. */
  25945. static PlaneImpostor: number;
  25946. /**
  25947. * Mesh-imposter type
  25948. */
  25949. static MeshImpostor: number;
  25950. /**
  25951. * Cylinder-Imposter type
  25952. */
  25953. static CylinderImpostor: number;
  25954. /**
  25955. * Particle-Imposter type
  25956. */
  25957. static ParticleImpostor: number;
  25958. /**
  25959. * Heightmap-Imposter type
  25960. */
  25961. static HeightmapImpostor: number;
  25962. }
  25963. }
  25964. declare module "babylonjs/Meshes/mesh" {
  25965. import { Observable } from "babylonjs/Misc/observable";
  25966. import { IAnimatable } from "babylonjs/Misc/tools";
  25967. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25968. import { Camera } from "babylonjs/Cameras/camera";
  25969. import { Scene } from "babylonjs/scene";
  25970. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  25971. import { Engine } from "babylonjs/Engines/engine";
  25972. import { Node } from "babylonjs/node";
  25973. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25974. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25975. import { Buffer } from "babylonjs/Meshes/buffer";
  25976. import { Geometry } from "babylonjs/Meshes/geometry";
  25977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25978. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25979. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25980. import { Effect } from "babylonjs/Materials/effect";
  25981. import { Material } from "babylonjs/Materials/material";
  25982. import { Skeleton } from "babylonjs/Bones/skeleton";
  25983. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25984. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25985. /**
  25986. * Class used to represent a specific level of detail of a mesh
  25987. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25988. */
  25989. export class MeshLODLevel {
  25990. /** Defines the distance where this level should star being displayed */
  25991. distance: number;
  25992. /** Defines the mesh to use to render this level */
  25993. mesh: Nullable<Mesh>;
  25994. /**
  25995. * Creates a new LOD level
  25996. * @param distance defines the distance where this level should star being displayed
  25997. * @param mesh defines the mesh to use to render this level
  25998. */
  25999. constructor(
  26000. /** Defines the distance where this level should star being displayed */
  26001. distance: number,
  26002. /** Defines the mesh to use to render this level */
  26003. mesh: Nullable<Mesh>);
  26004. }
  26005. /**
  26006. * @hidden
  26007. **/
  26008. export class _CreationDataStorage {
  26009. closePath?: boolean;
  26010. closeArray?: boolean;
  26011. idx: number[];
  26012. dashSize: number;
  26013. gapSize: number;
  26014. path3D: Path3D;
  26015. pathArray: Vector3[][];
  26016. arc: number;
  26017. radius: number;
  26018. cap: number;
  26019. tessellation: number;
  26020. }
  26021. /**
  26022. * @hidden
  26023. **/
  26024. class _InstanceDataStorage {
  26025. visibleInstances: any;
  26026. renderIdForInstances: number[];
  26027. batchCache: _InstancesBatch;
  26028. instancesBufferSize: number;
  26029. instancesBuffer: Nullable<Buffer>;
  26030. instancesData: Float32Array;
  26031. overridenInstanceCount: number;
  26032. }
  26033. /**
  26034. * @hidden
  26035. **/
  26036. export class _InstancesBatch {
  26037. mustReturn: boolean;
  26038. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  26039. renderSelf: boolean[];
  26040. }
  26041. /**
  26042. * Class used to represent renderable models
  26043. */
  26044. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26045. /**
  26046. * Mesh side orientation : usually the external or front surface
  26047. */
  26048. static readonly FRONTSIDE: number;
  26049. /**
  26050. * Mesh side orientation : usually the internal or back surface
  26051. */
  26052. static readonly BACKSIDE: number;
  26053. /**
  26054. * Mesh side orientation : both internal and external or front and back surfaces
  26055. */
  26056. static readonly DOUBLESIDE: number;
  26057. /**
  26058. * Mesh side orientation : by default, `FRONTSIDE`
  26059. */
  26060. static readonly DEFAULTSIDE: number;
  26061. /**
  26062. * Mesh cap setting : no cap
  26063. */
  26064. static readonly NO_CAP: number;
  26065. /**
  26066. * Mesh cap setting : one cap at the beginning of the mesh
  26067. */
  26068. static readonly CAP_START: number;
  26069. /**
  26070. * Mesh cap setting : one cap at the end of the mesh
  26071. */
  26072. static readonly CAP_END: number;
  26073. /**
  26074. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26075. */
  26076. static readonly CAP_ALL: number;
  26077. private _onBeforeRenderObservable;
  26078. private _onAfterRenderObservable;
  26079. private _onBeforeDrawObservable;
  26080. /**
  26081. * An event triggered before rendering the mesh
  26082. */
  26083. readonly onBeforeRenderObservable: Observable<Mesh>;
  26084. /**
  26085. * An event triggered after rendering the mesh
  26086. */
  26087. readonly onAfterRenderObservable: Observable<Mesh>;
  26088. /**
  26089. * An event triggered before drawing the mesh
  26090. */
  26091. readonly onBeforeDrawObservable: Observable<Mesh>;
  26092. private _onBeforeDrawObserver;
  26093. /**
  26094. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26095. */
  26096. onBeforeDraw: () => void;
  26097. /**
  26098. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26099. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26100. */
  26101. delayLoadState: number;
  26102. /**
  26103. * Gets the list of instances created from this mesh
  26104. * it is not supposed to be modified manually.
  26105. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26106. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26107. */
  26108. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  26109. /**
  26110. * Gets the file containing delay loading data for this mesh
  26111. */
  26112. delayLoadingFile: string;
  26113. /** @hidden */
  26114. _binaryInfo: any;
  26115. private _LODLevels;
  26116. /**
  26117. * User defined function used to change how LOD level selection is done
  26118. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26119. */
  26120. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26121. private _morphTargetManager;
  26122. /**
  26123. * Gets or sets the morph target manager
  26124. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26125. */
  26126. morphTargetManager: Nullable<MorphTargetManager>;
  26127. /** @hidden */
  26128. _creationDataStorage: Nullable<_CreationDataStorage>;
  26129. /** @hidden */
  26130. _geometry: Nullable<Geometry>;
  26131. /** @hidden */
  26132. _delayInfo: Array<string>;
  26133. /** @hidden */
  26134. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26135. /** @hidden */
  26136. _instanceDataStorage: _InstanceDataStorage;
  26137. private _effectiveMaterial;
  26138. /** @hidden */
  26139. _shouldGenerateFlatShading: boolean;
  26140. private _preActivateId;
  26141. /** @hidden */
  26142. _originalBuilderSideOrientation: number;
  26143. /**
  26144. * Use this property to change the original side orientation defined at construction time
  26145. */
  26146. overrideMaterialSideOrientation: Nullable<number>;
  26147. private _areNormalsFrozen;
  26148. private _sourcePositions;
  26149. private _sourceNormals;
  26150. private _source;
  26151. private meshMap;
  26152. /**
  26153. * Gets the source mesh (the one used to clone this one from)
  26154. */
  26155. readonly source: Nullable<Mesh>;
  26156. /**
  26157. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26158. */
  26159. isUnIndexed: boolean;
  26160. /**
  26161. * @constructor
  26162. * @param name The value used by scene.getMeshByName() to do a lookup.
  26163. * @param scene The scene to add this mesh to.
  26164. * @param parent The parent of this mesh, if it has one
  26165. * @param source An optional Mesh from which geometry is shared, cloned.
  26166. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26167. * When false, achieved by calling a clone(), also passing False.
  26168. * This will make creation of children, recursive.
  26169. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26170. */
  26171. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26172. /**
  26173. * Gets the class name
  26174. * @returns the string "Mesh".
  26175. */
  26176. getClassName(): string;
  26177. /** @hidden */
  26178. readonly _isMesh: boolean;
  26179. /**
  26180. * Returns a description of this mesh
  26181. * @param fullDetails define if full details about this mesh must be used
  26182. * @returns a descriptive string representing this mesh
  26183. */
  26184. toString(fullDetails?: boolean): string;
  26185. /** @hidden */
  26186. _unBindEffect(): void;
  26187. /**
  26188. * Gets a boolean indicating if this mesh has LOD
  26189. */
  26190. readonly hasLODLevels: boolean;
  26191. /**
  26192. * Gets the list of MeshLODLevel associated with the current mesh
  26193. * @returns an array of MeshLODLevel
  26194. */
  26195. getLODLevels(): MeshLODLevel[];
  26196. private _sortLODLevels;
  26197. /**
  26198. * Add a mesh as LOD level triggered at the given distance.
  26199. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26200. * @param distance The distance from the center of the object to show this level
  26201. * @param mesh The mesh to be added as LOD level (can be null)
  26202. * @return This mesh (for chaining)
  26203. */
  26204. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26205. /**
  26206. * Returns the LOD level mesh at the passed distance or null if not found.
  26207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26208. * @param distance The distance from the center of the object to show this level
  26209. * @returns a Mesh or `null`
  26210. */
  26211. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26212. /**
  26213. * Remove a mesh from the LOD array
  26214. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26215. * @param mesh defines the mesh to be removed
  26216. * @return This mesh (for chaining)
  26217. */
  26218. removeLODLevel(mesh: Mesh): Mesh;
  26219. /**
  26220. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26221. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26222. * @param camera defines the camera to use to compute distance
  26223. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26224. * @return This mesh (for chaining)
  26225. */
  26226. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26227. /**
  26228. * Gets the mesh internal Geometry object
  26229. */
  26230. readonly geometry: Nullable<Geometry>;
  26231. /**
  26232. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26233. * @returns the total number of vertices
  26234. */
  26235. getTotalVertices(): number;
  26236. /**
  26237. * Returns the content of an associated vertex buffer
  26238. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26239. * - VertexBuffer.PositionKind
  26240. * - VertexBuffer.UVKind
  26241. * - VertexBuffer.UV2Kind
  26242. * - VertexBuffer.UV3Kind
  26243. * - VertexBuffer.UV4Kind
  26244. * - VertexBuffer.UV5Kind
  26245. * - VertexBuffer.UV6Kind
  26246. * - VertexBuffer.ColorKind
  26247. * - VertexBuffer.MatricesIndicesKind
  26248. * - VertexBuffer.MatricesIndicesExtraKind
  26249. * - VertexBuffer.MatricesWeightsKind
  26250. * - VertexBuffer.MatricesWeightsExtraKind
  26251. * @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
  26252. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26253. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26254. */
  26255. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26256. /**
  26257. * Returns the mesh VertexBuffer object from the requested `kind`
  26258. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26259. * - VertexBuffer.PositionKind
  26260. * - VertexBuffer.UVKind
  26261. * - VertexBuffer.UV2Kind
  26262. * - VertexBuffer.UV3Kind
  26263. * - VertexBuffer.UV4Kind
  26264. * - VertexBuffer.UV5Kind
  26265. * - VertexBuffer.UV6Kind
  26266. * - VertexBuffer.ColorKind
  26267. * - VertexBuffer.MatricesIndicesKind
  26268. * - VertexBuffer.MatricesIndicesExtraKind
  26269. * - VertexBuffer.MatricesWeightsKind
  26270. * - VertexBuffer.MatricesWeightsExtraKind
  26271. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26272. */
  26273. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26274. /**
  26275. * Tests if a specific vertex buffer is associated with this mesh
  26276. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26277. * - VertexBuffer.PositionKind
  26278. * - VertexBuffer.UVKind
  26279. * - VertexBuffer.UV2Kind
  26280. * - VertexBuffer.UV3Kind
  26281. * - VertexBuffer.UV4Kind
  26282. * - VertexBuffer.UV5Kind
  26283. * - VertexBuffer.UV6Kind
  26284. * - VertexBuffer.ColorKind
  26285. * - VertexBuffer.MatricesIndicesKind
  26286. * - VertexBuffer.MatricesIndicesExtraKind
  26287. * - VertexBuffer.MatricesWeightsKind
  26288. * - VertexBuffer.MatricesWeightsExtraKind
  26289. * @returns a boolean
  26290. */
  26291. isVerticesDataPresent(kind: string): boolean;
  26292. /**
  26293. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26294. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26295. * - VertexBuffer.PositionKind
  26296. * - VertexBuffer.UVKind
  26297. * - VertexBuffer.UV2Kind
  26298. * - VertexBuffer.UV3Kind
  26299. * - VertexBuffer.UV4Kind
  26300. * - VertexBuffer.UV5Kind
  26301. * - VertexBuffer.UV6Kind
  26302. * - VertexBuffer.ColorKind
  26303. * - VertexBuffer.MatricesIndicesKind
  26304. * - VertexBuffer.MatricesIndicesExtraKind
  26305. * - VertexBuffer.MatricesWeightsKind
  26306. * - VertexBuffer.MatricesWeightsExtraKind
  26307. * @returns a boolean
  26308. */
  26309. isVertexBufferUpdatable(kind: string): boolean;
  26310. /**
  26311. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26312. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26313. * - VertexBuffer.PositionKind
  26314. * - VertexBuffer.UVKind
  26315. * - VertexBuffer.UV2Kind
  26316. * - VertexBuffer.UV3Kind
  26317. * - VertexBuffer.UV4Kind
  26318. * - VertexBuffer.UV5Kind
  26319. * - VertexBuffer.UV6Kind
  26320. * - VertexBuffer.ColorKind
  26321. * - VertexBuffer.MatricesIndicesKind
  26322. * - VertexBuffer.MatricesIndicesExtraKind
  26323. * - VertexBuffer.MatricesWeightsKind
  26324. * - VertexBuffer.MatricesWeightsExtraKind
  26325. * @returns an array of strings
  26326. */
  26327. getVerticesDataKinds(): string[];
  26328. /**
  26329. * Returns a positive integer : the total number of indices in this mesh geometry.
  26330. * @returns the numner of indices or zero if the mesh has no geometry.
  26331. */
  26332. getTotalIndices(): number;
  26333. /**
  26334. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26335. * @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.
  26336. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26337. * @returns the indices array or an empty array if the mesh has no geometry
  26338. */
  26339. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26340. readonly isBlocked: boolean;
  26341. /**
  26342. * Determine if the current mesh is ready to be rendered
  26343. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26344. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26345. * @returns true if all associated assets are ready (material, textures, shaders)
  26346. */
  26347. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26348. /**
  26349. * 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.
  26350. */
  26351. readonly areNormalsFrozen: boolean;
  26352. /**
  26353. * 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.
  26354. * @returns the current mesh
  26355. */
  26356. freezeNormals(): Mesh;
  26357. /**
  26358. * 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
  26359. * @returns the current mesh
  26360. */
  26361. unfreezeNormals(): Mesh;
  26362. /**
  26363. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26364. */
  26365. overridenInstanceCount: number;
  26366. /** @hidden */
  26367. _preActivate(): Mesh;
  26368. /** @hidden */
  26369. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26370. /** @hidden */
  26371. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26372. /**
  26373. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26374. * This means the mesh underlying bounding box and sphere are recomputed.
  26375. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26376. * @returns the current mesh
  26377. */
  26378. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26379. /** @hidden */
  26380. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26381. /**
  26382. * This function will subdivide the mesh into multiple submeshes
  26383. * @param count defines the expected number of submeshes
  26384. */
  26385. subdivide(count: number): void;
  26386. /**
  26387. * Copy a FloatArray into a specific associated vertex buffer
  26388. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26389. * - VertexBuffer.PositionKind
  26390. * - VertexBuffer.UVKind
  26391. * - VertexBuffer.UV2Kind
  26392. * - VertexBuffer.UV3Kind
  26393. * - VertexBuffer.UV4Kind
  26394. * - VertexBuffer.UV5Kind
  26395. * - VertexBuffer.UV6Kind
  26396. * - VertexBuffer.ColorKind
  26397. * - VertexBuffer.MatricesIndicesKind
  26398. * - VertexBuffer.MatricesIndicesExtraKind
  26399. * - VertexBuffer.MatricesWeightsKind
  26400. * - VertexBuffer.MatricesWeightsExtraKind
  26401. * @param data defines the data source
  26402. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26403. * @param stride defines the data stride size (can be null)
  26404. * @returns the current mesh
  26405. */
  26406. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26407. /**
  26408. * Flags an associated vertex buffer as updatable
  26409. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26410. * - VertexBuffer.PositionKind
  26411. * - VertexBuffer.UVKind
  26412. * - VertexBuffer.UV2Kind
  26413. * - VertexBuffer.UV3Kind
  26414. * - VertexBuffer.UV4Kind
  26415. * - VertexBuffer.UV5Kind
  26416. * - VertexBuffer.UV6Kind
  26417. * - VertexBuffer.ColorKind
  26418. * - VertexBuffer.MatricesIndicesKind
  26419. * - VertexBuffer.MatricesIndicesExtraKind
  26420. * - VertexBuffer.MatricesWeightsKind
  26421. * - VertexBuffer.MatricesWeightsExtraKind
  26422. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26423. */
  26424. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26425. /**
  26426. * Sets the mesh global Vertex Buffer
  26427. * @param buffer defines the buffer to use
  26428. * @returns the current mesh
  26429. */
  26430. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26431. /**
  26432. * Update a specific associated vertex buffer
  26433. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26434. * - VertexBuffer.PositionKind
  26435. * - VertexBuffer.UVKind
  26436. * - VertexBuffer.UV2Kind
  26437. * - VertexBuffer.UV3Kind
  26438. * - VertexBuffer.UV4Kind
  26439. * - VertexBuffer.UV5Kind
  26440. * - VertexBuffer.UV6Kind
  26441. * - VertexBuffer.ColorKind
  26442. * - VertexBuffer.MatricesIndicesKind
  26443. * - VertexBuffer.MatricesIndicesExtraKind
  26444. * - VertexBuffer.MatricesWeightsKind
  26445. * - VertexBuffer.MatricesWeightsExtraKind
  26446. * @param data defines the data source
  26447. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26448. * @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)
  26449. * @returns the current mesh
  26450. */
  26451. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26452. /**
  26453. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26454. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26455. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26456. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26457. * @returns the current mesh
  26458. */
  26459. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26460. /**
  26461. * Creates a un-shared specific occurence of the geometry for the mesh.
  26462. * @returns the current mesh
  26463. */
  26464. makeGeometryUnique(): Mesh;
  26465. /**
  26466. * Set the index buffer of this mesh
  26467. * @param indices defines the source data
  26468. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26469. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26470. * @returns the current mesh
  26471. */
  26472. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26473. /**
  26474. * Update the current index buffer
  26475. * @param indices defines the source data
  26476. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26477. * @returns the current mesh
  26478. */
  26479. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26480. /**
  26481. * Invert the geometry to move from a right handed system to a left handed one.
  26482. * @returns the current mesh
  26483. */
  26484. toLeftHanded(): Mesh;
  26485. /** @hidden */
  26486. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26487. /** @hidden */
  26488. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26489. /**
  26490. * Registers for this mesh a javascript function called just before the rendering process
  26491. * @param func defines the function to call before rendering this mesh
  26492. * @returns the current mesh
  26493. */
  26494. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26495. /**
  26496. * Disposes a previously registered javascript function called before the rendering
  26497. * @param func defines the function to remove
  26498. * @returns the current mesh
  26499. */
  26500. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26501. /**
  26502. * Registers for this mesh a javascript function called just after the rendering is complete
  26503. * @param func defines the function to call after rendering this mesh
  26504. * @returns the current mesh
  26505. */
  26506. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26507. /**
  26508. * Disposes a previously registered javascript function called after the rendering.
  26509. * @param func defines the function to remove
  26510. * @returns the current mesh
  26511. */
  26512. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26513. /** @hidden */
  26514. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26515. /** @hidden */
  26516. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26517. /** @hidden */
  26518. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26519. /**
  26520. * 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
  26521. * @param subMesh defines the subMesh to render
  26522. * @param enableAlphaMode defines if alpha mode can be changed
  26523. * @returns the current mesh
  26524. */
  26525. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26526. private _onBeforeDraw;
  26527. /**
  26528. * Renormalize the mesh and patch it up if there are no weights
  26529. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26530. * However in the case of zero weights then we set just a single influence to 1.
  26531. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26532. */
  26533. cleanMatrixWeights(): void;
  26534. private normalizeSkinFourWeights;
  26535. private normalizeSkinWeightsAndExtra;
  26536. /**
  26537. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26538. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26539. * the user know there was an issue with importing the mesh
  26540. * @returns a validation object with skinned, valid and report string
  26541. */
  26542. validateSkinning(): {
  26543. skinned: boolean;
  26544. valid: boolean;
  26545. report: string;
  26546. };
  26547. /** @hidden */
  26548. _checkDelayState(): Mesh;
  26549. private _queueLoad;
  26550. /**
  26551. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26552. * A mesh is in the frustum if its bounding box intersects the frustum
  26553. * @param frustumPlanes defines the frustum to test
  26554. * @returns true if the mesh is in the frustum planes
  26555. */
  26556. isInFrustum(frustumPlanes: Plane[]): boolean;
  26557. /**
  26558. * Sets the mesh material by the material or multiMaterial `id` property
  26559. * @param id is a string identifying the material or the multiMaterial
  26560. * @returns the current mesh
  26561. */
  26562. setMaterialByID(id: string): Mesh;
  26563. /**
  26564. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26565. * @returns an array of IAnimatable
  26566. */
  26567. getAnimatables(): IAnimatable[];
  26568. /**
  26569. * Modifies the mesh geometry according to the passed transformation matrix.
  26570. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26571. * The mesh normals are modified using the same transformation.
  26572. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26573. * @param transform defines the transform matrix to use
  26574. * @see http://doc.babylonjs.com/resources/baking_transformations
  26575. * @returns the current mesh
  26576. */
  26577. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26578. /**
  26579. * Modifies the mesh geometry according to its own current World Matrix.
  26580. * The mesh World Matrix is then reset.
  26581. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26582. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26583. * @see http://doc.babylonjs.com/resources/baking_transformations
  26584. * @returns the current mesh
  26585. */
  26586. bakeCurrentTransformIntoVertices(): Mesh;
  26587. /** @hidden */
  26588. readonly _positions: Nullable<Vector3[]>;
  26589. /** @hidden */
  26590. _resetPointsArrayCache(): Mesh;
  26591. /** @hidden */
  26592. _generatePointsArray(): boolean;
  26593. /**
  26594. * Returns a new Mesh object generated from the current mesh properties.
  26595. * This method must not get confused with createInstance()
  26596. * @param name is a string, the name given to the new mesh
  26597. * @param newParent can be any Node object (default `null`)
  26598. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26599. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26600. * @returns a new mesh
  26601. */
  26602. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26603. /**
  26604. * Releases resources associated with this mesh.
  26605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26607. */
  26608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26609. /**
  26610. * Modifies the mesh geometry according to a displacement map.
  26611. * 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.
  26612. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26613. * @param url is a string, the URL from the image file is to be downloaded.
  26614. * @param minHeight is the lower limit of the displacement.
  26615. * @param maxHeight is the upper limit of the displacement.
  26616. * @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.
  26617. * @param uvOffset is an optional vector2 used to offset UV.
  26618. * @param uvScale is an optional vector2 used to scale UV.
  26619. * @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.
  26620. * @returns the Mesh.
  26621. */
  26622. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26623. /**
  26624. * Modifies the mesh geometry according to a displacementMap buffer.
  26625. * 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.
  26626. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26627. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26628. * @param heightMapWidth is the width of the buffer image.
  26629. * @param heightMapHeight is the height of the buffer image.
  26630. * @param minHeight is the lower limit of the displacement.
  26631. * @param maxHeight is the upper limit of the displacement.
  26632. * @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.
  26633. * @param uvOffset is an optional vector2 used to offset UV.
  26634. * @param uvScale is an optional vector2 used to scale UV.
  26635. * @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.
  26636. * @returns the Mesh.
  26637. */
  26638. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26639. /**
  26640. * Modify the mesh to get a flat shading rendering.
  26641. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26642. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26643. * @returns current mesh
  26644. */
  26645. convertToFlatShadedMesh(): Mesh;
  26646. /**
  26647. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26648. * In other words, more vertices, no more indices and a single bigger VBO.
  26649. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26650. * @returns current mesh
  26651. */
  26652. convertToUnIndexedMesh(): Mesh;
  26653. /**
  26654. * Inverses facet orientations.
  26655. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26656. * @param flipNormals will also inverts the normals
  26657. * @returns current mesh
  26658. */
  26659. flipFaces(flipNormals?: boolean): Mesh;
  26660. /** @hidden */
  26661. static _instancedMeshFactory: (name: string, mesh: Mesh) => import("babylonjs/Meshes/instancedMesh").InstancedMesh;
  26662. /**
  26663. * Creates a new InstancedMesh object from the mesh model.
  26664. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26665. * @param name defines the name of the new instance
  26666. * @returns a new InstancedMesh
  26667. */
  26668. createInstance(name: string): InstancedMesh;
  26669. /**
  26670. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26671. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26672. * @returns the current mesh
  26673. */
  26674. synchronizeInstances(): Mesh;
  26675. /**
  26676. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26677. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26678. * This should be used together with the simplification to avoid disappearing triangles.
  26679. * @param successCallback an optional success callback to be called after the optimization finished.
  26680. * @returns the current mesh
  26681. */
  26682. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26683. /**
  26684. * Serialize current mesh
  26685. * @param serializationObject defines the object which will receive the serialization data
  26686. */
  26687. serialize(serializationObject: any): void;
  26688. /** @hidden */
  26689. _syncGeometryWithMorphTargetManager(): void;
  26690. /** @hidden */
  26691. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26692. /**
  26693. * Returns a new Mesh object parsed from the source provided.
  26694. * @param parsedMesh is the source
  26695. * @param scene defines the hosting scene
  26696. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26697. * @returns a new Mesh
  26698. */
  26699. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26700. /**
  26701. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26702. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26703. * @param name defines the name of the mesh to create
  26704. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26705. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26706. * @param closePath creates a seam between the first and the last points of each path of the path array
  26707. * @param offset is taken in account only if the `pathArray` is containing a single path
  26708. * @param scene defines the hosting scene
  26709. * @param updatable defines if the mesh must be flagged as updatable
  26710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26711. * @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)
  26712. * @returns a new Mesh
  26713. */
  26714. static CreateRibbon: (name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene | undefined, updatable?: boolean | undefined, sideOrientation?: number | undefined, instance?: Mesh | undefined) => Mesh;
  26715. /**
  26716. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26717. * @param name defines the name of the mesh to create
  26718. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26719. * @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
  26720. * @param scene defines the hosting scene
  26721. * @param updatable defines if the mesh must be flagged as updatable
  26722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26723. * @returns a new Mesh
  26724. */
  26725. static CreateDisc: (name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26726. /**
  26727. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26728. * @param name defines the name of the mesh to create
  26729. * @param size sets the size (float) of each box side (default 1)
  26730. * @param scene defines the hosting scene
  26731. * @param updatable defines if the mesh must be flagged as updatable
  26732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26733. * @returns a new Mesh
  26734. */
  26735. static CreateBox: (name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26736. /**
  26737. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26738. * @param name defines the name of the mesh to create
  26739. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26740. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26741. * @param scene defines the hosting scene
  26742. * @param updatable defines if the mesh must be flagged as updatable
  26743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26744. * @returns a new Mesh
  26745. */
  26746. static CreateSphere: (name: string, segments: number, diameter: number, scene?: Scene | undefined, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26747. /**
  26748. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26749. * @param name defines the name of the mesh to create
  26750. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26751. * @param diameterTop set the top cap diameter (floats, default 1)
  26752. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26753. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26754. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26755. * @param scene defines the hosting scene
  26756. * @param updatable defines if the mesh must be flagged as updatable
  26757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26758. * @returns a new Mesh
  26759. */
  26760. static CreateCylinder: (name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene | undefined, updatable?: any, sideOrientation?: number | undefined) => Mesh;
  26761. /**
  26762. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26763. * @param name defines the name of the mesh to create
  26764. * @param diameter sets the diameter size (float) of the torus (default 1)
  26765. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26766. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26767. * @param scene defines the hosting scene
  26768. * @param updatable defines if the mesh must be flagged as updatable
  26769. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26770. * @returns a new Mesh
  26771. */
  26772. static CreateTorus: (name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene | undefined, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26773. /**
  26774. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26775. * @param name defines the name of the mesh to create
  26776. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26777. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26778. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26779. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26780. * @param p the number of windings on X axis (positive integers, default 2)
  26781. * @param q the number of windings on Y axis (positive integers, default 3)
  26782. * @param scene defines the hosting scene
  26783. * @param updatable defines if the mesh must be flagged as updatable
  26784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26785. * @returns a new Mesh
  26786. */
  26787. static CreateTorusKnot: (name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene | undefined, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26788. /**
  26789. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26790. * @param name defines the name of the mesh to create
  26791. * @param points is an array successive Vector3
  26792. * @param scene defines the hosting scene
  26793. * @param updatable defines if the mesh must be flagged as updatable
  26794. * @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).
  26795. * @returns a new Mesh
  26796. */
  26797. static CreateLines: (name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<import("babylonjs/Meshes/linesMesh").LinesMesh>) => import("babylonjs/Meshes/linesMesh").LinesMesh;
  26798. /**
  26799. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26800. * @param name defines the name of the mesh to create
  26801. * @param points is an array successive Vector3
  26802. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26803. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26804. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26805. * @param scene defines the hosting scene
  26806. * @param updatable defines if the mesh must be flagged as updatable
  26807. * @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)
  26808. * @returns a new Mesh
  26809. */
  26810. static CreateDashedLines: (name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean | undefined, instance?: import("babylonjs/Meshes/linesMesh").LinesMesh | undefined) => import("babylonjs/Meshes/linesMesh").LinesMesh;
  26811. /**
  26812. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26813. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26814. * 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.
  26815. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26816. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26817. * Remember you can only change the shape positions, not their number when updating a polygon.
  26818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26819. * @param name defines the name of the mesh to create
  26820. * @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
  26821. * @param scene defines the hosting scene
  26822. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26823. * @param updatable defines if the mesh must be flagged as updatable
  26824. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26825. * @returns a new Mesh
  26826. */
  26827. static CreatePolygon: (name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][] | undefined, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26828. /**
  26829. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26831. * @param name defines the name of the mesh to create
  26832. * @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
  26833. * @param depth defines the height of extrusion
  26834. * @param scene defines the hosting scene
  26835. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26836. * @param updatable defines if the mesh must be flagged as updatable
  26837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26838. * @returns a new Mesh
  26839. */
  26840. static ExtrudePolygon: (name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][] | undefined, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26841. /**
  26842. * Creates an extruded shape mesh.
  26843. * 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
  26844. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26845. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26846. * @param name defines the name of the mesh to create
  26847. * @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
  26848. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26849. * @param scale is the value to scale the shape
  26850. * @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
  26851. * @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
  26852. * @param scene defines the hosting scene
  26853. * @param updatable defines if the mesh must be flagged as updatable
  26854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26855. * @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)
  26856. * @returns a new Mesh
  26857. */
  26858. static ExtrudeShape: (name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean | undefined, sideOrientation?: number | undefined, instance?: Mesh | undefined) => Mesh;
  26859. /**
  26860. * Creates an custom extruded shape mesh.
  26861. * The custom extrusion is a parametric shape.
  26862. * It has no predefined shape. Its final shape will depend on the input parameters.
  26863. * Please consider using the same method from the MeshBuilder class instead
  26864. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26865. * @param name defines the name of the mesh to create
  26866. * @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
  26867. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26868. * @param scaleFunction is a custom Javascript function called on each path point
  26869. * @param rotationFunction is a custom Javascript function called on each path point
  26870. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26871. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26872. * @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
  26873. * @param scene defines the hosting scene
  26874. * @param updatable defines if the mesh must be flagged as updatable
  26875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26876. * @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)
  26877. * @returns a new Mesh
  26878. */
  26879. static ExtrudeShapeCustom: (name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean | undefined, sideOrientation?: number | undefined, instance?: Mesh | undefined) => Mesh;
  26880. /**
  26881. * Creates lathe mesh.
  26882. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26883. * Please consider using the same method from the MeshBuilder class instead
  26884. * @param name defines the name of the mesh to create
  26885. * @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
  26886. * @param radius is the radius value of the lathe
  26887. * @param tessellation is the side number of the lathe.
  26888. * @param scene defines the hosting scene
  26889. * @param updatable defines if the mesh must be flagged as updatable
  26890. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26891. * @returns a new Mesh
  26892. */
  26893. static CreateLathe: (name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26894. /**
  26895. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26896. * @param name defines the name of the mesh to create
  26897. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26898. * @param scene defines the hosting scene
  26899. * @param updatable defines if the mesh must be flagged as updatable
  26900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26901. * @returns a new Mesh
  26902. */
  26903. static CreatePlane: (name: string, size: number, scene: Scene, updatable?: boolean | undefined, sideOrientation?: number | undefined) => Mesh;
  26904. /**
  26905. * Creates a ground mesh.
  26906. * Please consider using the same method from the MeshBuilder class instead
  26907. * @param name defines the name of the mesh to create
  26908. * @param width set the width of the ground
  26909. * @param height set the height of the ground
  26910. * @param subdivisions sets the number of subdivisions per side
  26911. * @param scene defines the hosting scene
  26912. * @param updatable defines if the mesh must be flagged as updatable
  26913. * @returns a new Mesh
  26914. */
  26915. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26916. /**
  26917. * Creates a tiled ground mesh.
  26918. * Please consider using the same method from the MeshBuilder class instead
  26919. * @param name defines the name of the mesh to create
  26920. * @param xmin set the ground minimum X coordinate
  26921. * @param zmin set the ground minimum Y coordinate
  26922. * @param xmax set the ground maximum X coordinate
  26923. * @param zmax set the ground maximum Z coordinate
  26924. * @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
  26925. * @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
  26926. * @param scene defines the hosting scene
  26927. * @param updatable defines if the mesh must be flagged as updatable
  26928. * @returns a new Mesh
  26929. */
  26930. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26931. w: number;
  26932. h: number;
  26933. }, precision: {
  26934. w: number;
  26935. h: number;
  26936. }, scene: Scene, updatable?: boolean): Mesh;
  26937. /**
  26938. * Creates a ground mesh from a height map.
  26939. * Please consider using the same method from the MeshBuilder class instead
  26940. * @see http://doc.babylonjs.com/babylon101/height_map
  26941. * @param name defines the name of the mesh to create
  26942. * @param url sets the URL of the height map image resource
  26943. * @param width set the ground width size
  26944. * @param height set the ground height size
  26945. * @param subdivisions sets the number of subdivision per side
  26946. * @param minHeight is the minimum altitude on the ground
  26947. * @param maxHeight is the maximum altitude on the ground
  26948. * @param scene defines the hosting scene
  26949. * @param updatable defines if the mesh must be flagged as updatable
  26950. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26951. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26952. * @returns a new Mesh
  26953. */
  26954. static CreateGroundFromHeightMap: (name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean | undefined, onReady?: ((mesh: import("babylonjs/Meshes/groundMesh").GroundMesh) => void) | undefined, alphaFilter?: number | undefined) => import("babylonjs/Meshes/groundMesh").GroundMesh;
  26955. /**
  26956. * Creates a tube mesh.
  26957. * The tube is a parametric shape.
  26958. * It has no predefined shape. Its final shape will depend on the input parameters.
  26959. * Please consider using the same method from the MeshBuilder class instead
  26960. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26961. * @param name defines the name of the mesh to create
  26962. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26963. * @param radius sets the tube radius size
  26964. * @param tessellation is the number of sides on the tubular surface
  26965. * @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
  26966. * @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
  26967. * @param scene defines the hosting scene
  26968. * @param updatable defines if the mesh must be flagged as updatable
  26969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26970. * @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)
  26971. * @returns a new Mesh
  26972. */
  26973. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26974. (i: number, distance: number): number;
  26975. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26976. /**
  26977. * Creates a polyhedron mesh.
  26978. * Please consider using the same method from the MeshBuilder class instead.
  26979. * * 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
  26980. * * The parameter `size` (positive float, default 1) sets the polygon size
  26981. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26982. * * 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`
  26983. * * 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
  26984. * * 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)`)
  26985. * * 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
  26986. * * 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
  26987. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26988. * * 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
  26989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26990. * @param name defines the name of the mesh to create
  26991. * @param options defines the options used to create the mesh
  26992. * @param scene defines the hosting scene
  26993. * @returns a new Mesh
  26994. */
  26995. static CreatePolyhedron: (name: string, options: {
  26996. type?: number | undefined;
  26997. size?: number | undefined;
  26998. sizeX?: number | undefined;
  26999. sizeY?: number | undefined;
  27000. sizeZ?: number | undefined;
  27001. custom?: any;
  27002. faceUV?: Vector4[] | undefined;
  27003. faceColors?: Color4[] | undefined;
  27004. updatable?: boolean | undefined;
  27005. sideOrientation?: number | undefined;
  27006. }, scene: Scene) => Mesh;
  27007. /**
  27008. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27009. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27010. * * 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`)
  27011. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27012. * * 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
  27013. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27014. * * 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
  27015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27016. * @param name defines the name of the mesh
  27017. * @param options defines the options used to create the mesh
  27018. * @param scene defines the hosting scene
  27019. * @returns a new Mesh
  27020. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27021. */
  27022. static CreateIcoSphere: (name: string, options: {
  27023. radius?: number | undefined;
  27024. flat?: boolean | undefined;
  27025. subdivisions?: number | undefined;
  27026. sideOrientation?: number | undefined;
  27027. updatable?: boolean | undefined;
  27028. }, scene: Scene) => Mesh;
  27029. /**
  27030. * Creates a decal mesh.
  27031. * Please consider using the same method from the MeshBuilder class instead.
  27032. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27033. * @param name defines the name of the mesh
  27034. * @param sourceMesh defines the mesh receiving the decal
  27035. * @param position sets the position of the decal in world coordinates
  27036. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27037. * @param size sets the decal scaling
  27038. * @param angle sets the angle to rotate the decal
  27039. * @returns a new Mesh
  27040. */
  27041. static CreateDecal: (name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number) => Mesh;
  27042. /**
  27043. * Prepare internal position array for software CPU skinning
  27044. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27045. */
  27046. setPositionsForCPUSkinning(): Float32Array;
  27047. /**
  27048. * Prepare internal normal array for software CPU skinning
  27049. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27050. */
  27051. setNormalsForCPUSkinning(): Float32Array;
  27052. /**
  27053. * Updates the vertex buffer by applying transformation from the bones
  27054. * @param skeleton defines the skeleton to apply to current mesh
  27055. * @returns the current mesh
  27056. */
  27057. applySkeleton(skeleton: Skeleton): Mesh;
  27058. /**
  27059. * 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
  27060. * @param meshes defines the list of meshes to scan
  27061. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27062. */
  27063. static MinMax(meshes: AbstractMesh[]): {
  27064. min: Vector3;
  27065. max: Vector3;
  27066. };
  27067. /**
  27068. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27069. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27070. * @returns a vector3
  27071. */
  27072. static Center(meshesOrMinMaxVector: {
  27073. min: Vector3;
  27074. max: Vector3;
  27075. } | AbstractMesh[]): Vector3;
  27076. /**
  27077. * Merge the array of meshes into a single mesh for performance reasons.
  27078. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27079. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27080. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27081. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27082. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27083. * @returns a new mesh
  27084. */
  27085. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27086. /** @hidden */
  27087. addInstance(instance: InstancedMesh): void;
  27088. /** @hidden */
  27089. removeInstance(instance: InstancedMesh): void;
  27090. }
  27091. }
  27092. declare module "babylonjs/Shaders/pass.fragment" {
  27093. export var passPixelShader: {
  27094. name: string;
  27095. shader: string;
  27096. };
  27097. }
  27098. declare module "babylonjs/Shaders/passCube.fragment" {
  27099. export var passCubePixelShader: {
  27100. name: string;
  27101. shader: string;
  27102. };
  27103. }
  27104. declare module "babylonjs/PostProcesses/passPostProcess" {
  27105. import { Nullable } from "babylonjs/types";
  27106. import { Camera } from "babylonjs/Cameras/camera";
  27107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  27108. import "Shaders/pass.fragment";
  27109. import "Shaders/passCube.fragment";
  27110. import { Engine } from "babylonjs/Engines/engine";
  27111. /**
  27112. * PassPostProcess which produces an output the same as it's input
  27113. */
  27114. export class PassPostProcess extends PostProcess {
  27115. /**
  27116. * Creates the PassPostProcess
  27117. * @param name The name of the effect.
  27118. * @param options The required width/height ratio to downsize to before computing the render pass.
  27119. * @param camera The camera to apply the render pass to.
  27120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27121. * @param engine The engine which the post process will be applied. (default: current engine)
  27122. * @param reusable If the post process can be reused on the same frame. (default: false)
  27123. * @param textureType The type of texture to be used when performing the post processing.
  27124. * @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)
  27125. */
  27126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27127. }
  27128. /**
  27129. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  27130. */
  27131. export class PassCubePostProcess extends PostProcess {
  27132. private _face;
  27133. /**
  27134. * Gets or sets the cube face to display.
  27135. * * 0 is +X
  27136. * * 1 is -X
  27137. * * 2 is +Y
  27138. * * 3 is -Y
  27139. * * 4 is +Z
  27140. * * 5 is -Z
  27141. */
  27142. face: number;
  27143. /**
  27144. * Creates the PassCubePostProcess
  27145. * @param name The name of the effect.
  27146. * @param options The required width/height ratio to downsize to before computing the render pass.
  27147. * @param camera The camera to apply the render pass to.
  27148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27149. * @param engine The engine which the post process will be applied. (default: current engine)
  27150. * @param reusable If the post process can be reused on the same frame. (default: false)
  27151. * @param textureType The type of texture to be used when performing the post processing.
  27152. * @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)
  27153. */
  27154. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27155. }
  27156. }
  27157. declare module "babylonjs/Shaders/anaglyph.fragment" {
  27158. export var anaglyphPixelShader: {
  27159. name: string;
  27160. shader: string;
  27161. };
  27162. }
  27163. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  27164. import { Engine } from "babylonjs/Engines/engine";
  27165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  27166. import { Camera } from "babylonjs/Cameras/camera";
  27167. import "Shaders/anaglyph.fragment";
  27168. /**
  27169. * Postprocess used to generate anaglyphic rendering
  27170. */
  27171. export class AnaglyphPostProcess extends PostProcess {
  27172. private _passedProcess;
  27173. /**
  27174. * Creates a new AnaglyphPostProcess
  27175. * @param name defines postprocess name
  27176. * @param options defines creation options or target ratio scale
  27177. * @param rigCameras defines cameras using this postprocess
  27178. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27179. * @param engine defines hosting engine
  27180. * @param reusable defines if the postprocess will be reused multiple times per frame
  27181. */
  27182. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27183. }
  27184. }
  27185. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  27186. export var stereoscopicInterlacePixelShader: {
  27187. name: string;
  27188. shader: string;
  27189. };
  27190. }
  27191. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  27192. import { Camera } from "babylonjs/Cameras/camera";
  27193. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27194. import { Engine } from "babylonjs/Engines/engine";
  27195. import "Shaders/stereoscopicInterlace.fragment";
  27196. /**
  27197. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  27198. */
  27199. export class StereoscopicInterlacePostProcess extends PostProcess {
  27200. private _stepSize;
  27201. private _passedProcess;
  27202. /**
  27203. * Initializes a StereoscopicInterlacePostProcess
  27204. * @param name The name of the effect.
  27205. * @param rigCameras The rig cameras to be appled to the post process
  27206. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  27207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27208. * @param engine The engine which the post process will be applied. (default: current engine)
  27209. * @param reusable If the post process can be reused on the same frame. (default: false)
  27210. */
  27211. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27212. }
  27213. }
  27214. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  27215. import { Matrix } from "babylonjs/Maths/math";
  27216. /**
  27217. * This represents all the required metrics to create a VR camera.
  27218. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  27219. */
  27220. export class VRCameraMetrics {
  27221. /**
  27222. * Define the horizontal resolution off the screen.
  27223. */
  27224. hResolution: number;
  27225. /**
  27226. * Define the vertical resolution off the screen.
  27227. */
  27228. vResolution: number;
  27229. /**
  27230. * Define the horizontal screen size.
  27231. */
  27232. hScreenSize: number;
  27233. /**
  27234. * Define the vertical screen size.
  27235. */
  27236. vScreenSize: number;
  27237. /**
  27238. * Define the vertical screen center position.
  27239. */
  27240. vScreenCenter: number;
  27241. /**
  27242. * Define the distance of the eyes to the screen.
  27243. */
  27244. eyeToScreenDistance: number;
  27245. /**
  27246. * Define the distance between both lenses
  27247. */
  27248. lensSeparationDistance: number;
  27249. /**
  27250. * Define the distance between both viewer's eyes.
  27251. */
  27252. interpupillaryDistance: number;
  27253. /**
  27254. * Define the distortion factor of the VR postprocess.
  27255. * Please, touch with care.
  27256. */
  27257. distortionK: number[];
  27258. /**
  27259. * Define the chromatic aberration correction factors for the VR post process.
  27260. */
  27261. chromaAbCorrection: number[];
  27262. /**
  27263. * Define the scale factor of the post process.
  27264. * The smaller the better but the slower.
  27265. */
  27266. postProcessScaleFactor: number;
  27267. /**
  27268. * Define an offset for the lens center.
  27269. */
  27270. lensCenterOffset: number;
  27271. /**
  27272. * Define if the current vr camera should compensate the distortion of the lense or not.
  27273. */
  27274. compensateDistortion: boolean;
  27275. /**
  27276. * Gets the rendering aspect ratio based on the provided resolutions.
  27277. */
  27278. readonly aspectRatio: number;
  27279. /**
  27280. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  27281. */
  27282. readonly aspectRatioFov: number;
  27283. /**
  27284. * @hidden
  27285. */
  27286. readonly leftHMatrix: Matrix;
  27287. /**
  27288. * @hidden
  27289. */
  27290. readonly rightHMatrix: Matrix;
  27291. /**
  27292. * @hidden
  27293. */
  27294. readonly leftPreViewMatrix: Matrix;
  27295. /**
  27296. * @hidden
  27297. */
  27298. readonly rightPreViewMatrix: Matrix;
  27299. /**
  27300. * Get the default VRMetrics based on the most generic setup.
  27301. * @returns the default vr metrics
  27302. */
  27303. static GetDefault(): VRCameraMetrics;
  27304. }
  27305. }
  27306. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  27307. export var vrDistortionCorrectionPixelShader: {
  27308. name: string;
  27309. shader: string;
  27310. };
  27311. }
  27312. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  27313. import { Camera } from "babylonjs/Cameras/camera";
  27314. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  27315. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27316. import "Shaders/vrDistortionCorrection.fragment";
  27317. /**
  27318. * VRDistortionCorrectionPostProcess used for mobile VR
  27319. */
  27320. export class VRDistortionCorrectionPostProcess extends PostProcess {
  27321. private _isRightEye;
  27322. private _distortionFactors;
  27323. private _postProcessScaleFactor;
  27324. private _lensCenterOffset;
  27325. private _scaleIn;
  27326. private _scaleFactor;
  27327. private _lensCenter;
  27328. /**
  27329. * Initializes the VRDistortionCorrectionPostProcess
  27330. * @param name The name of the effect.
  27331. * @param camera The camera to apply the render pass to.
  27332. * @param isRightEye If this is for the right eye distortion
  27333. * @param vrMetrics All the required metrics for the VR camera
  27334. */
  27335. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27336. }
  27337. }
  27338. declare module "babylonjs/Cameras/camera" {
  27339. import { SmartArray } from "babylonjs/Misc/smartArray";
  27340. import { Observable } from "babylonjs/Misc/observable";
  27341. import { Nullable } from "babylonjs/types";
  27342. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  27343. import { Scene } from "babylonjs/scene";
  27344. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  27345. import { Node } from "babylonjs/node";
  27346. import { Mesh } from "babylonjs/Meshes/mesh";
  27347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27348. import { Ray } from "babylonjs/Culling/ray";
  27349. import { ICullable } from "babylonjs/Culling/boundingInfo";
  27350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27351. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27352. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27353. /**
  27354. * This is the base class of all the camera used in the application.
  27355. * @see http://doc.babylonjs.com/features/cameras
  27356. */
  27357. export class Camera extends Node {
  27358. /** @hidden */
  27359. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  27360. /**
  27361. * This is the default projection mode used by the cameras.
  27362. * It helps recreating a feeling of perspective and better appreciate depth.
  27363. * This is the best way to simulate real life cameras.
  27364. */
  27365. static readonly PERSPECTIVE_CAMERA: number;
  27366. /**
  27367. * This helps creating camera with an orthographic mode.
  27368. * 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.
  27369. */
  27370. static readonly ORTHOGRAPHIC_CAMERA: number;
  27371. /**
  27372. * This is the default FOV mode for perspective cameras.
  27373. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  27374. */
  27375. static readonly FOVMODE_VERTICAL_FIXED: number;
  27376. /**
  27377. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  27378. */
  27379. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  27380. /**
  27381. * This specifies ther is no need for a camera rig.
  27382. * Basically only one eye is rendered corresponding to the camera.
  27383. */
  27384. static readonly RIG_MODE_NONE: number;
  27385. /**
  27386. * Simulates a camera Rig with one blue eye and one red eye.
  27387. * This can be use with 3d blue and red glasses.
  27388. */
  27389. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  27390. /**
  27391. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  27392. */
  27393. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  27394. /**
  27395. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  27396. */
  27397. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  27398. /**
  27399. * Defines that both eyes of the camera will be rendered over under each other.
  27400. */
  27401. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  27402. /**
  27403. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  27404. */
  27405. static readonly RIG_MODE_VR: number;
  27406. /**
  27407. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  27408. */
  27409. static readonly RIG_MODE_WEBVR: number;
  27410. /**
  27411. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  27412. */
  27413. static readonly RIG_MODE_CUSTOM: number;
  27414. /**
  27415. * Defines if by default attaching controls should prevent the default javascript event to continue.
  27416. */
  27417. static ForceAttachControlToAlwaysPreventDefault: boolean;
  27418. /**
  27419. * @hidden
  27420. * Might be removed once multiview will be a thing
  27421. */
  27422. static UseAlternateWebVRRendering: boolean;
  27423. /**
  27424. * Define the input manager associated with the camera.
  27425. */
  27426. inputs: CameraInputsManager<Camera>;
  27427. /**
  27428. * Define the current local position of the camera in the scene
  27429. */
  27430. position: Vector3;
  27431. /**
  27432. * The vector the camera should consider as up.
  27433. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  27434. */
  27435. upVector: Vector3;
  27436. /**
  27437. * Define the current limit on the left side for an orthographic camera
  27438. * In scene unit
  27439. */
  27440. orthoLeft: Nullable<number>;
  27441. /**
  27442. * Define the current limit on the right side for an orthographic camera
  27443. * In scene unit
  27444. */
  27445. orthoRight: Nullable<number>;
  27446. /**
  27447. * Define the current limit on the bottom side for an orthographic camera
  27448. * In scene unit
  27449. */
  27450. orthoBottom: Nullable<number>;
  27451. /**
  27452. * Define the current limit on the top side for an orthographic camera
  27453. * In scene unit
  27454. */
  27455. orthoTop: Nullable<number>;
  27456. /**
  27457. * Field Of View is set in Radians. (default is 0.8)
  27458. */
  27459. fov: number;
  27460. /**
  27461. * Define the minimum distance the camera can see from.
  27462. * This is important to note that the depth buffer are not infinite and the closer it starts
  27463. * the more your scene might encounter depth fighting issue.
  27464. */
  27465. minZ: number;
  27466. /**
  27467. * Define the maximum distance the camera can see to.
  27468. * This is important to note that the depth buffer are not infinite and the further it end
  27469. * the more your scene might encounter depth fighting issue.
  27470. */
  27471. maxZ: number;
  27472. /**
  27473. * Define the default inertia of the camera.
  27474. * This helps giving a smooth feeling to the camera movement.
  27475. */
  27476. inertia: number;
  27477. /**
  27478. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  27479. */
  27480. mode: number;
  27481. /**
  27482. * Define wether the camera is intermediate.
  27483. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  27484. */
  27485. isIntermediate: boolean;
  27486. /**
  27487. * Define the viewport of the camera.
  27488. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  27489. */
  27490. viewport: Viewport;
  27491. /**
  27492. * Restricts the camera to viewing objects with the same layerMask.
  27493. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  27494. */
  27495. layerMask: number;
  27496. /**
  27497. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  27498. */
  27499. fovMode: number;
  27500. /**
  27501. * Rig mode of the camera.
  27502. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  27503. * This is normally controlled byt the camera themselves as internal use.
  27504. */
  27505. cameraRigMode: number;
  27506. /**
  27507. * Defines the distance between both "eyes" in case of a RIG
  27508. */
  27509. interaxialDistance: number;
  27510. /**
  27511. * Defines if stereoscopic rendering is done side by side or over under.
  27512. */
  27513. isStereoscopicSideBySide: boolean;
  27514. /**
  27515. * 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
  27516. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  27517. * else in the scene.
  27518. */
  27519. customRenderTargets: RenderTargetTexture[];
  27520. /**
  27521. * When set, the camera will render to this render target instead of the default canvas
  27522. */
  27523. outputRenderTarget: Nullable<RenderTargetTexture>;
  27524. /**
  27525. * Observable triggered when the camera view matrix has changed.
  27526. */
  27527. onViewMatrixChangedObservable: Observable<Camera>;
  27528. /**
  27529. * Observable triggered when the camera Projection matrix has changed.
  27530. */
  27531. onProjectionMatrixChangedObservable: Observable<Camera>;
  27532. /**
  27533. * Observable triggered when the inputs have been processed.
  27534. */
  27535. onAfterCheckInputsObservable: Observable<Camera>;
  27536. /**
  27537. * Observable triggered when reset has been called and applied to the camera.
  27538. */
  27539. onRestoreStateObservable: Observable<Camera>;
  27540. /** @hidden */
  27541. _cameraRigParams: any;
  27542. /** @hidden */
  27543. _rigCameras: Camera[];
  27544. /** @hidden */
  27545. _rigPostProcess: Nullable<PostProcess>;
  27546. protected _webvrViewMatrix: Matrix;
  27547. /** @hidden */
  27548. _skipRendering: boolean;
  27549. /** @hidden */
  27550. _alternateCamera: Camera;
  27551. /** @hidden */
  27552. _projectionMatrix: Matrix;
  27553. /** @hidden */
  27554. _postProcesses: Nullable<PostProcess>[];
  27555. /** @hidden */
  27556. _activeMeshes: SmartArray<AbstractMesh>;
  27557. protected _globalPosition: Vector3;
  27558. /** hidden */
  27559. _computedViewMatrix: Matrix;
  27560. private _doNotComputeProjectionMatrix;
  27561. private _transformMatrix;
  27562. private _frustumPlanes;
  27563. private _refreshFrustumPlanes;
  27564. private _storedFov;
  27565. private _stateStored;
  27566. /**
  27567. * Instantiates a new camera object.
  27568. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  27569. * @see http://doc.babylonjs.com/features/cameras
  27570. * @param name Defines the name of the camera in the scene
  27571. * @param position Defines the position of the camera
  27572. * @param scene Defines the scene the camera belongs too
  27573. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  27574. */
  27575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  27576. /**
  27577. * Store current camera state (fov, position, etc..)
  27578. * @returns the camera
  27579. */
  27580. storeState(): Camera;
  27581. /**
  27582. * Restores the camera state values if it has been stored. You must call storeState() first
  27583. */
  27584. protected _restoreStateValues(): boolean;
  27585. /**
  27586. * Restored camera state. You must call storeState() first.
  27587. * @returns true if restored and false otherwise
  27588. */
  27589. restoreState(): boolean;
  27590. /**
  27591. * Gets the class name of the camera.
  27592. * @returns the class name
  27593. */
  27594. getClassName(): string;
  27595. /** @hidden */
  27596. readonly _isCamera: boolean;
  27597. /**
  27598. * Gets a string representation of the camera useful for debug purpose.
  27599. * @param fullDetails Defines that a more verboe level of logging is required
  27600. * @returns the string representation
  27601. */
  27602. toString(fullDetails?: boolean): string;
  27603. /**
  27604. * Gets the current world space position of the camera.
  27605. */
  27606. readonly globalPosition: Vector3;
  27607. /**
  27608. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  27609. * @returns the active meshe list
  27610. */
  27611. getActiveMeshes(): SmartArray<AbstractMesh>;
  27612. /**
  27613. * Check wether a mesh is part of the current active mesh list of the camera
  27614. * @param mesh Defines the mesh to check
  27615. * @returns true if active, false otherwise
  27616. */
  27617. isActiveMesh(mesh: Mesh): boolean;
  27618. /**
  27619. * Is this camera ready to be used/rendered
  27620. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  27621. * @return true if the camera is ready
  27622. */
  27623. isReady(completeCheck?: boolean): boolean;
  27624. /** @hidden */
  27625. _initCache(): void;
  27626. /** @hidden */
  27627. _updateCache(ignoreParentClass?: boolean): void;
  27628. /** @hidden */
  27629. _isSynchronized(): boolean;
  27630. /** @hidden */
  27631. _isSynchronizedViewMatrix(): boolean;
  27632. /** @hidden */
  27633. _isSynchronizedProjectionMatrix(): boolean;
  27634. /**
  27635. * Attach the input controls to a specific dom element to get the input from.
  27636. * @param element Defines the element the controls should be listened from
  27637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  27638. */
  27639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27640. /**
  27641. * Detach the current controls from the specified dom element.
  27642. * @param element Defines the element to stop listening the inputs from
  27643. */
  27644. detachControl(element: HTMLElement): void;
  27645. /**
  27646. * Update the camera state according to the different inputs gathered during the frame.
  27647. */
  27648. update(): void;
  27649. /** @hidden */
  27650. _checkInputs(): void;
  27651. /** @hidden */
  27652. readonly rigCameras: Camera[];
  27653. /**
  27654. * Gets the post process used by the rig cameras
  27655. */
  27656. readonly rigPostProcess: Nullable<PostProcess>;
  27657. /**
  27658. * Internal, gets the first post proces.
  27659. * @returns the first post process to be run on this camera.
  27660. */
  27661. _getFirstPostProcess(): Nullable<PostProcess>;
  27662. private _cascadePostProcessesToRigCams;
  27663. /**
  27664. * Attach a post process to the camera.
  27665. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  27666. * @param postProcess The post process to attach to the camera
  27667. * @param insertAt The position of the post process in case several of them are in use in the scene
  27668. * @returns the position the post process has been inserted at
  27669. */
  27670. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  27671. /**
  27672. * Detach a post process to the camera.
  27673. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  27674. * @param postProcess The post process to detach from the camera
  27675. */
  27676. detachPostProcess(postProcess: PostProcess): void;
  27677. /**
  27678. * Gets the current world matrix of the camera
  27679. */
  27680. getWorldMatrix(): Matrix;
  27681. /** @hidden */
  27682. protected _getViewMatrix(): Matrix;
  27683. /**
  27684. * Gets the current view matrix of the camera.
  27685. * @param force forces the camera to recompute the matrix without looking at the cached state
  27686. * @returns the view matrix
  27687. */
  27688. getViewMatrix(force?: boolean): Matrix;
  27689. /**
  27690. * Freeze the projection matrix.
  27691. * It will prevent the cache check of the camera projection compute and can speed up perf
  27692. * if no parameter of the camera are meant to change
  27693. * @param projection Defines manually a projection if necessary
  27694. */
  27695. freezeProjectionMatrix(projection?: Matrix): void;
  27696. /**
  27697. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  27698. */
  27699. unfreezeProjectionMatrix(): void;
  27700. /**
  27701. * Gets the current projection matrix of the camera.
  27702. * @param force forces the camera to recompute the matrix without looking at the cached state
  27703. * @returns the projection matrix
  27704. */
  27705. getProjectionMatrix(force?: boolean): Matrix;
  27706. /**
  27707. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  27708. * @returns a Matrix
  27709. */
  27710. getTransformationMatrix(): Matrix;
  27711. private _updateFrustumPlanes;
  27712. /**
  27713. * Checks if a cullable object (mesh...) is in the camera frustum
  27714. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  27715. * @param target The object to check
  27716. * @returns true if the object is in frustum otherwise false
  27717. */
  27718. isInFrustum(target: ICullable): boolean;
  27719. /**
  27720. * Checks if a cullable object (mesh...) is in the camera frustum
  27721. * Unlike isInFrustum this cheks the full bounding box
  27722. * @param target The object to check
  27723. * @returns true if the object is in frustum otherwise false
  27724. */
  27725. isCompletelyInFrustum(target: ICullable): boolean;
  27726. /**
  27727. * Gets a ray in the forward direction from the camera.
  27728. * @param length Defines the length of the ray to create
  27729. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  27730. * @param origin Defines the start point of the ray which defaults to the camera position
  27731. * @returns the forward ray
  27732. */
  27733. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  27734. /**
  27735. * Releases resources associated with this node.
  27736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27738. */
  27739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27740. /**
  27741. * Gets the left camera of a rig setup in case of Rigged Camera
  27742. */
  27743. readonly leftCamera: Nullable<FreeCamera>;
  27744. /**
  27745. * Gets the right camera of a rig setup in case of Rigged Camera
  27746. */
  27747. readonly rightCamera: Nullable<FreeCamera>;
  27748. /**
  27749. * Gets the left camera target of a rig setup in case of Rigged Camera
  27750. * @returns the target position
  27751. */
  27752. getLeftTarget(): Nullable<Vector3>;
  27753. /**
  27754. * Gets the right camera target of a rig setup in case of Rigged Camera
  27755. * @returns the target position
  27756. */
  27757. getRightTarget(): Nullable<Vector3>;
  27758. /**
  27759. * @hidden
  27760. */
  27761. setCameraRigMode(mode: number, rigParams: any): void;
  27762. private _getVRProjectionMatrix;
  27763. protected _updateCameraRotationMatrix(): void;
  27764. protected _updateWebVRCameraRotationMatrix(): void;
  27765. /**
  27766. * This function MUST be overwritten by the different WebVR cameras available.
  27767. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27768. */
  27769. protected _getWebVRProjectionMatrix(): Matrix;
  27770. /**
  27771. * This function MUST be overwritten by the different WebVR cameras available.
  27772. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27773. */
  27774. protected _getWebVRViewMatrix(): Matrix;
  27775. /** @hidden */
  27776. setCameraRigParameter(name: string, value: any): void;
  27777. /**
  27778. * needs to be overridden by children so sub has required properties to be copied
  27779. * @hidden
  27780. */
  27781. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27782. /**
  27783. * May need to be overridden by children
  27784. * @hidden
  27785. */
  27786. _updateRigCameras(): void;
  27787. /** @hidden */
  27788. _setupInputs(): void;
  27789. /**
  27790. * Serialiaze the camera setup to a json represention
  27791. * @returns the JSON representation
  27792. */
  27793. serialize(): any;
  27794. /**
  27795. * Clones the current camera.
  27796. * @param name The cloned camera name
  27797. * @returns the cloned camera
  27798. */
  27799. clone(name: string): Camera;
  27800. /**
  27801. * Gets the direction of the camera relative to a given local axis.
  27802. * @param localAxis Defines the reference axis to provide a relative direction.
  27803. * @return the direction
  27804. */
  27805. getDirection(localAxis: Vector3): Vector3;
  27806. /**
  27807. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27808. * @param localAxis Defines the reference axis to provide a relative direction.
  27809. * @param result Defines the vector to store the result in
  27810. */
  27811. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27812. /**
  27813. * Gets a camera constructor for a given camera type
  27814. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27815. * @param name The name of the camera the result will be able to instantiate
  27816. * @param scene The scene the result will construct the camera in
  27817. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27818. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27819. * @returns a factory method to construc the camera
  27820. */
  27821. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27822. /**
  27823. * Compute the world matrix of the camera.
  27824. * @returns the camera workd matrix
  27825. */
  27826. computeWorldMatrix(): Matrix;
  27827. /**
  27828. * Parse a JSON and creates the camera from the parsed information
  27829. * @param parsedCamera The JSON to parse
  27830. * @param scene The scene to instantiate the camera in
  27831. * @returns the newly constructed camera
  27832. */
  27833. static Parse(parsedCamera: any, scene: Scene): Camera;
  27834. }
  27835. }
  27836. declare module "babylonjs/Materials/fresnelParameters" {
  27837. import { Color3 } from "babylonjs/Maths/math";
  27838. /**
  27839. * This represents all the required information to add a fresnel effect on a material:
  27840. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27841. */
  27842. export class FresnelParameters {
  27843. private _isEnabled;
  27844. /**
  27845. * Define if the fresnel effect is enable or not.
  27846. */
  27847. isEnabled: boolean;
  27848. /**
  27849. * Define the color used on edges (grazing angle)
  27850. */
  27851. leftColor: Color3;
  27852. /**
  27853. * Define the color used on center
  27854. */
  27855. rightColor: Color3;
  27856. /**
  27857. * Define bias applied to computed fresnel term
  27858. */
  27859. bias: number;
  27860. /**
  27861. * Defined the power exponent applied to fresnel term
  27862. */
  27863. power: number;
  27864. /**
  27865. * Clones the current fresnel and its valuues
  27866. * @returns a clone fresnel configuration
  27867. */
  27868. clone(): FresnelParameters;
  27869. /**
  27870. * Serializes the current fresnel parameters to a JSON representation.
  27871. * @return the JSON serialization
  27872. */
  27873. serialize(): any;
  27874. /**
  27875. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27876. * @param parsedFresnelParameters Define the JSON representation
  27877. * @returns the parsed parameters
  27878. */
  27879. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27880. }
  27881. }
  27882. declare module "babylonjs/Misc/decorators" {
  27883. import { Nullable } from "babylonjs/types";
  27884. import { Scene } from "babylonjs/scene";
  27885. import { IAnimatable } from "babylonjs/Misc/tools";
  27886. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27887. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27888. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27889. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27890. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27891. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27892. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27893. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27894. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27895. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27896. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27897. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27898. /**
  27899. * Decorator used to define property that can be serialized as reference to a camera
  27900. * @param sourceName defines the name of the property to decorate
  27901. */
  27902. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27903. /**
  27904. * Class used to help serialization objects
  27905. */
  27906. export class SerializationHelper {
  27907. /** hidden */
  27908. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  27909. /** hidden */
  27910. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  27911. /** hidden */
  27912. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  27913. /** hidden */
  27914. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  27915. /**
  27916. * Appends the serialized animations from the source animations
  27917. * @param source Source containing the animations
  27918. * @param destination Target to store the animations
  27919. */
  27920. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27921. /**
  27922. * Static function used to serialized a specific entity
  27923. * @param entity defines the entity to serialize
  27924. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27925. * @returns a JSON compatible object representing the serialization of the entity
  27926. */
  27927. static Serialize<T>(entity: T, serializationObject?: any): any;
  27928. /**
  27929. * Creates a new entity from a serialization data object
  27930. * @param creationFunction defines a function used to instanciated the new entity
  27931. * @param source defines the source serialization data
  27932. * @param scene defines the hosting scene
  27933. * @param rootUrl defines the root url for resources
  27934. * @returns a new entity
  27935. */
  27936. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27937. /**
  27938. * Clones an object
  27939. * @param creationFunction defines the function used to instanciate the new object
  27940. * @param source defines the source object
  27941. * @returns the cloned object
  27942. */
  27943. static Clone<T>(creationFunction: () => T, source: T): T;
  27944. /**
  27945. * Instanciates a new object based on a source one (some data will be shared between both object)
  27946. * @param creationFunction defines the function used to instanciate the new object
  27947. * @param source defines the source object
  27948. * @returns the new object
  27949. */
  27950. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27951. }
  27952. }
  27953. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  27954. import { Nullable } from "babylonjs/types";
  27955. /**
  27956. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27957. */
  27958. export interface CubeMapInfo {
  27959. /**
  27960. * The pixel array for the front face.
  27961. * This is stored in format, left to right, up to down format.
  27962. */
  27963. front: Nullable<ArrayBufferView>;
  27964. /**
  27965. * The pixel array for the back face.
  27966. * This is stored in format, left to right, up to down format.
  27967. */
  27968. back: Nullable<ArrayBufferView>;
  27969. /**
  27970. * The pixel array for the left face.
  27971. * This is stored in format, left to right, up to down format.
  27972. */
  27973. left: Nullable<ArrayBufferView>;
  27974. /**
  27975. * The pixel array for the right face.
  27976. * This is stored in format, left to right, up to down format.
  27977. */
  27978. right: Nullable<ArrayBufferView>;
  27979. /**
  27980. * The pixel array for the up face.
  27981. * This is stored in format, left to right, up to down format.
  27982. */
  27983. up: Nullable<ArrayBufferView>;
  27984. /**
  27985. * The pixel array for the down face.
  27986. * This is stored in format, left to right, up to down format.
  27987. */
  27988. down: Nullable<ArrayBufferView>;
  27989. /**
  27990. * The size of the cubemap stored.
  27991. *
  27992. * Each faces will be size * size pixels.
  27993. */
  27994. size: number;
  27995. /**
  27996. * The format of the texture.
  27997. *
  27998. * RGBA, RGB.
  27999. */
  28000. format: number;
  28001. /**
  28002. * The type of the texture data.
  28003. *
  28004. * UNSIGNED_INT, FLOAT.
  28005. */
  28006. type: number;
  28007. /**
  28008. * Specifies whether the texture is in gamma space.
  28009. */
  28010. gammaSpace: boolean;
  28011. }
  28012. /**
  28013. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28014. */
  28015. export class PanoramaToCubeMapTools {
  28016. private static FACE_FRONT;
  28017. private static FACE_BACK;
  28018. private static FACE_RIGHT;
  28019. private static FACE_LEFT;
  28020. private static FACE_DOWN;
  28021. private static FACE_UP;
  28022. /**
  28023. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28024. *
  28025. * @param float32Array The source data.
  28026. * @param inputWidth The width of the input panorama.
  28027. * @param inputHeight The height of the input panorama.
  28028. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28029. * @return The cubemap data
  28030. */
  28031. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28032. private static CreateCubemapTexture;
  28033. private static CalcProjectionSpherical;
  28034. }
  28035. }
  28036. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28037. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28038. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28039. import { Nullable } from "babylonjs/types";
  28040. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28041. /**
  28042. * Helper class dealing with the extraction of spherical polynomial dataArray
  28043. * from a cube map.
  28044. */
  28045. export class CubeMapToSphericalPolynomialTools {
  28046. private static FileFaces;
  28047. /**
  28048. * Converts a texture to the according Spherical Polynomial data.
  28049. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28050. *
  28051. * @param texture The texture to extract the information from.
  28052. * @return The Spherical Polynomial data.
  28053. */
  28054. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28055. /**
  28056. * Converts a cubemap to the according Spherical Polynomial data.
  28057. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28058. *
  28059. * @param cubeInfo The Cube map to extract the information from.
  28060. * @return The Spherical Polynomial data.
  28061. */
  28062. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28063. }
  28064. }
  28065. declare module "babylonjs/Materials/Textures/baseTexture" {
  28066. import { Observable } from "babylonjs/Misc/observable";
  28067. import { IAnimatable } from "babylonjs/Misc/tools";
  28068. import { Nullable } from "babylonjs/types";
  28069. import { Scene } from "babylonjs/scene";
  28070. import { Matrix, ISize } from "babylonjs/Maths/math";
  28071. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28072. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28073. /**
  28074. * Base class of all the textures in babylon.
  28075. * It groups all the common properties the materials, post process, lights... might need
  28076. * in order to make a correct use of the texture.
  28077. */
  28078. export class BaseTexture implements IAnimatable {
  28079. /**
  28080. * Default anisotropic filtering level for the application.
  28081. * It is set to 4 as a good tradeoff between perf and quality.
  28082. */
  28083. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28084. /**
  28085. * Gets or sets the unique id of the texture
  28086. */
  28087. uniqueId: number;
  28088. /**
  28089. * Define the name of the texture.
  28090. */
  28091. name: string;
  28092. /**
  28093. * Gets or sets an object used to store user defined information.
  28094. */
  28095. metadata: any;
  28096. private _hasAlpha;
  28097. /**
  28098. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28099. */
  28100. hasAlpha: boolean;
  28101. /**
  28102. * Defines if the alpha value should be determined via the rgb values.
  28103. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28104. */
  28105. getAlphaFromRGB: boolean;
  28106. /**
  28107. * Intensity or strength of the texture.
  28108. * It is commonly used by materials to fine tune the intensity of the texture
  28109. */
  28110. level: number;
  28111. /**
  28112. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28113. * This is part of the texture as textures usually maps to one uv set.
  28114. */
  28115. coordinatesIndex: number;
  28116. private _coordinatesMode;
  28117. /**
  28118. * How a texture is mapped.
  28119. *
  28120. * | Value | Type | Description |
  28121. * | ----- | ----------------------------------- | ----------- |
  28122. * | 0 | EXPLICIT_MODE | |
  28123. * | 1 | SPHERICAL_MODE | |
  28124. * | 2 | PLANAR_MODE | |
  28125. * | 3 | CUBIC_MODE | |
  28126. * | 4 | PROJECTION_MODE | |
  28127. * | 5 | SKYBOX_MODE | |
  28128. * | 6 | INVCUBIC_MODE | |
  28129. * | 7 | EQUIRECTANGULAR_MODE | |
  28130. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28131. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28132. */
  28133. coordinatesMode: number;
  28134. /**
  28135. * | Value | Type | Description |
  28136. * | ----- | ------------------ | ----------- |
  28137. * | 0 | CLAMP_ADDRESSMODE | |
  28138. * | 1 | WRAP_ADDRESSMODE | |
  28139. * | 2 | MIRROR_ADDRESSMODE | |
  28140. */
  28141. wrapU: number;
  28142. /**
  28143. * | Value | Type | Description |
  28144. * | ----- | ------------------ | ----------- |
  28145. * | 0 | CLAMP_ADDRESSMODE | |
  28146. * | 1 | WRAP_ADDRESSMODE | |
  28147. * | 2 | MIRROR_ADDRESSMODE | |
  28148. */
  28149. wrapV: number;
  28150. /**
  28151. * | Value | Type | Description |
  28152. * | ----- | ------------------ | ----------- |
  28153. * | 0 | CLAMP_ADDRESSMODE | |
  28154. * | 1 | WRAP_ADDRESSMODE | |
  28155. * | 2 | MIRROR_ADDRESSMODE | |
  28156. */
  28157. wrapR: number;
  28158. /**
  28159. * With compliant hardware and browser (supporting anisotropic filtering)
  28160. * this defines the level of anisotropic filtering in the texture.
  28161. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28162. */
  28163. anisotropicFilteringLevel: number;
  28164. /**
  28165. * Define if the texture is a cube texture or if false a 2d texture.
  28166. */
  28167. isCube: boolean;
  28168. /**
  28169. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28170. */
  28171. is3D: boolean;
  28172. /**
  28173. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28174. * HDR texture are usually stored in linear space.
  28175. * This only impacts the PBR and Background materials
  28176. */
  28177. gammaSpace: boolean;
  28178. /**
  28179. * Gets whether or not the texture contains RGBD data.
  28180. */
  28181. readonly isRGBD: boolean;
  28182. /**
  28183. * Is Z inverted in the texture (useful in a cube texture).
  28184. */
  28185. invertZ: boolean;
  28186. /**
  28187. * Are mip maps generated for this texture or not.
  28188. */
  28189. readonly noMipmap: boolean;
  28190. /**
  28191. * @hidden
  28192. */
  28193. lodLevelInAlpha: boolean;
  28194. /**
  28195. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28196. */
  28197. lodGenerationOffset: number;
  28198. /**
  28199. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28200. */
  28201. lodGenerationScale: number;
  28202. /**
  28203. * Define if the texture is a render target.
  28204. */
  28205. isRenderTarget: boolean;
  28206. /**
  28207. * Define the unique id of the texture in the scene.
  28208. */
  28209. readonly uid: string;
  28210. /**
  28211. * Return a string representation of the texture.
  28212. * @returns the texture as a string
  28213. */
  28214. toString(): string;
  28215. /**
  28216. * Get the class name of the texture.
  28217. * @returns "BaseTexture"
  28218. */
  28219. getClassName(): string;
  28220. /**
  28221. * Define the list of animation attached to the texture.
  28222. */
  28223. animations: import("babylonjs/Animations/animation").Animation[];
  28224. /**
  28225. * An event triggered when the texture is disposed.
  28226. */
  28227. onDisposeObservable: Observable<BaseTexture>;
  28228. private _onDisposeObserver;
  28229. /**
  28230. * Callback triggered when the texture has been disposed.
  28231. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28232. */
  28233. onDispose: () => void;
  28234. /**
  28235. * Define the current state of the loading sequence when in delayed load mode.
  28236. */
  28237. delayLoadState: number;
  28238. private _scene;
  28239. /** @hidden */
  28240. _samplingMode: number;
  28241. /** @hidden */
  28242. _texture: Nullable<InternalTexture>;
  28243. private _uid;
  28244. /**
  28245. * Define if the texture is preventinga material to render or not.
  28246. * If not and the texture is not ready, the engine will use a default black texture instead.
  28247. */
  28248. readonly isBlocking: boolean;
  28249. /**
  28250. * Instantiates a new BaseTexture.
  28251. * Base class of all the textures in babylon.
  28252. * It groups all the common properties the materials, post process, lights... might need
  28253. * in order to make a correct use of the texture.
  28254. * @param scene Define the scene the texture blongs to
  28255. */
  28256. constructor(scene: Nullable<Scene>);
  28257. /**
  28258. * Get the scene the texture belongs to.
  28259. * @returns the scene or null if undefined
  28260. */
  28261. getScene(): Nullable<Scene>;
  28262. /**
  28263. * Get the texture transform matrix used to offset tile the texture for istance.
  28264. * @returns the transformation matrix
  28265. */
  28266. getTextureMatrix(): Matrix;
  28267. /**
  28268. * Get the texture reflection matrix used to rotate/transform the reflection.
  28269. * @returns the reflection matrix
  28270. */
  28271. getReflectionTextureMatrix(): Matrix;
  28272. /**
  28273. * Get the underlying lower level texture from Babylon.
  28274. * @returns the insternal texture
  28275. */
  28276. getInternalTexture(): Nullable<InternalTexture>;
  28277. /**
  28278. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28279. * @returns true if ready or not blocking
  28280. */
  28281. isReadyOrNotBlocking(): boolean;
  28282. /**
  28283. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28284. * @returns true if fully ready
  28285. */
  28286. isReady(): boolean;
  28287. private _cachedSize;
  28288. /**
  28289. * Get the size of the texture.
  28290. * @returns the texture size.
  28291. */
  28292. getSize(): ISize;
  28293. /**
  28294. * Get the base size of the texture.
  28295. * It can be different from the size if the texture has been resized for POT for instance
  28296. * @returns the base size
  28297. */
  28298. getBaseSize(): ISize;
  28299. /**
  28300. * Update the sampling mode of the texture.
  28301. * Default is Trilinear mode.
  28302. *
  28303. * | Value | Type | Description |
  28304. * | ----- | ------------------ | ----------- |
  28305. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28306. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28307. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28308. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28309. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28310. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28311. * | 7 | NEAREST_LINEAR | |
  28312. * | 8 | NEAREST_NEAREST | |
  28313. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28314. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28315. * | 11 | LINEAR_LINEAR | |
  28316. * | 12 | LINEAR_NEAREST | |
  28317. *
  28318. * > _mag_: magnification filter (close to the viewer)
  28319. * > _min_: minification filter (far from the viewer)
  28320. * > _mip_: filter used between mip map levels
  28321. *@param samplingMode Define the new sampling mode of the texture
  28322. */
  28323. updateSamplingMode(samplingMode: number): void;
  28324. /**
  28325. * Scales the texture if is `canRescale()`
  28326. * @param ratio the resize factor we want to use to rescale
  28327. */
  28328. scale(ratio: number): void;
  28329. /**
  28330. * Get if the texture can rescale.
  28331. */
  28332. readonly canRescale: boolean;
  28333. /** @hidden */
  28334. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  28335. /** @hidden */
  28336. _rebuild(): void;
  28337. /**
  28338. * Triggers the load sequence in delayed load mode.
  28339. */
  28340. delayLoad(): void;
  28341. /**
  28342. * Clones the texture.
  28343. * @returns the cloned texture
  28344. */
  28345. clone(): Nullable<BaseTexture>;
  28346. /**
  28347. * Get the texture underlying type (INT, FLOAT...)
  28348. */
  28349. readonly textureType: number;
  28350. /**
  28351. * Get the texture underlying format (RGB, RGBA...)
  28352. */
  28353. readonly textureFormat: number;
  28354. /**
  28355. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28356. * This will returns an RGBA array buffer containing either in values (0-255) or
  28357. * float values (0-1) depending of the underlying buffer type.
  28358. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28359. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28360. * @param buffer defines a user defined buffer to fill with data (can be null)
  28361. * @returns The Array buffer containing the pixels data.
  28362. */
  28363. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28364. /**
  28365. * Release and destroy the underlying lower level texture aka internalTexture.
  28366. */
  28367. releaseInternalTexture(): void;
  28368. /**
  28369. * Get the polynomial representation of the texture data.
  28370. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28371. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28372. */
  28373. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28374. /** @hidden */
  28375. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28376. /** @hidden */
  28377. readonly _lodTextureMid: Nullable<BaseTexture>;
  28378. /** @hidden */
  28379. readonly _lodTextureLow: Nullable<BaseTexture>;
  28380. /**
  28381. * Dispose the texture and release its associated resources.
  28382. */
  28383. dispose(): void;
  28384. /**
  28385. * Serialize the texture into a JSON representation that can be parsed later on.
  28386. * @returns the JSON representation of the texture
  28387. */
  28388. serialize(): any;
  28389. /**
  28390. * Helper function to be called back once a list of texture contains only ready textures.
  28391. * @param textures Define the list of textures to wait for
  28392. * @param callback Define the callback triggered once the entire list will be ready
  28393. */
  28394. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28395. }
  28396. }
  28397. declare module "babylonjs/Materials/Textures/internalTexture" {
  28398. import { Observable } from "babylonjs/Misc/observable";
  28399. import { Nullable, int } from "babylonjs/types";
  28400. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28401. import { Engine } from "babylonjs/Engines/engine";
  28402. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  28403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28404. /**
  28405. * Class used to store data associated with WebGL texture data for the engine
  28406. * This class should not be used directly
  28407. */
  28408. export class InternalTexture implements IInternalTextureTracker {
  28409. /** hidden */
  28410. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28411. /**
  28412. * The source of the texture data is unknown
  28413. */
  28414. static DATASOURCE_UNKNOWN: number;
  28415. /**
  28416. * Texture data comes from an URL
  28417. */
  28418. static DATASOURCE_URL: number;
  28419. /**
  28420. * Texture data is only used for temporary storage
  28421. */
  28422. static DATASOURCE_TEMP: number;
  28423. /**
  28424. * Texture data comes from raw data (ArrayBuffer)
  28425. */
  28426. static DATASOURCE_RAW: number;
  28427. /**
  28428. * Texture content is dynamic (video or dynamic texture)
  28429. */
  28430. static DATASOURCE_DYNAMIC: number;
  28431. /**
  28432. * Texture content is generated by rendering to it
  28433. */
  28434. static DATASOURCE_RENDERTARGET: number;
  28435. /**
  28436. * Texture content is part of a multi render target process
  28437. */
  28438. static DATASOURCE_MULTIRENDERTARGET: number;
  28439. /**
  28440. * Texture data comes from a cube data file
  28441. */
  28442. static DATASOURCE_CUBE: number;
  28443. /**
  28444. * Texture data comes from a raw cube data
  28445. */
  28446. static DATASOURCE_CUBERAW: number;
  28447. /**
  28448. * Texture data come from a prefiltered cube data file
  28449. */
  28450. static DATASOURCE_CUBEPREFILTERED: number;
  28451. /**
  28452. * Texture content is raw 3D data
  28453. */
  28454. static DATASOURCE_RAW3D: number;
  28455. /**
  28456. * Texture content is a depth texture
  28457. */
  28458. static DATASOURCE_DEPTHTEXTURE: number;
  28459. /**
  28460. * Texture data comes from a raw cube data encoded with RGBD
  28461. */
  28462. static DATASOURCE_CUBERAW_RGBD: number;
  28463. /**
  28464. * Defines if the texture is ready
  28465. */
  28466. isReady: boolean;
  28467. /**
  28468. * Defines if the texture is a cube texture
  28469. */
  28470. isCube: boolean;
  28471. /**
  28472. * Defines if the texture contains 3D data
  28473. */
  28474. is3D: boolean;
  28475. /**
  28476. * Gets the URL used to load this texture
  28477. */
  28478. url: string;
  28479. /**
  28480. * Gets the sampling mode of the texture
  28481. */
  28482. samplingMode: number;
  28483. /**
  28484. * Gets a boolean indicating if the texture needs mipmaps generation
  28485. */
  28486. generateMipMaps: boolean;
  28487. /**
  28488. * Gets the number of samples used by the texture (WebGL2+ only)
  28489. */
  28490. samples: number;
  28491. /**
  28492. * Gets the type of the texture (int, float...)
  28493. */
  28494. type: number;
  28495. /**
  28496. * Gets the format of the texture (RGB, RGBA...)
  28497. */
  28498. format: number;
  28499. /**
  28500. * Observable called when the texture is loaded
  28501. */
  28502. onLoadedObservable: Observable<InternalTexture>;
  28503. /**
  28504. * Gets the width of the texture
  28505. */
  28506. width: number;
  28507. /**
  28508. * Gets the height of the texture
  28509. */
  28510. height: number;
  28511. /**
  28512. * Gets the depth of the texture
  28513. */
  28514. depth: number;
  28515. /**
  28516. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28517. */
  28518. baseWidth: number;
  28519. /**
  28520. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28521. */
  28522. baseHeight: number;
  28523. /**
  28524. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28525. */
  28526. baseDepth: number;
  28527. /**
  28528. * Gets a boolean indicating if the texture is inverted on Y axis
  28529. */
  28530. invertY: boolean;
  28531. /**
  28532. * Gets or set the previous tracker in the list
  28533. */
  28534. previous: Nullable<IInternalTextureTracker>;
  28535. /**
  28536. * Gets or set the next tracker in the list
  28537. */
  28538. next: Nullable<IInternalTextureTracker>;
  28539. /** @hidden */
  28540. _initialSlot: number;
  28541. /** @hidden */
  28542. _designatedSlot: number;
  28543. /** @hidden */
  28544. _dataSource: number;
  28545. /** @hidden */
  28546. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28547. /** @hidden */
  28548. _bufferView: Nullable<ArrayBufferView>;
  28549. /** @hidden */
  28550. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28551. /** @hidden */
  28552. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28553. /** @hidden */
  28554. _size: number;
  28555. /** @hidden */
  28556. _extension: string;
  28557. /** @hidden */
  28558. _files: Nullable<string[]>;
  28559. /** @hidden */
  28560. _workingCanvas: HTMLCanvasElement;
  28561. /** @hidden */
  28562. _workingContext: CanvasRenderingContext2D;
  28563. /** @hidden */
  28564. _framebuffer: Nullable<WebGLFramebuffer>;
  28565. /** @hidden */
  28566. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28567. /** @hidden */
  28568. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28569. /** @hidden */
  28570. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28571. /** @hidden */
  28572. _attachments: Nullable<number[]>;
  28573. /** @hidden */
  28574. _cachedCoordinatesMode: Nullable<number>;
  28575. /** @hidden */
  28576. _cachedWrapU: Nullable<number>;
  28577. /** @hidden */
  28578. _cachedWrapV: Nullable<number>;
  28579. /** @hidden */
  28580. _cachedWrapR: Nullable<number>;
  28581. /** @hidden */
  28582. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28583. /** @hidden */
  28584. _isDisabled: boolean;
  28585. /** @hidden */
  28586. _compression: Nullable<string>;
  28587. /** @hidden */
  28588. _generateStencilBuffer: boolean;
  28589. /** @hidden */
  28590. _generateDepthBuffer: boolean;
  28591. /** @hidden */
  28592. _comparisonFunction: number;
  28593. /** @hidden */
  28594. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28595. /** @hidden */
  28596. _lodGenerationScale: number;
  28597. /** @hidden */
  28598. _lodGenerationOffset: number;
  28599. /** @hidden */
  28600. _lodTextureHigh: BaseTexture;
  28601. /** @hidden */
  28602. _lodTextureMid: BaseTexture;
  28603. /** @hidden */
  28604. _lodTextureLow: BaseTexture;
  28605. /** @hidden */
  28606. _isRGBD: boolean;
  28607. /** @hidden */
  28608. _webGLTexture: Nullable<WebGLTexture>;
  28609. /** @hidden */
  28610. _references: number;
  28611. private _engine;
  28612. /**
  28613. * Gets the Engine the texture belongs to.
  28614. * @returns The babylon engine
  28615. */
  28616. getEngine(): Engine;
  28617. /**
  28618. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28619. */
  28620. readonly dataSource: number;
  28621. /**
  28622. * Creates a new InternalTexture
  28623. * @param engine defines the engine to use
  28624. * @param dataSource defines the type of data that will be used
  28625. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28626. */
  28627. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28628. /**
  28629. * Increments the number of references (ie. the number of Texture that point to it)
  28630. */
  28631. incrementReferences(): void;
  28632. /**
  28633. * Change the size of the texture (not the size of the content)
  28634. * @param width defines the new width
  28635. * @param height defines the new height
  28636. * @param depth defines the new depth (1 by default)
  28637. */
  28638. updateSize(width: int, height: int, depth?: int): void;
  28639. /** @hidden */
  28640. _rebuild(): void;
  28641. /** @hidden */
  28642. _swapAndDie(target: InternalTexture): void;
  28643. /**
  28644. * Dispose the current allocated resources
  28645. */
  28646. dispose(): void;
  28647. }
  28648. }
  28649. declare module "babylonjs/Misc/dds" {
  28650. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28652. import { Engine } from "babylonjs/Engines/engine";
  28653. /**
  28654. * Direct draw surface info
  28655. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  28656. */
  28657. export interface DDSInfo {
  28658. /**
  28659. * Width of the texture
  28660. */
  28661. width: number;
  28662. /**
  28663. * Width of the texture
  28664. */
  28665. height: number;
  28666. /**
  28667. * Number of Mipmaps for the texture
  28668. * @see https://en.wikipedia.org/wiki/Mipmap
  28669. */
  28670. mipmapCount: number;
  28671. /**
  28672. * If the textures format is a known fourCC format
  28673. * @see https://www.fourcc.org/
  28674. */
  28675. isFourCC: boolean;
  28676. /**
  28677. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  28678. */
  28679. isRGB: boolean;
  28680. /**
  28681. * If the texture is a lumincance format
  28682. */
  28683. isLuminance: boolean;
  28684. /**
  28685. * If this is a cube texture
  28686. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  28687. */
  28688. isCube: boolean;
  28689. /**
  28690. * If the texture is a compressed format eg. FOURCC_DXT1
  28691. */
  28692. isCompressed: boolean;
  28693. /**
  28694. * The dxgiFormat of the texture
  28695. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  28696. */
  28697. dxgiFormat: number;
  28698. /**
  28699. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  28700. */
  28701. textureType: number;
  28702. /**
  28703. * Sphericle polynomial created for the dds texture
  28704. */
  28705. sphericalPolynomial?: SphericalPolynomial;
  28706. }
  28707. /**
  28708. * Class used to provide DDS decompression tools
  28709. */
  28710. export class DDSTools {
  28711. /**
  28712. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  28713. */
  28714. static StoreLODInAlphaChannel: boolean;
  28715. /**
  28716. * Gets DDS information from an array buffer
  28717. * @param arrayBuffer defines the array buffer to read data from
  28718. * @returns the DDS information
  28719. */
  28720. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  28721. private static _FloatView;
  28722. private static _Int32View;
  28723. private static _ToHalfFloat;
  28724. private static _FromHalfFloat;
  28725. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  28726. private static _GetHalfFloatRGBAArrayBuffer;
  28727. private static _GetFloatRGBAArrayBuffer;
  28728. private static _GetFloatAsUIntRGBAArrayBuffer;
  28729. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  28730. private static _GetRGBAArrayBuffer;
  28731. private static _ExtractLongWordOrder;
  28732. private static _GetRGBArrayBuffer;
  28733. private static _GetLuminanceArrayBuffer;
  28734. /**
  28735. * Uploads DDS Levels to a Babylon Texture
  28736. * @hidden
  28737. */
  28738. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  28739. }
  28740. }
  28741. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  28742. import { Nullable } from "babylonjs/types";
  28743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28744. /**
  28745. * This represents the required contract to create a new type of texture loader.
  28746. */
  28747. export interface IInternalTextureLoader {
  28748. /**
  28749. * Defines wether the loader supports cascade loading the different faces.
  28750. */
  28751. supportCascades: boolean;
  28752. /**
  28753. * This returns if the loader support the current file information.
  28754. * @param extension defines the file extension of the file being loaded
  28755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  28756. * @param fallback defines the fallback internal texture if any
  28757. * @param isBase64 defines whether the texture is encoded as a base64
  28758. * @param isBuffer defines whether the texture data are stored as a buffer
  28759. * @returns true if the loader can load the specified file
  28760. */
  28761. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  28762. /**
  28763. * Transform the url before loading if required.
  28764. * @param rootUrl the url of the texture
  28765. * @param textureFormatInUse defines the current compressed format in use iun the engine
  28766. * @returns the transformed texture
  28767. */
  28768. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  28769. /**
  28770. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  28771. * @param rootUrl the url of the texture
  28772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  28773. * @returns the fallback texture
  28774. */
  28775. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  28776. /**
  28777. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  28778. * @param data contains the texture data
  28779. * @param texture defines the BabylonJS internal texture
  28780. * @param createPolynomials will be true if polynomials have been requested
  28781. * @param onLoad defines the callback to trigger once the texture is ready
  28782. * @param onError defines the callback to trigger in case of error
  28783. */
  28784. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  28785. /**
  28786. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  28787. * @param data contains the texture data
  28788. * @param texture defines the BabylonJS internal texture
  28789. * @param callback defines the method to call once ready to upload
  28790. */
  28791. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  28792. }
  28793. }
  28794. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  28795. import { Scene } from "babylonjs/scene";
  28796. import { Engine } from "babylonjs/Engines/engine";
  28797. import { Texture } from "babylonjs/Materials/Textures/texture";
  28798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28799. /**
  28800. * Creation options of the multi render target texture.
  28801. */
  28802. export interface IMultiRenderTargetOptions {
  28803. /**
  28804. * Define if the texture needs to create mip maps after render.
  28805. */
  28806. generateMipMaps?: boolean;
  28807. /**
  28808. * Define the types of all the draw buffers we want to create
  28809. */
  28810. types?: number[];
  28811. /**
  28812. * Define the sampling modes of all the draw buffers we want to create
  28813. */
  28814. samplingModes?: number[];
  28815. /**
  28816. * Define if a depth buffer is required
  28817. */
  28818. generateDepthBuffer?: boolean;
  28819. /**
  28820. * Define if a stencil buffer is required
  28821. */
  28822. generateStencilBuffer?: boolean;
  28823. /**
  28824. * Define if a depth texture is required instead of a depth buffer
  28825. */
  28826. generateDepthTexture?: boolean;
  28827. /**
  28828. * Define the number of desired draw buffers
  28829. */
  28830. textureCount?: number;
  28831. /**
  28832. * Define if aspect ratio should be adapted to the texture or stay the scene one
  28833. */
  28834. doNotChangeAspectRatio?: boolean;
  28835. /**
  28836. * Define the default type of the buffers we are creating
  28837. */
  28838. defaultType?: number;
  28839. }
  28840. /**
  28841. * A multi render target, like a render target provides the ability to render to a texture.
  28842. * Unlike the render target, it can render to several draw buffers in one draw.
  28843. * This is specially interesting in deferred rendering or for any effects requiring more than
  28844. * just one color from a single pass.
  28845. */
  28846. export class MultiRenderTarget extends RenderTargetTexture {
  28847. private _internalTextures;
  28848. private _textures;
  28849. private _multiRenderTargetOptions;
  28850. /**
  28851. * Get if draw buffers are currently supported by the used hardware and browser.
  28852. */
  28853. readonly isSupported: boolean;
  28854. /**
  28855. * Get the list of textures generated by the multi render target.
  28856. */
  28857. readonly textures: Texture[];
  28858. /**
  28859. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  28860. */
  28861. readonly depthTexture: Texture;
  28862. /**
  28863. * Set the wrapping mode on U of all the textures we are rendering to.
  28864. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  28865. */
  28866. wrapU: number;
  28867. /**
  28868. * Set the wrapping mode on V of all the textures we are rendering to.
  28869. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  28870. */
  28871. wrapV: number;
  28872. /**
  28873. * Instantiate a new multi render target texture.
  28874. * A multi render target, like a render target provides the ability to render to a texture.
  28875. * Unlike the render target, it can render to several draw buffers in one draw.
  28876. * This is specially interesting in deferred rendering or for any effects requiring more than
  28877. * just one color from a single pass.
  28878. * @param name Define the name of the texture
  28879. * @param size Define the size of the buffers to render to
  28880. * @param count Define the number of target we are rendering into
  28881. * @param scene Define the scene the texture belongs to
  28882. * @param options Define the options used to create the multi render target
  28883. */
  28884. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  28885. /** @hidden */
  28886. _rebuild(): void;
  28887. private _createInternalTextures;
  28888. private _createTextures;
  28889. /**
  28890. * Define the number of samples used if MSAA is enabled.
  28891. */
  28892. samples: number;
  28893. /**
  28894. * Resize all the textures in the multi render target.
  28895. * Be carrefull as it will recreate all the data in the new texture.
  28896. * @param size Define the new size
  28897. */
  28898. resize(size: any): void;
  28899. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28900. /**
  28901. * Dispose the render targets and their associated resources
  28902. */
  28903. dispose(): void;
  28904. /**
  28905. * Release all the underlying texture used as draw buffers.
  28906. */
  28907. releaseInternalTextures(): void;
  28908. }
  28909. }
  28910. declare module "babylonjs/Audio/analyser" {
  28911. import { Scene } from "babylonjs/scene";
  28912. /**
  28913. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28915. */
  28916. export class Analyser {
  28917. /**
  28918. * Gets or sets the smoothing
  28919. * @ignorenaming
  28920. */
  28921. SMOOTHING: number;
  28922. /**
  28923. * Gets or sets the FFT table size
  28924. * @ignorenaming
  28925. */
  28926. FFT_SIZE: number;
  28927. /**
  28928. * Gets or sets the bar graph amplitude
  28929. * @ignorenaming
  28930. */
  28931. BARGRAPHAMPLITUDE: number;
  28932. /**
  28933. * Gets or sets the position of the debug canvas
  28934. * @ignorenaming
  28935. */
  28936. DEBUGCANVASPOS: {
  28937. x: number;
  28938. y: number;
  28939. };
  28940. /**
  28941. * Gets or sets the debug canvas size
  28942. * @ignorenaming
  28943. */
  28944. DEBUGCANVASSIZE: {
  28945. width: number;
  28946. height: number;
  28947. };
  28948. private _byteFreqs;
  28949. private _byteTime;
  28950. private _floatFreqs;
  28951. private _webAudioAnalyser;
  28952. private _debugCanvas;
  28953. private _debugCanvasContext;
  28954. private _scene;
  28955. private _registerFunc;
  28956. private _audioEngine;
  28957. /**
  28958. * Creates a new analyser
  28959. * @param scene defines hosting scene
  28960. */
  28961. constructor(scene: Scene);
  28962. /**
  28963. * Get the number of data values you will have to play with for the visualization
  28964. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28965. * @returns a number
  28966. */
  28967. getFrequencyBinCount(): number;
  28968. /**
  28969. * Gets the current frequency data as a byte array
  28970. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28971. * @returns a Uint8Array
  28972. */
  28973. getByteFrequencyData(): Uint8Array;
  28974. /**
  28975. * Gets the current waveform as a byte array
  28976. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28977. * @returns a Uint8Array
  28978. */
  28979. getByteTimeDomainData(): Uint8Array;
  28980. /**
  28981. * Gets the current frequency data as a float array
  28982. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28983. * @returns a Float32Array
  28984. */
  28985. getFloatFrequencyData(): Float32Array;
  28986. /**
  28987. * Renders the debug canvas
  28988. */
  28989. drawDebugCanvas(): void;
  28990. /**
  28991. * Stops rendering the debug canvas and removes it
  28992. */
  28993. stopDebugCanvas(): void;
  28994. /**
  28995. * Connects two audio nodes
  28996. * @param inputAudioNode defines first node to connect
  28997. * @param outputAudioNode defines second node to connect
  28998. */
  28999. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29000. /**
  29001. * Releases all associated resources
  29002. */
  29003. dispose(): void;
  29004. }
  29005. }
  29006. declare module "babylonjs/Audio/audioEngine" {
  29007. import { IDisposable } from "babylonjs/scene";
  29008. import { Analyser } from "babylonjs/Audio/analyser";
  29009. import { Nullable } from "babylonjs/types";
  29010. import { Observable } from "babylonjs/Misc/observable";
  29011. /**
  29012. * This represents an audio engine and it is responsible
  29013. * to play, synchronize and analyse sounds throughout the application.
  29014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29015. */
  29016. export interface IAudioEngine extends IDisposable {
  29017. /**
  29018. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29019. */
  29020. readonly canUseWebAudio: boolean;
  29021. /**
  29022. * Gets the current AudioContext if available.
  29023. */
  29024. readonly audioContext: Nullable<AudioContext>;
  29025. /**
  29026. * The master gain node defines the global audio volume of your audio engine.
  29027. */
  29028. readonly masterGain: GainNode;
  29029. /**
  29030. * Gets whether or not mp3 are supported by your browser.
  29031. */
  29032. readonly isMP3supported: boolean;
  29033. /**
  29034. * Gets whether or not ogg are supported by your browser.
  29035. */
  29036. readonly isOGGsupported: boolean;
  29037. /**
  29038. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29039. * @ignoreNaming
  29040. */
  29041. WarnedWebAudioUnsupported: boolean;
  29042. /**
  29043. * Defines if the audio engine relies on a custom unlocked button.
  29044. * In this case, the embedded button will not be displayed.
  29045. */
  29046. useCustomUnlockedButton: boolean;
  29047. /**
  29048. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29049. */
  29050. readonly unlocked: boolean;
  29051. /**
  29052. * Event raised when audio has been unlocked on the browser.
  29053. */
  29054. onAudioUnlockedObservable: Observable<AudioEngine>;
  29055. /**
  29056. * Event raised when audio has been locked on the browser.
  29057. */
  29058. onAudioLockedObservable: Observable<AudioEngine>;
  29059. /**
  29060. * Flags the audio engine in Locked state.
  29061. * This happens due to new browser policies preventing audio to autoplay.
  29062. */
  29063. lock(): void;
  29064. /**
  29065. * Unlocks the audio engine once a user action has been done on the dom.
  29066. * This is helpful to resume play once browser policies have been satisfied.
  29067. */
  29068. unlock(): void;
  29069. }
  29070. /**
  29071. * This represents the default audio engine used in babylon.
  29072. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29074. */
  29075. export class AudioEngine implements IAudioEngine {
  29076. private _audioContext;
  29077. private _audioContextInitialized;
  29078. private _muteButton;
  29079. private _hostElement;
  29080. /**
  29081. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29082. */
  29083. canUseWebAudio: boolean;
  29084. /**
  29085. * The master gain node defines the global audio volume of your audio engine.
  29086. */
  29087. masterGain: GainNode;
  29088. /**
  29089. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29090. * @ignoreNaming
  29091. */
  29092. WarnedWebAudioUnsupported: boolean;
  29093. /**
  29094. * Gets whether or not mp3 are supported by your browser.
  29095. */
  29096. isMP3supported: boolean;
  29097. /**
  29098. * Gets whether or not ogg are supported by your browser.
  29099. */
  29100. isOGGsupported: boolean;
  29101. /**
  29102. * Gets whether audio has been unlocked on the device.
  29103. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29104. * a user interaction has happened.
  29105. */
  29106. unlocked: boolean;
  29107. /**
  29108. * Defines if the audio engine relies on a custom unlocked button.
  29109. * In this case, the embedded button will not be displayed.
  29110. */
  29111. useCustomUnlockedButton: boolean;
  29112. /**
  29113. * Event raised when audio has been unlocked on the browser.
  29114. */
  29115. onAudioUnlockedObservable: Observable<AudioEngine>;
  29116. /**
  29117. * Event raised when audio has been locked on the browser.
  29118. */
  29119. onAudioLockedObservable: Observable<AudioEngine>;
  29120. /**
  29121. * Gets the current AudioContext if available.
  29122. */
  29123. readonly audioContext: Nullable<AudioContext>;
  29124. private _connectedAnalyser;
  29125. /**
  29126. * Instantiates a new audio engine.
  29127. *
  29128. * There should be only one per page as some browsers restrict the number
  29129. * of audio contexts you can create.
  29130. * @param hostElement defines the host element where to display the mute icon if necessary
  29131. */
  29132. constructor(hostElement?: Nullable<HTMLElement>);
  29133. /**
  29134. * Flags the audio engine in Locked state.
  29135. * This happens due to new browser policies preventing audio to autoplay.
  29136. */
  29137. lock(): void;
  29138. /**
  29139. * Unlocks the audio engine once a user action has been done on the dom.
  29140. * This is helpful to resume play once browser policies have been satisfied.
  29141. */
  29142. unlock(): void;
  29143. private _resumeAudioContext;
  29144. private _initializeAudioContext;
  29145. private _tryToRun;
  29146. private _triggerRunningState;
  29147. private _triggerSuspendedState;
  29148. private _displayMuteButton;
  29149. private _moveButtonToTopLeft;
  29150. private _onResize;
  29151. private _hideMuteButton;
  29152. /**
  29153. * Destroy and release the resources associated with the audio ccontext.
  29154. */
  29155. dispose(): void;
  29156. /**
  29157. * Gets the global volume sets on the master gain.
  29158. * @returns the global volume if set or -1 otherwise
  29159. */
  29160. getGlobalVolume(): number;
  29161. /**
  29162. * Sets the global volume of your experience (sets on the master gain).
  29163. * @param newVolume Defines the new global volume of the application
  29164. */
  29165. setGlobalVolume(newVolume: number): void;
  29166. /**
  29167. * Connect the audio engine to an audio analyser allowing some amazing
  29168. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29170. * @param analyser The analyser to connect to the engine
  29171. */
  29172. connectToAnalyser(analyser: Analyser): void;
  29173. }
  29174. }
  29175. declare module "babylonjs/Loading/loadingScreen" {
  29176. /**
  29177. * Interface used to present a loading screen while loading a scene
  29178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29179. */
  29180. export interface ILoadingScreen {
  29181. /**
  29182. * Function called to display the loading screen
  29183. */
  29184. displayLoadingUI: () => void;
  29185. /**
  29186. * Function called to hide the loading screen
  29187. */
  29188. hideLoadingUI: () => void;
  29189. /**
  29190. * Gets or sets the color to use for the background
  29191. */
  29192. loadingUIBackgroundColor: string;
  29193. /**
  29194. * Gets or sets the text to display while loading
  29195. */
  29196. loadingUIText: string;
  29197. }
  29198. /**
  29199. * Class used for the default loading screen
  29200. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29201. */
  29202. export class DefaultLoadingScreen implements ILoadingScreen {
  29203. private _renderingCanvas;
  29204. private _loadingText;
  29205. private _loadingDivBackgroundColor;
  29206. private _loadingDiv;
  29207. private _loadingTextDiv;
  29208. /**
  29209. * Creates a new default loading screen
  29210. * @param _renderingCanvas defines the canvas used to render the scene
  29211. * @param _loadingText defines the default text to display
  29212. * @param _loadingDivBackgroundColor defines the default background color
  29213. */
  29214. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29215. /**
  29216. * Function called to display the loading screen
  29217. */
  29218. displayLoadingUI(): void;
  29219. /**
  29220. * Function called to hide the loading screen
  29221. */
  29222. hideLoadingUI(): void;
  29223. /**
  29224. * Gets or sets the text to display while loading
  29225. */
  29226. loadingUIText: string;
  29227. /**
  29228. * Gets or sets the color to use for the background
  29229. */
  29230. loadingUIBackgroundColor: string;
  29231. private _resizeLoadingUI;
  29232. }
  29233. }
  29234. declare module "babylonjs/Materials/Textures/videoTexture" {
  29235. import { Observable } from "babylonjs/Misc/observable";
  29236. import { Nullable } from "babylonjs/types";
  29237. import { Scene } from "babylonjs/scene";
  29238. import { Texture } from "babylonjs/Materials/Textures/texture";
  29239. /**
  29240. * Settings for finer control over video usage
  29241. */
  29242. export interface VideoTextureSettings {
  29243. /**
  29244. * Applies `autoplay` to video, if specified
  29245. */
  29246. autoPlay?: boolean;
  29247. /**
  29248. * Applies `loop` to video, if specified
  29249. */
  29250. loop?: boolean;
  29251. /**
  29252. * Automatically updates internal texture from video at every frame in the render loop
  29253. */
  29254. autoUpdateTexture: boolean;
  29255. /**
  29256. * Image src displayed during the video loading or until the user interacts with the video.
  29257. */
  29258. poster?: string;
  29259. }
  29260. /**
  29261. * If you want to display a video in your scene, this is the special texture for that.
  29262. * This special texture works similar to other textures, with the exception of a few parameters.
  29263. * @see https://doc.babylonjs.com/how_to/video_texture
  29264. */
  29265. export class VideoTexture extends Texture {
  29266. /**
  29267. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29268. */
  29269. readonly autoUpdateTexture: boolean;
  29270. /**
  29271. * The video instance used by the texture internally
  29272. */
  29273. readonly video: HTMLVideoElement;
  29274. private _onUserActionRequestedObservable;
  29275. /**
  29276. * Event triggerd when a dom action is required by the user to play the video.
  29277. * This happens due to recent changes in browser policies preventing video to auto start.
  29278. */
  29279. readonly onUserActionRequestedObservable: Observable<Texture>;
  29280. private _generateMipMaps;
  29281. private _engine;
  29282. private _stillImageCaptured;
  29283. private _displayingPosterTexture;
  29284. private _settings;
  29285. private _createInternalTextureOnEvent;
  29286. /**
  29287. * Creates a video texture.
  29288. * If you want to display a video in your scene, this is the special texture for that.
  29289. * This special texture works similar to other textures, with the exception of a few parameters.
  29290. * @see https://doc.babylonjs.com/how_to/video_texture
  29291. * @param name optional name, will detect from video source, if not defined
  29292. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29293. * @param scene is obviously the current scene.
  29294. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29295. * @param invertY is false by default but can be used to invert video on Y axis
  29296. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29297. * @param settings allows finer control over video usage
  29298. */
  29299. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29300. private _getName;
  29301. private _getVideo;
  29302. private _createInternalTexture;
  29303. private reset;
  29304. /**
  29305. * @hidden Internal method to initiate `update`.
  29306. */
  29307. _rebuild(): void;
  29308. /**
  29309. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29310. */
  29311. update(): void;
  29312. /**
  29313. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29314. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29315. */
  29316. updateTexture(isVisible: boolean): void;
  29317. protected _updateInternalTexture: () => void;
  29318. /**
  29319. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29320. * @param url New url.
  29321. */
  29322. updateURL(url: string): void;
  29323. /**
  29324. * Dispose the texture and release its associated resources.
  29325. */
  29326. dispose(): void;
  29327. /**
  29328. * Creates a video texture straight from your WebCam video feed.
  29329. * @param scene Define the scene the texture should be created in
  29330. * @param onReady Define a callback to triggered once the texture will be ready
  29331. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29332. */
  29333. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29334. minWidth: number;
  29335. maxWidth: number;
  29336. minHeight: number;
  29337. maxHeight: number;
  29338. deviceId: string;
  29339. }): void;
  29340. }
  29341. }
  29342. declare module "babylonjs/Engines/engine" {
  29343. import { Observable } from "babylonjs/Misc/observable";
  29344. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  29345. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  29346. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  29347. import { Camera } from "babylonjs/Cameras/camera";
  29348. import { Scene } from "babylonjs/scene";
  29349. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  29350. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  29351. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29352. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29353. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  29354. import { Material } from "babylonjs/Materials/material";
  29355. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29356. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29358. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  29359. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29360. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  29361. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29362. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  29363. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  29364. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29365. /**
  29366. * Interface for attribute information associated with buffer instanciation
  29367. */
  29368. export class InstancingAttributeInfo {
  29369. /**
  29370. * Index/offset of the attribute in the vertex shader
  29371. */
  29372. index: number;
  29373. /**
  29374. * size of the attribute, 1, 2, 3 or 4
  29375. */
  29376. attributeSize: number;
  29377. /**
  29378. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29379. * default is FLOAT
  29380. */
  29381. attribyteType: number;
  29382. /**
  29383. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29384. */
  29385. normalized: boolean;
  29386. /**
  29387. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29388. */
  29389. offset: number;
  29390. /**
  29391. * Name of the GLSL attribute, for debugging purpose only
  29392. */
  29393. attributeName: string;
  29394. }
  29395. /**
  29396. * Define options used to create a render target texture
  29397. */
  29398. export class RenderTargetCreationOptions {
  29399. /**
  29400. * Specifies is mipmaps must be generated
  29401. */
  29402. generateMipMaps?: boolean;
  29403. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  29404. generateDepthBuffer?: boolean;
  29405. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  29406. generateStencilBuffer?: boolean;
  29407. /** Defines texture type (int by default) */
  29408. type?: number;
  29409. /** Defines sampling mode (trilinear by default) */
  29410. samplingMode?: number;
  29411. /** Defines format (RGBA by default) */
  29412. format?: number;
  29413. }
  29414. /**
  29415. * Define options used to create a depth texture
  29416. */
  29417. export class DepthTextureCreationOptions {
  29418. /** Specifies whether or not a stencil should be allocated in the texture */
  29419. generateStencil?: boolean;
  29420. /** Specifies whether or not bilinear filtering is enable on the texture */
  29421. bilinearFiltering?: boolean;
  29422. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29423. comparisonFunction?: number;
  29424. /** Specifies if the created texture is a cube texture */
  29425. isCube?: boolean;
  29426. }
  29427. /**
  29428. * Class used to describe the capabilities of the engine relatively to the current browser
  29429. */
  29430. export class EngineCapabilities {
  29431. /** Maximum textures units per fragment shader */
  29432. maxTexturesImageUnits: number;
  29433. /** Maximum texture units per vertex shader */
  29434. maxVertexTextureImageUnits: number;
  29435. /** Maximum textures units in the entire pipeline */
  29436. maxCombinedTexturesImageUnits: number;
  29437. /** Maximum texture size */
  29438. maxTextureSize: number;
  29439. /** Maximum cube texture size */
  29440. maxCubemapTextureSize: number;
  29441. /** Maximum render texture size */
  29442. maxRenderTextureSize: number;
  29443. /** Maximum number of vertex attributes */
  29444. maxVertexAttribs: number;
  29445. /** Maximum number of varyings */
  29446. maxVaryingVectors: number;
  29447. /** Maximum number of uniforms per vertex shader */
  29448. maxVertexUniformVectors: number;
  29449. /** Maximum number of uniforms per fragment shader */
  29450. maxFragmentUniformVectors: number;
  29451. /** Defines if standard derivates (dx/dy) are supported */
  29452. standardDerivatives: boolean;
  29453. /** Defines if s3tc texture compression is supported */
  29454. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29455. /** Defines if pvrtc texture compression is supported */
  29456. pvrtc: any;
  29457. /** Defines if etc1 texture compression is supported */
  29458. etc1: any;
  29459. /** Defines if etc2 texture compression is supported */
  29460. etc2: any;
  29461. /** Defines if astc texture compression is supported */
  29462. astc: any;
  29463. /** Defines if float textures are supported */
  29464. textureFloat: boolean;
  29465. /** Defines if vertex array objects are supported */
  29466. vertexArrayObject: boolean;
  29467. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29468. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29469. /** Gets the maximum level of anisotropy supported */
  29470. maxAnisotropy: number;
  29471. /** Defines if instancing is supported */
  29472. instancedArrays: boolean;
  29473. /** Defines if 32 bits indices are supported */
  29474. uintIndices: boolean;
  29475. /** Defines if high precision shaders are supported */
  29476. highPrecisionShaderSupported: boolean;
  29477. /** Defines if depth reading in the fragment shader is supported */
  29478. fragmentDepthSupported: boolean;
  29479. /** Defines if float texture linear filtering is supported*/
  29480. textureFloatLinearFiltering: boolean;
  29481. /** Defines if rendering to float textures is supported */
  29482. textureFloatRender: boolean;
  29483. /** Defines if half float textures are supported*/
  29484. textureHalfFloat: boolean;
  29485. /** Defines if half float texture linear filtering is supported*/
  29486. textureHalfFloatLinearFiltering: boolean;
  29487. /** Defines if rendering to half float textures is supported */
  29488. textureHalfFloatRender: boolean;
  29489. /** Defines if textureLOD shader command is supported */
  29490. textureLOD: boolean;
  29491. /** Defines if draw buffers extension is supported */
  29492. drawBuffersExtension: boolean;
  29493. /** Defines if depth textures are supported */
  29494. depthTextureExtension: boolean;
  29495. /** Defines if float color buffer are supported */
  29496. colorBufferFloat: boolean;
  29497. /** Gets disjoint timer query extension (null if not supported) */
  29498. timerQuery: EXT_disjoint_timer_query;
  29499. /** Defines if timestamp can be used with timer query */
  29500. canUseTimestampForTimerQuery: boolean;
  29501. /** Function used to let the system compiles shaders in background */
  29502. parallelShaderCompile: {
  29503. MAX_SHADER_COMPILER_THREADS_KHR: number;
  29504. maxShaderCompilerThreadsKHR: (thread: number) => void;
  29505. COMPLETION_STATUS_KHR: number;
  29506. };
  29507. }
  29508. /** Interface defining initialization parameters for Engine class */
  29509. export interface EngineOptions extends WebGLContextAttributes {
  29510. /**
  29511. * Defines if the engine should no exceed a specified device ratio
  29512. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29513. */
  29514. limitDeviceRatio?: number;
  29515. /**
  29516. * Defines if webvr should be enabled automatically
  29517. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29518. */
  29519. autoEnableWebVR?: boolean;
  29520. /**
  29521. * Defines if webgl2 should be turned off even if supported
  29522. * @see http://doc.babylonjs.com/features/webgl2
  29523. */
  29524. disableWebGL2Support?: boolean;
  29525. /**
  29526. * Defines if webaudio should be initialized as well
  29527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29528. */
  29529. audioEngine?: boolean;
  29530. /**
  29531. * Defines if animations should run using a deterministic lock step
  29532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29533. */
  29534. deterministicLockstep?: boolean;
  29535. /** Defines the maximum steps to use with deterministic lock step mode */
  29536. lockstepMaxSteps?: number;
  29537. /**
  29538. * Defines that engine should ignore context lost events
  29539. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29540. */
  29541. doNotHandleContextLost?: boolean;
  29542. }
  29543. /**
  29544. * Defines the interface used by display changed events
  29545. */
  29546. export interface IDisplayChangedEventArgs {
  29547. /** Gets the vrDisplay object (if any) */
  29548. vrDisplay: Nullable<any>;
  29549. /** Gets a boolean indicating if webVR is supported */
  29550. vrSupported: boolean;
  29551. }
  29552. /**
  29553. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29554. */
  29555. export class Engine {
  29556. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29557. static ExceptionList: ({
  29558. key: string;
  29559. capture: string;
  29560. captureConstraint: number;
  29561. targets: string[];
  29562. } | {
  29563. key: string;
  29564. capture: null;
  29565. captureConstraint: null;
  29566. targets: string[];
  29567. })[];
  29568. /** Gets the list of created engines */
  29569. static Instances: Engine[];
  29570. /**
  29571. * Gets the latest created engine
  29572. */
  29573. static readonly LastCreatedEngine: Nullable<Engine>;
  29574. /**
  29575. * Gets the latest created scene
  29576. */
  29577. static readonly LastCreatedScene: Nullable<Scene>;
  29578. /**
  29579. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29580. * @param flag defines which part of the materials must be marked as dirty
  29581. * @param predicate defines a predicate used to filter which materials should be affected
  29582. */
  29583. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29584. /**
  29585. * Hidden
  29586. */
  29587. static _TextureLoaders: IInternalTextureLoader[];
  29588. /** Defines that alpha blending is disabled */
  29589. static readonly ALPHA_DISABLE: number;
  29590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29591. static readonly ALPHA_ADD: number;
  29592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29593. static readonly ALPHA_COMBINE: number;
  29594. /** Defines that alpha blending to DEST - SRC * DEST */
  29595. static readonly ALPHA_SUBTRACT: number;
  29596. /** Defines that alpha blending to SRC * DEST */
  29597. static readonly ALPHA_MULTIPLY: number;
  29598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29599. static readonly ALPHA_MAXIMIZED: number;
  29600. /** Defines that alpha blending to SRC + DEST */
  29601. static readonly ALPHA_ONEONE: number;
  29602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29603. static readonly ALPHA_PREMULTIPLIED: number;
  29604. /**
  29605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29607. */
  29608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29610. static readonly ALPHA_INTERPOLATE: number;
  29611. /**
  29612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29614. */
  29615. static readonly ALPHA_SCREENMODE: number;
  29616. /** Defines that the ressource is not delayed*/
  29617. static readonly DELAYLOADSTATE_NONE: number;
  29618. /** Defines that the ressource was successfully delay loaded */
  29619. static readonly DELAYLOADSTATE_LOADED: number;
  29620. /** Defines that the ressource is currently delay loading */
  29621. static readonly DELAYLOADSTATE_LOADING: number;
  29622. /** Defines that the ressource is delayed and has not started loading */
  29623. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29625. static readonly NEVER: number;
  29626. /** 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 */
  29627. static readonly ALWAYS: number;
  29628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29629. static readonly LESS: number;
  29630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29631. static readonly EQUAL: number;
  29632. /** 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 */
  29633. static readonly LEQUAL: number;
  29634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29635. static readonly GREATER: number;
  29636. /** 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 */
  29637. static readonly GEQUAL: number;
  29638. /** 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 */
  29639. static readonly NOTEQUAL: number;
  29640. /** Passed to stencilOperation to specify that stencil value must be kept */
  29641. static readonly KEEP: number;
  29642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29643. static readonly REPLACE: number;
  29644. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29645. static readonly INCR: number;
  29646. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29647. static readonly DECR: number;
  29648. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29649. static readonly INVERT: number;
  29650. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29651. static readonly INCR_WRAP: number;
  29652. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29653. static readonly DECR_WRAP: number;
  29654. /** Texture is not repeating outside of 0..1 UVs */
  29655. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29656. /** Texture is repeating outside of 0..1 UVs */
  29657. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29658. /** Texture is repeating and mirrored */
  29659. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29660. /** ALPHA */
  29661. static readonly TEXTUREFORMAT_ALPHA: number;
  29662. /** LUMINANCE */
  29663. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29664. /** LUMINANCE_ALPHA */
  29665. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29666. /** RGB */
  29667. static readonly TEXTUREFORMAT_RGB: number;
  29668. /** RGBA */
  29669. static readonly TEXTUREFORMAT_RGBA: number;
  29670. /** RED */
  29671. static readonly TEXTUREFORMAT_RED: number;
  29672. /** RED (2nd reference) */
  29673. static readonly TEXTUREFORMAT_R: number;
  29674. /** RG */
  29675. static readonly TEXTUREFORMAT_RG: number;
  29676. /** RED_INTEGER */
  29677. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29678. /** RED_INTEGER (2nd reference) */
  29679. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29680. /** RG_INTEGER */
  29681. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29682. /** RGB_INTEGER */
  29683. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29684. /** RGBA_INTEGER */
  29685. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29686. /** UNSIGNED_BYTE */
  29687. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29688. /** UNSIGNED_BYTE (2nd reference) */
  29689. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29690. /** FLOAT */
  29691. static readonly TEXTURETYPE_FLOAT: number;
  29692. /** HALF_FLOAT */
  29693. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29694. /** BYTE */
  29695. static readonly TEXTURETYPE_BYTE: number;
  29696. /** SHORT */
  29697. static readonly TEXTURETYPE_SHORT: number;
  29698. /** UNSIGNED_SHORT */
  29699. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29700. /** INT */
  29701. static readonly TEXTURETYPE_INT: number;
  29702. /** UNSIGNED_INT */
  29703. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29704. /** UNSIGNED_SHORT_4_4_4_4 */
  29705. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29706. /** UNSIGNED_SHORT_5_5_5_1 */
  29707. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29708. /** UNSIGNED_SHORT_5_6_5 */
  29709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29710. /** UNSIGNED_INT_2_10_10_10_REV */
  29711. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29712. /** UNSIGNED_INT_24_8 */
  29713. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29714. /** UNSIGNED_INT_10F_11F_11F_REV */
  29715. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29716. /** UNSIGNED_INT_5_9_9_9_REV */
  29717. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29718. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29719. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29720. /** nearest is mag = nearest and min = nearest and mip = linear */
  29721. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29723. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29724. /** Trilinear is mag = linear and min = linear and mip = linear */
  29725. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29726. /** nearest is mag = nearest and min = nearest and mip = linear */
  29727. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29729. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29730. /** Trilinear is mag = linear and min = linear and mip = linear */
  29731. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29732. /** mag = nearest and min = nearest and mip = nearest */
  29733. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29734. /** mag = nearest and min = linear and mip = nearest */
  29735. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29736. /** mag = nearest and min = linear and mip = linear */
  29737. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29738. /** mag = nearest and min = linear and mip = none */
  29739. static readonly TEXTURE_NEAREST_LINEAR: number;
  29740. /** mag = nearest and min = nearest and mip = none */
  29741. static readonly TEXTURE_NEAREST_NEAREST: number;
  29742. /** mag = linear and min = nearest and mip = nearest */
  29743. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29744. /** mag = linear and min = nearest and mip = linear */
  29745. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29746. /** mag = linear and min = linear and mip = none */
  29747. static readonly TEXTURE_LINEAR_LINEAR: number;
  29748. /** mag = linear and min = nearest and mip = none */
  29749. static readonly TEXTURE_LINEAR_NEAREST: number;
  29750. /** Explicit coordinates mode */
  29751. static readonly TEXTURE_EXPLICIT_MODE: number;
  29752. /** Spherical coordinates mode */
  29753. static readonly TEXTURE_SPHERICAL_MODE: number;
  29754. /** Planar coordinates mode */
  29755. static readonly TEXTURE_PLANAR_MODE: number;
  29756. /** Cubic coordinates mode */
  29757. static readonly TEXTURE_CUBIC_MODE: number;
  29758. /** Projection coordinates mode */
  29759. static readonly TEXTURE_PROJECTION_MODE: number;
  29760. /** Skybox coordinates mode */
  29761. static readonly TEXTURE_SKYBOX_MODE: number;
  29762. /** Inverse Cubic coordinates mode */
  29763. static readonly TEXTURE_INVCUBIC_MODE: number;
  29764. /** Equirectangular coordinates mode */
  29765. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29766. /** Equirectangular Fixed coordinates mode */
  29767. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29768. /** Equirectangular Fixed Mirrored coordinates mode */
  29769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29770. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29771. static readonly SCALEMODE_FLOOR: number;
  29772. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29773. static readonly SCALEMODE_NEAREST: number;
  29774. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29775. static readonly SCALEMODE_CEILING: number;
  29776. /**
  29777. * Returns the current version of the framework
  29778. */
  29779. static readonly Version: string;
  29780. /**
  29781. * Returns a string describing the current engine
  29782. */
  29783. readonly description: string;
  29784. /**
  29785. * Gets or sets the epsilon value used by collision engine
  29786. */
  29787. static CollisionsEpsilon: number;
  29788. /**
  29789. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  29790. */
  29791. static CodeRepository: string;
  29792. /**
  29793. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29794. */
  29795. static ShadersRepository: string;
  29796. /**
  29797. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29798. */
  29799. forcePOTTextures: boolean;
  29800. /**
  29801. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29802. */
  29803. isFullscreen: boolean;
  29804. /**
  29805. * Gets a boolean indicating if the pointer is currently locked
  29806. */
  29807. isPointerLock: boolean;
  29808. /**
  29809. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29810. */
  29811. cullBackFaces: boolean;
  29812. /**
  29813. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29814. */
  29815. renderEvenInBackground: boolean;
  29816. /**
  29817. * Gets or sets a boolean indicating that cache can be kept between frames
  29818. */
  29819. preventCacheWipeBetweenFrames: boolean;
  29820. /**
  29821. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29822. **/
  29823. enableOfflineSupport: boolean;
  29824. /**
  29825. * 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)
  29826. **/
  29827. disableManifestCheck: boolean;
  29828. /**
  29829. * Gets the list of created scenes
  29830. */
  29831. scenes: Scene[];
  29832. /**
  29833. * Event raised when a new scene is created
  29834. */
  29835. onNewSceneAddedObservable: Observable<Scene>;
  29836. /**
  29837. * Gets the list of created postprocesses
  29838. */
  29839. postProcesses: PostProcess[];
  29840. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29841. validateShaderPrograms: boolean;
  29842. /**
  29843. * Observable event triggered each time the rendering canvas is resized
  29844. */
  29845. onResizeObservable: Observable<Engine>;
  29846. /**
  29847. * Observable event triggered each time the canvas loses focus
  29848. */
  29849. onCanvasBlurObservable: Observable<Engine>;
  29850. /**
  29851. * Observable event triggered each time the canvas gains focus
  29852. */
  29853. onCanvasFocusObservable: Observable<Engine>;
  29854. /**
  29855. * Observable event triggered each time the canvas receives pointerout event
  29856. */
  29857. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29858. /**
  29859. * Observable event triggered before each texture is initialized
  29860. */
  29861. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29862. private _vrDisplay;
  29863. private _vrSupported;
  29864. private _oldSize;
  29865. private _oldHardwareScaleFactor;
  29866. private _vrExclusivePointerMode;
  29867. private _webVRInitPromise;
  29868. /**
  29869. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  29870. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  29871. */
  29872. readonly isInVRExclusivePointerMode: boolean;
  29873. /**
  29874. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29875. */
  29876. disableUniformBuffers: boolean;
  29877. /** @hidden */
  29878. _uniformBuffers: UniformBuffer[];
  29879. /**
  29880. * Gets a boolean indicating that the engine supports uniform buffers
  29881. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29882. */
  29883. readonly supportsUniformBuffers: boolean;
  29884. /**
  29885. * Observable raised when the engine begins a new frame
  29886. */
  29887. onBeginFrameObservable: Observable<Engine>;
  29888. /**
  29889. * If set, will be used to request the next animation frame for the render loop
  29890. */
  29891. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29892. /**
  29893. * Observable raised when the engine ends the current frame
  29894. */
  29895. onEndFrameObservable: Observable<Engine>;
  29896. /**
  29897. * Observable raised when the engine is about to compile a shader
  29898. */
  29899. onBeforeShaderCompilationObservable: Observable<Engine>;
  29900. /**
  29901. * Observable raised when the engine has jsut compiled a shader
  29902. */
  29903. onAfterShaderCompilationObservable: Observable<Engine>;
  29904. /** @hidden */
  29905. _gl: WebGLRenderingContext;
  29906. private _renderingCanvas;
  29907. private _windowIsBackground;
  29908. private _webGLVersion;
  29909. /**
  29910. * Gets a boolean indicating that only power of 2 textures are supported
  29911. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29912. */
  29913. readonly needPOTTextures: boolean;
  29914. /** @hidden */
  29915. _badOS: boolean;
  29916. /** @hidden */
  29917. _badDesktopOS: boolean;
  29918. /**
  29919. * Gets or sets a value indicating if we want to disable texture binding optimization.
  29920. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  29921. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  29922. */
  29923. disableTextureBindingOptimization: boolean;
  29924. /**
  29925. * Gets the audio engine
  29926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29927. * @ignorenaming
  29928. */
  29929. static audioEngine: IAudioEngine;
  29930. /**
  29931. * Default AudioEngine factory responsible of creating the Audio Engine.
  29932. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29933. */
  29934. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29935. /**
  29936. * Default offline support factory responsible of creating a tool used to store data locally.
  29937. * By default, this will create a Database object if the workload has been embedded.
  29938. */
  29939. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29940. private _onFocus;
  29941. private _onBlur;
  29942. private _onCanvasPointerOut;
  29943. private _onCanvasBlur;
  29944. private _onCanvasFocus;
  29945. private _onFullscreenChange;
  29946. private _onPointerLockChange;
  29947. private _onVRDisplayPointerRestricted;
  29948. private _onVRDisplayPointerUnrestricted;
  29949. private _onVrDisplayConnect;
  29950. private _onVrDisplayDisconnect;
  29951. private _onVrDisplayPresentChange;
  29952. /**
  29953. * Observable signaled when VR display mode changes
  29954. */
  29955. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  29956. /**
  29957. * Observable signaled when VR request present is complete
  29958. */
  29959. onVRRequestPresentComplete: Observable<boolean>;
  29960. /**
  29961. * Observable signaled when VR request present starts
  29962. */
  29963. onVRRequestPresentStart: Observable<Engine>;
  29964. private _hardwareScalingLevel;
  29965. /** @hidden */
  29966. protected _caps: EngineCapabilities;
  29967. private _pointerLockRequested;
  29968. private _isStencilEnable;
  29969. private _colorWrite;
  29970. private _loadingScreen;
  29971. /** @hidden */
  29972. _drawCalls: PerfCounter;
  29973. /** @hidden */
  29974. _textureCollisions: PerfCounter;
  29975. private _glVersion;
  29976. private _glRenderer;
  29977. private _glVendor;
  29978. private _videoTextureSupported;
  29979. private _renderingQueueLaunched;
  29980. private _activeRenderLoops;
  29981. private _deterministicLockstep;
  29982. private _lockstepMaxSteps;
  29983. /**
  29984. * Observable signaled when a context lost event is raised
  29985. */
  29986. onContextLostObservable: Observable<Engine>;
  29987. /**
  29988. * Observable signaled when a context restored event is raised
  29989. */
  29990. onContextRestoredObservable: Observable<Engine>;
  29991. private _onContextLost;
  29992. private _onContextRestored;
  29993. private _contextWasLost;
  29994. private _doNotHandleContextLost;
  29995. /**
  29996. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29998. */
  29999. doNotHandleContextLost: boolean;
  30000. private _performanceMonitor;
  30001. private _fps;
  30002. private _deltaTime;
  30003. /**
  30004. * Turn this value on if you want to pause FPS computation when in background
  30005. */
  30006. disablePerformanceMonitorInBackground: boolean;
  30007. /**
  30008. * Gets the performance monitor attached to this engine
  30009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30010. */
  30011. readonly performanceMonitor: PerformanceMonitor;
  30012. /** @hidden */
  30013. protected _depthCullingState: _DepthCullingState;
  30014. /** @hidden */
  30015. protected _stencilState: _StencilState;
  30016. /** @hidden */
  30017. protected _alphaState: _AlphaState;
  30018. /** @hidden */
  30019. protected _alphaMode: number;
  30020. protected _internalTexturesCache: InternalTexture[];
  30021. /** @hidden */
  30022. protected _activeChannel: number;
  30023. private _currentTextureChannel;
  30024. /** @hidden */
  30025. protected _boundTexturesCache: {
  30026. [key: string]: Nullable<InternalTexture>;
  30027. };
  30028. /** @hidden */
  30029. protected _currentEffect: Nullable<Effect>;
  30030. /** @hidden */
  30031. protected _currentProgram: Nullable<WebGLProgram>;
  30032. private _compiledEffects;
  30033. private _vertexAttribArraysEnabled;
  30034. /** @hidden */
  30035. protected _cachedViewport: Nullable<Viewport>;
  30036. private _cachedVertexArrayObject;
  30037. /** @hidden */
  30038. protected _cachedVertexBuffers: any;
  30039. /** @hidden */
  30040. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  30041. /** @hidden */
  30042. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30043. /** @hidden */
  30044. protected _currentRenderTarget: Nullable<InternalTexture>;
  30045. private _uintIndicesCurrentlySet;
  30046. private _currentBoundBuffer;
  30047. /** @hidden */
  30048. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30049. private _currentBufferPointers;
  30050. private _currentInstanceLocations;
  30051. private _currentInstanceBuffers;
  30052. private _textureUnits;
  30053. private _firstBoundInternalTextureTracker;
  30054. private _lastBoundInternalTextureTracker;
  30055. private _workingCanvas;
  30056. private _workingContext;
  30057. private _rescalePostProcess;
  30058. private _dummyFramebuffer;
  30059. private _externalData;
  30060. private _bindedRenderFunction;
  30061. private _vaoRecordInProgress;
  30062. private _mustWipeVertexAttributes;
  30063. private _emptyTexture;
  30064. private _emptyCubeTexture;
  30065. private _emptyTexture3D;
  30066. /** @hidden */
  30067. _frameHandler: number;
  30068. private _nextFreeTextureSlots;
  30069. private _maxSimultaneousTextures;
  30070. private _activeRequests;
  30071. private _texturesSupported;
  30072. private _textureFormatInUse;
  30073. /**
  30074. * Gets the list of texture formats supported
  30075. */
  30076. readonly texturesSupported: Array<string>;
  30077. /**
  30078. * Gets the list of texture formats in use
  30079. */
  30080. readonly textureFormatInUse: Nullable<string>;
  30081. /**
  30082. * Gets the current viewport
  30083. */
  30084. readonly currentViewport: Nullable<Viewport>;
  30085. /**
  30086. * Gets the default empty texture
  30087. */
  30088. readonly emptyTexture: InternalTexture;
  30089. /**
  30090. * Gets the default empty 3D texture
  30091. */
  30092. readonly emptyTexture3D: InternalTexture;
  30093. /**
  30094. * Gets the default empty cube texture
  30095. */
  30096. readonly emptyCubeTexture: InternalTexture;
  30097. /**
  30098. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30099. */
  30100. readonly premultipliedAlpha: boolean;
  30101. /**
  30102. * Creates a new engine
  30103. * @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
  30104. * @param antialias defines enable antialiasing (default: false)
  30105. * @param options defines further options to be sent to the getContext() function
  30106. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30107. */
  30108. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30109. private _rebuildInternalTextures;
  30110. private _rebuildEffects;
  30111. /**
  30112. * Gets a boolean indicating if all created effects are ready
  30113. * @returns true if all effects are ready
  30114. */
  30115. areAllEffectsReady(): boolean;
  30116. private _rebuildBuffers;
  30117. private _initGLContext;
  30118. /**
  30119. * Gets version of the current webGL context
  30120. */
  30121. readonly webGLVersion: number;
  30122. /**
  30123. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30124. */
  30125. readonly isStencilEnable: boolean;
  30126. private _prepareWorkingCanvas;
  30127. /**
  30128. * Reset the texture cache to empty state
  30129. */
  30130. resetTextureCache(): void;
  30131. /**
  30132. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30134. * @returns true if engine is in deterministic lock step mode
  30135. */
  30136. isDeterministicLockStep(): boolean;
  30137. /**
  30138. * Gets the max steps when engine is running in deterministic lock step
  30139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30140. * @returns the max steps
  30141. */
  30142. getLockstepMaxSteps(): number;
  30143. /**
  30144. * Gets an object containing information about the current webGL context
  30145. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30146. */
  30147. getGlInfo(): {
  30148. vendor: string;
  30149. renderer: string;
  30150. version: string;
  30151. };
  30152. /**
  30153. * Gets current aspect ratio
  30154. * @param camera defines the camera to use to get the aspect ratio
  30155. * @param useScreen defines if screen size must be used (or the current render target if any)
  30156. * @returns a number defining the aspect ratio
  30157. */
  30158. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  30159. /**
  30160. * Gets current screen aspect ratio
  30161. * @returns a number defining the aspect ratio
  30162. */
  30163. getScreenAspectRatio(): number;
  30164. /**
  30165. * Gets the current render width
  30166. * @param useScreen defines if screen size must be used (or the current render target if any)
  30167. * @returns a number defining the current render width
  30168. */
  30169. getRenderWidth(useScreen?: boolean): number;
  30170. /**
  30171. * Gets the current render height
  30172. * @param useScreen defines if screen size must be used (or the current render target if any)
  30173. * @returns a number defining the current render height
  30174. */
  30175. getRenderHeight(useScreen?: boolean): number;
  30176. /**
  30177. * Gets the HTML canvas attached with the current webGL context
  30178. * @returns a HTML canvas
  30179. */
  30180. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30181. /**
  30182. * Gets the client rect of the HTML canvas attached with the current webGL context
  30183. * @returns a client rectanglee
  30184. */
  30185. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30186. /**
  30187. * Defines the hardware scaling level.
  30188. * By default the hardware scaling level is computed from the window device ratio.
  30189. * 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.
  30190. * @param level defines the level to use
  30191. */
  30192. setHardwareScalingLevel(level: number): void;
  30193. /**
  30194. * Gets the current hardware scaling level.
  30195. * By default the hardware scaling level is computed from the window device ratio.
  30196. * 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.
  30197. * @returns a number indicating the current hardware scaling level
  30198. */
  30199. getHardwareScalingLevel(): number;
  30200. /**
  30201. * Gets the list of loaded textures
  30202. * @returns an array containing all loaded textures
  30203. */
  30204. getLoadedTexturesCache(): InternalTexture[];
  30205. /**
  30206. * Gets the object containing all engine capabilities
  30207. * @returns the EngineCapabilities object
  30208. */
  30209. getCaps(): EngineCapabilities;
  30210. /**
  30211. * Gets the current depth function
  30212. * @returns a number defining the depth function
  30213. */
  30214. getDepthFunction(): Nullable<number>;
  30215. /**
  30216. * Sets the current depth function
  30217. * @param depthFunc defines the function to use
  30218. */
  30219. setDepthFunction(depthFunc: number): void;
  30220. /**
  30221. * Sets the current depth function to GREATER
  30222. */
  30223. setDepthFunctionToGreater(): void;
  30224. /**
  30225. * Sets the current depth function to GEQUAL
  30226. */
  30227. setDepthFunctionToGreaterOrEqual(): void;
  30228. /**
  30229. * Sets the current depth function to LESS
  30230. */
  30231. setDepthFunctionToLess(): void;
  30232. /**
  30233. * Sets the current depth function to LEQUAL
  30234. */
  30235. setDepthFunctionToLessOrEqual(): void;
  30236. /**
  30237. * Gets a boolean indicating if stencil buffer is enabled
  30238. * @returns the current stencil buffer state
  30239. */
  30240. getStencilBuffer(): boolean;
  30241. /**
  30242. * Enable or disable the stencil buffer
  30243. * @param enable defines if the stencil buffer must be enabled or disabled
  30244. */
  30245. setStencilBuffer(enable: boolean): void;
  30246. /**
  30247. * Gets the current stencil mask
  30248. * @returns a number defining the new stencil mask to use
  30249. */
  30250. getStencilMask(): number;
  30251. /**
  30252. * Sets the current stencil mask
  30253. * @param mask defines the new stencil mask to use
  30254. */
  30255. setStencilMask(mask: number): void;
  30256. /**
  30257. * Gets the current stencil function
  30258. * @returns a number defining the stencil function to use
  30259. */
  30260. getStencilFunction(): number;
  30261. /**
  30262. * Gets the current stencil reference value
  30263. * @returns a number defining the stencil reference value to use
  30264. */
  30265. getStencilFunctionReference(): number;
  30266. /**
  30267. * Gets the current stencil mask
  30268. * @returns a number defining the stencil mask to use
  30269. */
  30270. getStencilFunctionMask(): number;
  30271. /**
  30272. * Sets the current stencil function
  30273. * @param stencilFunc defines the new stencil function to use
  30274. */
  30275. setStencilFunction(stencilFunc: number): void;
  30276. /**
  30277. * Sets the current stencil reference
  30278. * @param reference defines the new stencil reference to use
  30279. */
  30280. setStencilFunctionReference(reference: number): void;
  30281. /**
  30282. * Sets the current stencil mask
  30283. * @param mask defines the new stencil mask to use
  30284. */
  30285. setStencilFunctionMask(mask: number): void;
  30286. /**
  30287. * Gets the current stencil operation when stencil fails
  30288. * @returns a number defining stencil operation to use when stencil fails
  30289. */
  30290. getStencilOperationFail(): number;
  30291. /**
  30292. * Gets the current stencil operation when depth fails
  30293. * @returns a number defining stencil operation to use when depth fails
  30294. */
  30295. getStencilOperationDepthFail(): number;
  30296. /**
  30297. * Gets the current stencil operation when stencil passes
  30298. * @returns a number defining stencil operation to use when stencil passes
  30299. */
  30300. getStencilOperationPass(): number;
  30301. /**
  30302. * Sets the stencil operation to use when stencil fails
  30303. * @param operation defines the stencil operation to use when stencil fails
  30304. */
  30305. setStencilOperationFail(operation: number): void;
  30306. /**
  30307. * Sets the stencil operation to use when depth fails
  30308. * @param operation defines the stencil operation to use when depth fails
  30309. */
  30310. setStencilOperationDepthFail(operation: number): void;
  30311. /**
  30312. * Sets the stencil operation to use when stencil passes
  30313. * @param operation defines the stencil operation to use when stencil passes
  30314. */
  30315. setStencilOperationPass(operation: number): void;
  30316. /**
  30317. * Sets a boolean indicating if the dithering state is enabled or disabled
  30318. * @param value defines the dithering state
  30319. */
  30320. setDitheringState(value: boolean): void;
  30321. /**
  30322. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30323. * @param value defines the rasterizer state
  30324. */
  30325. setRasterizerState(value: boolean): void;
  30326. /**
  30327. * stop executing a render loop function and remove it from the execution array
  30328. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30329. */
  30330. stopRenderLoop(renderFunction?: () => void): void;
  30331. /** @hidden */
  30332. _renderLoop(): void;
  30333. /**
  30334. * Register and execute a render loop. The engine can have more than one render function
  30335. * @param renderFunction defines the function to continuously execute
  30336. */
  30337. runRenderLoop(renderFunction: () => void): void;
  30338. /**
  30339. * Toggle full screen mode
  30340. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30341. */
  30342. switchFullscreen(requestPointerLock: boolean): void;
  30343. /**
  30344. * Clear the current render buffer or the current render target (if any is set up)
  30345. * @param color defines the color to use
  30346. * @param backBuffer defines if the back buffer must be cleared
  30347. * @param depth defines if the depth buffer must be cleared
  30348. * @param stencil defines if the stencil buffer must be cleared
  30349. */
  30350. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30351. /**
  30352. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30353. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30354. * @param y defines the y-coordinate of the corner of the clear rectangle
  30355. * @param width defines the width of the clear rectangle
  30356. * @param height defines the height of the clear rectangle
  30357. * @param clearColor defines the clear color
  30358. */
  30359. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  30360. private _viewportCached;
  30361. /** @hidden */
  30362. _viewport(x: number, y: number, width: number, height: number): void;
  30363. /**
  30364. * Set the WebGL's viewport
  30365. * @param viewport defines the viewport element to be used
  30366. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30367. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30368. */
  30369. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  30370. /**
  30371. * Directly set the WebGL Viewport
  30372. * @param x defines the x coordinate of the viewport (in screen space)
  30373. * @param y defines the y coordinate of the viewport (in screen space)
  30374. * @param width defines the width of the viewport (in screen space)
  30375. * @param height defines the height of the viewport (in screen space)
  30376. * @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
  30377. */
  30378. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  30379. /**
  30380. * Begin a new frame
  30381. */
  30382. beginFrame(): void;
  30383. /**
  30384. * Enf the current frame
  30385. */
  30386. endFrame(): void;
  30387. /**
  30388. * Resize the view according to the canvas' size
  30389. */
  30390. resize(): void;
  30391. /**
  30392. * Force a specific size of the canvas
  30393. * @param width defines the new canvas' width
  30394. * @param height defines the new canvas' height
  30395. */
  30396. setSize(width: number, height: number): void;
  30397. /**
  30398. * Gets a boolean indicating if a webVR device was detected
  30399. * @returns true if a webVR device was detected
  30400. */
  30401. isVRDevicePresent(): boolean;
  30402. /**
  30403. * Gets the current webVR device
  30404. * @returns the current webVR device (or null)
  30405. */
  30406. getVRDevice(): any;
  30407. /**
  30408. * Initializes a webVR display and starts listening to display change events
  30409. * The onVRDisplayChangedObservable will be notified upon these changes
  30410. * @returns The onVRDisplayChangedObservable
  30411. */
  30412. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30413. /**
  30414. * Initializes a webVR display and starts listening to display change events
  30415. * The onVRDisplayChangedObservable will be notified upon these changes
  30416. * @returns A promise containing a VRDisplay and if vr is supported
  30417. */
  30418. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  30419. /**
  30420. * Call this function to switch to webVR mode
  30421. * Will do nothing if webVR is not supported or if there is no webVR device
  30422. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30423. */
  30424. enableVR(): void;
  30425. /**
  30426. * Call this function to leave webVR mode
  30427. * Will do nothing if webVR is not supported or if there is no webVR device
  30428. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30429. */
  30430. disableVR(): void;
  30431. private _onVRFullScreenTriggered;
  30432. private _getVRDisplaysAsync;
  30433. /**
  30434. * Binds the frame buffer to the specified texture.
  30435. * @param texture The texture to render to or null for the default canvas
  30436. * @param faceIndex The face of the texture to render to in case of cube texture
  30437. * @param requiredWidth The width of the target to render to
  30438. * @param requiredHeight The height of the target to render to
  30439. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30440. * @param depthStencilTexture The depth stencil texture to use to render
  30441. * @param lodLevel defines le lod level to bind to the frame buffer
  30442. */
  30443. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30444. private bindUnboundFramebuffer;
  30445. /**
  30446. * Unbind the current render target texture from the webGL context
  30447. * @param texture defines the render target texture to unbind
  30448. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30449. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30450. */
  30451. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30452. /**
  30453. * Unbind a list of render target textures from the webGL context
  30454. * This is used only when drawBuffer extension or webGL2 are active
  30455. * @param textures defines the render target textures to unbind
  30456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30458. */
  30459. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30460. /**
  30461. * Force the mipmap generation for the given render target texture
  30462. * @param texture defines the render target texture to use
  30463. */
  30464. generateMipMapsForCubemap(texture: InternalTexture): void;
  30465. /**
  30466. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30467. */
  30468. flushFramebuffer(): void;
  30469. /**
  30470. * Unbind the current render target and bind the default framebuffer
  30471. */
  30472. restoreDefaultFramebuffer(): void;
  30473. /**
  30474. * Create an uniform buffer
  30475. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30476. * @param elements defines the content of the uniform buffer
  30477. * @returns the webGL uniform buffer
  30478. */
  30479. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  30480. /**
  30481. * Create a dynamic uniform buffer
  30482. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30483. * @param elements defines the content of the uniform buffer
  30484. * @returns the webGL uniform buffer
  30485. */
  30486. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  30487. /**
  30488. * Update an existing uniform buffer
  30489. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30490. * @param uniformBuffer defines the target uniform buffer
  30491. * @param elements defines the content to update
  30492. * @param offset defines the offset in the uniform buffer where update should start
  30493. * @param count defines the size of the data to update
  30494. */
  30495. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30496. private _resetVertexBufferBinding;
  30497. /**
  30498. * Creates a vertex buffer
  30499. * @param data the data for the vertex buffer
  30500. * @returns the new WebGL static buffer
  30501. */
  30502. createVertexBuffer(data: DataArray): WebGLBuffer;
  30503. /**
  30504. * Creates a dynamic vertex buffer
  30505. * @param data the data for the dynamic vertex buffer
  30506. * @returns the new WebGL dynamic buffer
  30507. */
  30508. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  30509. /**
  30510. * Update a dynamic index buffer
  30511. * @param indexBuffer defines the target index buffer
  30512. * @param indices defines the data to update
  30513. * @param offset defines the offset in the target index buffer where update should start
  30514. */
  30515. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  30516. /**
  30517. * Updates a dynamic vertex buffer.
  30518. * @param vertexBuffer the vertex buffer to update
  30519. * @param data the data used to update the vertex buffer
  30520. * @param byteOffset the byte offset of the data
  30521. * @param byteLength the byte length of the data
  30522. */
  30523. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30524. private _resetIndexBufferBinding;
  30525. /**
  30526. * Creates a new index buffer
  30527. * @param indices defines the content of the index buffer
  30528. * @param updatable defines if the index buffer must be updatable
  30529. * @returns a new webGL buffer
  30530. */
  30531. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  30532. /**
  30533. * Bind a webGL buffer to the webGL context
  30534. * @param buffer defines the buffer to bind
  30535. */
  30536. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  30537. /**
  30538. * Bind an uniform buffer to the current webGL context
  30539. * @param buffer defines the buffer to bind
  30540. */
  30541. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  30542. /**
  30543. * Bind a buffer to the current webGL context at a given location
  30544. * @param buffer defines the buffer to bind
  30545. * @param location defines the index where to bind the buffer
  30546. */
  30547. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  30548. /**
  30549. * Bind a specific block at a given index in a specific shader program
  30550. * @param shaderProgram defines the shader program
  30551. * @param blockName defines the block name
  30552. * @param index defines the index where to bind the block
  30553. */
  30554. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  30555. private bindIndexBuffer;
  30556. private bindBuffer;
  30557. /**
  30558. * update the bound buffer with the given data
  30559. * @param data defines the data to update
  30560. */
  30561. updateArrayBuffer(data: Float32Array): void;
  30562. private _vertexAttribPointer;
  30563. private _bindIndexBufferWithCache;
  30564. private _bindVertexBuffersAttributes;
  30565. /**
  30566. * Records a vertex array object
  30567. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30568. * @param vertexBuffers defines the list of vertex buffers to store
  30569. * @param indexBuffer defines the index buffer to store
  30570. * @param effect defines the effect to store
  30571. * @returns the new vertex array object
  30572. */
  30573. recordVertexArrayObject(vertexBuffers: {
  30574. [key: string]: VertexBuffer;
  30575. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  30576. /**
  30577. * Bind a specific vertex array object
  30578. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30579. * @param vertexArrayObject defines the vertex array object to bind
  30580. * @param indexBuffer defines the index buffer to bind
  30581. */
  30582. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  30583. /**
  30584. * Bind webGl buffers directly to the webGL context
  30585. * @param vertexBuffer defines the vertex buffer to bind
  30586. * @param indexBuffer defines the index buffer to bind
  30587. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30588. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30589. * @param effect defines the effect associated with the vertex buffer
  30590. */
  30591. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30592. private _unbindVertexArrayObject;
  30593. /**
  30594. * Bind a list of vertex buffers to the webGL context
  30595. * @param vertexBuffers defines the list of vertex buffers to bind
  30596. * @param indexBuffer defines the index buffer to bind
  30597. * @param effect defines the effect associated with the vertex buffers
  30598. */
  30599. bindBuffers(vertexBuffers: {
  30600. [key: string]: Nullable<VertexBuffer>;
  30601. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  30602. /**
  30603. * Unbind all instance attributes
  30604. */
  30605. unbindInstanceAttributes(): void;
  30606. /**
  30607. * Release and free the memory of a vertex array object
  30608. * @param vao defines the vertex array object to delete
  30609. */
  30610. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30611. /** @hidden */
  30612. _releaseBuffer(buffer: WebGLBuffer): boolean;
  30613. /**
  30614. * Creates a webGL buffer to use with instanciation
  30615. * @param capacity defines the size of the buffer
  30616. * @returns the webGL buffer
  30617. */
  30618. createInstancesBuffer(capacity: number): WebGLBuffer;
  30619. /**
  30620. * Delete a webGL buffer used with instanciation
  30621. * @param buffer defines the webGL buffer to delete
  30622. */
  30623. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30624. /**
  30625. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30626. * @param instancesBuffer defines the webGL buffer to update and bind
  30627. * @param data defines the data to store in the buffer
  30628. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30629. */
  30630. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30631. /**
  30632. * Apply all cached states (depth, culling, stencil and alpha)
  30633. */
  30634. applyStates(): void;
  30635. /**
  30636. * Send a draw order
  30637. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30638. * @param indexStart defines the starting index
  30639. * @param indexCount defines the number of index to draw
  30640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30641. */
  30642. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30643. /**
  30644. * Draw a list of points
  30645. * @param verticesStart defines the index of first vertex to draw
  30646. * @param verticesCount defines the count of vertices to draw
  30647. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30648. */
  30649. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30650. /**
  30651. * Draw a list of unindexed primitives
  30652. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30653. * @param verticesStart defines the index of first vertex to draw
  30654. * @param verticesCount defines the count of vertices to draw
  30655. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30656. */
  30657. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30658. /**
  30659. * Draw a list of indexed primitives
  30660. * @param fillMode defines the primitive to use
  30661. * @param indexStart defines the starting index
  30662. * @param indexCount defines the number of index to draw
  30663. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30664. */
  30665. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30666. /**
  30667. * Draw a list of unindexed primitives
  30668. * @param fillMode defines the primitive to use
  30669. * @param verticesStart defines the index of first vertex to draw
  30670. * @param verticesCount defines the count of vertices to draw
  30671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30672. */
  30673. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30674. private _drawMode;
  30675. /** @hidden */
  30676. _releaseEffect(effect: Effect): void;
  30677. /** @hidden */
  30678. _deleteProgram(program: WebGLProgram): void;
  30679. /**
  30680. * Create a new effect (used to store vertex/fragment shaders)
  30681. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30682. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30683. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30684. * @param samplers defines an array of string used to represent textures
  30685. * @param defines defines the string containing the defines to use to compile the shaders
  30686. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30687. * @param onCompiled defines a function to call when the effect creation is successful
  30688. * @param onError defines a function to call when the effect creation has failed
  30689. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30690. * @returns the new Effect
  30691. */
  30692. 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;
  30693. private _compileShader;
  30694. private _compileRawShader;
  30695. /**
  30696. * Directly creates a webGL program
  30697. * @param vertexCode defines the vertex shader code to use
  30698. * @param fragmentCode defines the fragment shader code to use
  30699. * @param context defines the webGL context to use (if not set, the current one will be used)
  30700. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30701. * @returns the new webGL program
  30702. */
  30703. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30704. /**
  30705. * Creates a webGL program
  30706. * @param vertexCode defines the vertex shader code to use
  30707. * @param fragmentCode defines the fragment shader code to use
  30708. * @param defines defines the string containing the defines to use to compile the shaders
  30709. * @param context defines the webGL context to use (if not set, the current one will be used)
  30710. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30711. * @returns the new webGL program
  30712. */
  30713. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30714. private _createShaderProgram;
  30715. private _finalizeProgram;
  30716. /** @hidden */
  30717. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  30718. /** @hidden */
  30719. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  30720. /**
  30721. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30722. * @param shaderProgram defines the webGL program to use
  30723. * @param uniformsNames defines the list of uniform names
  30724. * @returns an array of webGL uniform locations
  30725. */
  30726. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30727. /**
  30728. * Gets the lsit of active attributes for a given webGL program
  30729. * @param shaderProgram defines the webGL program to use
  30730. * @param attributesNames defines the list of attribute names to get
  30731. * @returns an array of indices indicating the offset of each attribute
  30732. */
  30733. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  30734. /**
  30735. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30736. * @param effect defines the effect to activate
  30737. */
  30738. enableEffect(effect: Nullable<Effect>): void;
  30739. /**
  30740. * Set the value of an uniform to an array of int32
  30741. * @param uniform defines the webGL uniform location where to store the value
  30742. * @param array defines the array of int32 to store
  30743. */
  30744. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30745. /**
  30746. * Set the value of an uniform to an array of int32 (stored as vec2)
  30747. * @param uniform defines the webGL uniform location where to store the value
  30748. * @param array defines the array of int32 to store
  30749. */
  30750. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30751. /**
  30752. * Set the value of an uniform to an array of int32 (stored as vec3)
  30753. * @param uniform defines the webGL uniform location where to store the value
  30754. * @param array defines the array of int32 to store
  30755. */
  30756. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30757. /**
  30758. * Set the value of an uniform to an array of int32 (stored as vec4)
  30759. * @param uniform defines the webGL uniform location where to store the value
  30760. * @param array defines the array of int32 to store
  30761. */
  30762. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30763. /**
  30764. * Set the value of an uniform to an array of float32
  30765. * @param uniform defines the webGL uniform location where to store the value
  30766. * @param array defines the array of float32 to store
  30767. */
  30768. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30769. /**
  30770. * Set the value of an uniform to an array of float32 (stored as vec2)
  30771. * @param uniform defines the webGL uniform location where to store the value
  30772. * @param array defines the array of float32 to store
  30773. */
  30774. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30775. /**
  30776. * Set the value of an uniform to an array of float32 (stored as vec3)
  30777. * @param uniform defines the webGL uniform location where to store the value
  30778. * @param array defines the array of float32 to store
  30779. */
  30780. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30781. /**
  30782. * Set the value of an uniform to an array of float32 (stored as vec4)
  30783. * @param uniform defines the webGL uniform location where to store the value
  30784. * @param array defines the array of float32 to store
  30785. */
  30786. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30787. /**
  30788. * Set the value of an uniform to an array of number
  30789. * @param uniform defines the webGL uniform location where to store the value
  30790. * @param array defines the array of number to store
  30791. */
  30792. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30793. /**
  30794. * Set the value of an uniform to an array of number (stored as vec2)
  30795. * @param uniform defines the webGL uniform location where to store the value
  30796. * @param array defines the array of number to store
  30797. */
  30798. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30799. /**
  30800. * Set the value of an uniform to an array of number (stored as vec3)
  30801. * @param uniform defines the webGL uniform location where to store the value
  30802. * @param array defines the array of number to store
  30803. */
  30804. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30805. /**
  30806. * Set the value of an uniform to an array of number (stored as vec4)
  30807. * @param uniform defines the webGL uniform location where to store the value
  30808. * @param array defines the array of number to store
  30809. */
  30810. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30811. /**
  30812. * Set the value of an uniform to an array of float32 (stored as matrices)
  30813. * @param uniform defines the webGL uniform location where to store the value
  30814. * @param matrices defines the array of float32 to store
  30815. */
  30816. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30817. /**
  30818. * Set the value of an uniform to a matrix
  30819. * @param uniform defines the webGL uniform location where to store the value
  30820. * @param matrix defines the matrix to store
  30821. */
  30822. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  30823. /**
  30824. * Set the value of an uniform to a matrix (3x3)
  30825. * @param uniform defines the webGL uniform location where to store the value
  30826. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30827. */
  30828. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30829. /**
  30830. * Set the value of an uniform to a matrix (2x2)
  30831. * @param uniform defines the webGL uniform location where to store the value
  30832. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30833. */
  30834. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30835. /**
  30836. * Set the value of an uniform to a number (int)
  30837. * @param uniform defines the webGL uniform location where to store the value
  30838. * @param value defines the int number to store
  30839. */
  30840. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30841. /**
  30842. * Set the value of an uniform to a number (float)
  30843. * @param uniform defines the webGL uniform location where to store the value
  30844. * @param value defines the float number to store
  30845. */
  30846. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30847. /**
  30848. * Set the value of an uniform to a vec2
  30849. * @param uniform defines the webGL uniform location where to store the value
  30850. * @param x defines the 1st component of the value
  30851. * @param y defines the 2nd component of the value
  30852. */
  30853. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30854. /**
  30855. * Set the value of an uniform to a vec3
  30856. * @param uniform defines the webGL uniform location where to store the value
  30857. * @param x defines the 1st component of the value
  30858. * @param y defines the 2nd component of the value
  30859. * @param z defines the 3rd component of the value
  30860. */
  30861. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30862. /**
  30863. * Set the value of an uniform to a boolean
  30864. * @param uniform defines the webGL uniform location where to store the value
  30865. * @param bool defines the boolean to store
  30866. */
  30867. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30868. /**
  30869. * Set the value of an uniform to a vec4
  30870. * @param uniform defines the webGL uniform location where to store the value
  30871. * @param x defines the 1st component of the value
  30872. * @param y defines the 2nd component of the value
  30873. * @param z defines the 3rd component of the value
  30874. * @param w defines the 4th component of the value
  30875. */
  30876. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30877. /**
  30878. * Set the value of an uniform to a Color3
  30879. * @param uniform defines the webGL uniform location where to store the value
  30880. * @param color3 defines the color to store
  30881. */
  30882. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  30883. /**
  30884. * Set the value of an uniform to a Color3 and an alpha value
  30885. * @param uniform defines the webGL uniform location where to store the value
  30886. * @param color3 defines the color to store
  30887. * @param alpha defines the alpha component to store
  30888. */
  30889. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  30890. /**
  30891. * Sets a Color4 on a uniform variable
  30892. * @param uniform defines the uniform location
  30893. * @param color4 defines the value to be set
  30894. */
  30895. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  30896. /**
  30897. * Set various states to the webGL context
  30898. * @param culling defines backface culling state
  30899. * @param zOffset defines the value to apply to zOffset (0 by default)
  30900. * @param force defines if states must be applied even if cache is up to date
  30901. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30902. */
  30903. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30904. /**
  30905. * Set the z offset to apply to current rendering
  30906. * @param value defines the offset to apply
  30907. */
  30908. setZOffset(value: number): void;
  30909. /**
  30910. * Gets the current value of the zOffset
  30911. * @returns the current zOffset state
  30912. */
  30913. getZOffset(): number;
  30914. /**
  30915. * Enable or disable depth buffering
  30916. * @param enable defines the state to set
  30917. */
  30918. setDepthBuffer(enable: boolean): void;
  30919. /**
  30920. * Gets a boolean indicating if depth writing is enabled
  30921. * @returns the current depth writing state
  30922. */
  30923. getDepthWrite(): boolean;
  30924. /**
  30925. * Enable or disable depth writing
  30926. * @param enable defines the state to set
  30927. */
  30928. setDepthWrite(enable: boolean): void;
  30929. /**
  30930. * Enable or disable color writing
  30931. * @param enable defines the state to set
  30932. */
  30933. setColorWrite(enable: boolean): void;
  30934. /**
  30935. * Gets a boolean indicating if color writing is enabled
  30936. * @returns the current color writing state
  30937. */
  30938. getColorWrite(): boolean;
  30939. /**
  30940. * Sets alpha constants used by some alpha blending modes
  30941. * @param r defines the red component
  30942. * @param g defines the green component
  30943. * @param b defines the blue component
  30944. * @param a defines the alpha component
  30945. */
  30946. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30947. /**
  30948. * Sets the current alpha mode
  30949. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30950. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30952. */
  30953. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30954. /**
  30955. * Gets the current alpha mode
  30956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30957. * @returns the current alpha mode
  30958. */
  30959. getAlphaMode(): number;
  30960. /**
  30961. * Clears the list of texture accessible through engine.
  30962. * This can help preventing texture load conflict due to name collision.
  30963. */
  30964. clearInternalTexturesCache(): void;
  30965. /**
  30966. * Force the entire cache to be cleared
  30967. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30968. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30969. */
  30970. wipeCaches(bruteForce?: boolean): void;
  30971. /**
  30972. * Set the compressed texture format to use, based on the formats you have, and the formats
  30973. * supported by the hardware / browser.
  30974. *
  30975. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30976. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30977. * to API arguments needed to compressed textures. This puts the burden on the container
  30978. * generator to house the arcane code for determining these for current & future formats.
  30979. *
  30980. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30981. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30982. *
  30983. * Note: The result of this call is not taken into account when a texture is base64.
  30984. *
  30985. * @param formatsAvailable defines the list of those format families you have created
  30986. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30987. *
  30988. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30989. * @returns The extension selected.
  30990. */
  30991. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30992. private _getSamplingParameters;
  30993. private _partialLoadImg;
  30994. private _cascadeLoadImgs;
  30995. /** @hidden */
  30996. _createTexture(): WebGLTexture;
  30997. /**
  30998. * Usually called from Texture.ts.
  30999. * Passed information to create a WebGLTexture
  31000. * @param urlArg defines a value which contains one of the following:
  31001. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31002. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31003. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31004. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31005. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  31006. * @param scene needed for loading to the correct scene
  31007. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31008. * @param onLoad optional callback to be called upon successful completion
  31009. * @param onError optional callback to be called upon failure
  31010. * @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
  31011. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31012. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31013. * @param forcedExtension defines the extension to use to pick the right loader
  31014. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31015. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31016. */
  31017. 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;
  31018. private _rescaleTexture;
  31019. /**
  31020. * Update a raw texture
  31021. * @param texture defines the texture to update
  31022. * @param data defines the data to store in the texture
  31023. * @param format defines the format of the data
  31024. * @param invertY defines if data must be stored with Y axis inverted
  31025. * @param compression defines the compression used (null by default)
  31026. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31027. */
  31028. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  31029. /**
  31030. * Creates a raw texture
  31031. * @param data defines the data to store in the texture
  31032. * @param width defines the width of the texture
  31033. * @param height defines the height of the texture
  31034. * @param format defines the format of the data
  31035. * @param generateMipMaps defines if the engine should generate the mip levels
  31036. * @param invertY defines if data must be stored with Y axis inverted
  31037. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31038. * @param compression defines the compression used (null by default)
  31039. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31040. * @returns the raw texture inside an InternalTexture
  31041. */
  31042. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31043. private _unpackFlipYCached;
  31044. /**
  31045. * In case you are sharing the context with other applications, it might
  31046. * be interested to not cache the unpack flip y state to ensure a consistent
  31047. * value would be set.
  31048. */
  31049. enableUnpackFlipYCached: boolean;
  31050. /** @hidden */
  31051. _unpackFlipY(value: boolean): void;
  31052. /** @hidden */
  31053. _getUnpackAlignement(): number;
  31054. /**
  31055. * Creates a dynamic texture
  31056. * @param width defines the width of the texture
  31057. * @param height defines the height of the texture
  31058. * @param generateMipMaps defines if the engine should generate the mip levels
  31059. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31060. * @returns the dynamic texture inside an InternalTexture
  31061. */
  31062. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31063. /**
  31064. * Update the sampling mode of a given texture
  31065. * @param samplingMode defines the required sampling mode
  31066. * @param texture defines the texture to update
  31067. */
  31068. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31069. /**
  31070. * Update the content of a dynamic texture
  31071. * @param texture defines the texture to update
  31072. * @param canvas defines the canvas containing the source
  31073. * @param invertY defines if data must be stored with Y axis inverted
  31074. * @param premulAlpha defines if alpha is stored as premultiplied
  31075. * @param format defines the format of the data
  31076. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31077. */
  31078. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31079. /**
  31080. * Update a video texture
  31081. * @param texture defines the texture to update
  31082. * @param video defines the video element to use
  31083. * @param invertY defines if data must be stored with Y axis inverted
  31084. */
  31085. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31086. /**
  31087. * Updates a depth texture Comparison Mode and Function.
  31088. * If the comparison Function is equal to 0, the mode will be set to none.
  31089. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31090. * @param texture The texture to set the comparison function for
  31091. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31092. */
  31093. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31094. private _setupDepthStencilTexture;
  31095. /**
  31096. * Creates a depth stencil texture.
  31097. * This is only available in WebGL 2 or with the depth texture extension available.
  31098. * @param size The size of face edge in the texture.
  31099. * @param options The options defining the texture.
  31100. * @returns The texture
  31101. */
  31102. createDepthStencilTexture(size: number | {
  31103. width: number;
  31104. height: number;
  31105. }, options: DepthTextureCreationOptions): InternalTexture;
  31106. /**
  31107. * Creates a depth stencil texture.
  31108. * This is only available in WebGL 2 or with the depth texture extension available.
  31109. * @param size The size of face edge in the texture.
  31110. * @param options The options defining the texture.
  31111. * @returns The texture
  31112. */
  31113. private _createDepthStencilTexture;
  31114. /**
  31115. * Creates a depth stencil cube texture.
  31116. * This is only available in WebGL 2.
  31117. * @param size The size of face edge in the cube texture.
  31118. * @param options The options defining the cube texture.
  31119. * @returns The cube texture
  31120. */
  31121. private _createDepthStencilCubeTexture;
  31122. /**
  31123. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31124. * @param renderTarget The render target to set the frame buffer for
  31125. */
  31126. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31127. /**
  31128. * Creates a new render target texture
  31129. * @param size defines the size of the texture
  31130. * @param options defines the options used to create the texture
  31131. * @returns a new render target texture stored in an InternalTexture
  31132. */
  31133. createRenderTargetTexture(size: number | {
  31134. width: number;
  31135. height: number;
  31136. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31137. /**
  31138. * Create a multi render target texture
  31139. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31140. * @param size defines the size of the texture
  31141. * @param options defines the creation options
  31142. * @returns the cube texture as an InternalTexture
  31143. */
  31144. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  31145. private _setupFramebufferDepthAttachments;
  31146. /**
  31147. * Updates the sample count of a render target texture
  31148. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31149. * @param texture defines the texture to update
  31150. * @param samples defines the sample count to set
  31151. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31152. */
  31153. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31154. /**
  31155. * Update the sample count for a given multiple render target texture
  31156. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31157. * @param textures defines the textures to update
  31158. * @param samples defines the sample count to set
  31159. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31160. */
  31161. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  31162. /** @hidden */
  31163. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31164. /** @hidden */
  31165. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31166. /** @hidden */
  31167. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31168. /** @hidden */
  31169. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31170. /**
  31171. * Creates a new render target cube texture
  31172. * @param size defines the size of the texture
  31173. * @param options defines the options used to create the texture
  31174. * @returns a new render target cube texture stored in an InternalTexture
  31175. */
  31176. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  31177. /**
  31178. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  31179. * @param rootUrl defines the url where the file to load is located
  31180. * @param scene defines the current scene
  31181. * @param lodScale defines scale to apply to the mip map selection
  31182. * @param lodOffset defines offset to apply to the mip map selection
  31183. * @param onLoad defines an optional callback raised when the texture is loaded
  31184. * @param onError defines an optional callback raised if there is an issue to load the texture
  31185. * @param format defines the format of the data
  31186. * @param forcedExtension defines the extension to use to pick the right loader
  31187. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  31188. * @returns the cube texture as an InternalTexture
  31189. */
  31190. 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;
  31191. /**
  31192. * Creates a cube texture
  31193. * @param rootUrl defines the url where the files to load is located
  31194. * @param scene defines the current scene
  31195. * @param files defines the list of files to load (1 per face)
  31196. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31197. * @param onLoad defines an optional callback raised when the texture is loaded
  31198. * @param onError defines an optional callback raised if there is an issue to load the texture
  31199. * @param format defines the format of the data
  31200. * @param forcedExtension defines the extension to use to pick the right loader
  31201. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31202. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31203. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31204. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31205. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31206. * @returns the cube texture as an InternalTexture
  31207. */
  31208. 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;
  31209. /**
  31210. * @hidden
  31211. */
  31212. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31213. /**
  31214. * Update a raw cube texture
  31215. * @param texture defines the texture to udpdate
  31216. * @param data defines the data to store
  31217. * @param format defines the data format
  31218. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31219. * @param invertY defines if data must be stored with Y axis inverted
  31220. * @param compression defines the compression used (null by default)
  31221. * @param level defines which level of the texture to update
  31222. */
  31223. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  31224. /**
  31225. * Creates a new raw cube texture
  31226. * @param data defines the array of data to use to create each face
  31227. * @param size defines the size of the textures
  31228. * @param format defines the format of the data
  31229. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31230. * @param generateMipMaps defines if the engine should generate the mip levels
  31231. * @param invertY defines if data must be stored with Y axis inverted
  31232. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31233. * @param compression defines the compression used (null by default)
  31234. * @returns the cube texture as an InternalTexture
  31235. */
  31236. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31237. /**
  31238. * Creates a new raw cube texture from a specified url
  31239. * @param url defines the url where the data is located
  31240. * @param scene defines the current scene
  31241. * @param size defines the size of the textures
  31242. * @param format defines the format of the data
  31243. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31244. * @param noMipmap defines if the engine should avoid generating the mip levels
  31245. * @param callback defines a callback used to extract texture data from loaded data
  31246. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  31247. * @param onLoad defines a callback called when texture is loaded
  31248. * @param onError defines a callback called if there is an error
  31249. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31250. * @param invertY defines if data must be stored with Y axis inverted
  31251. * @returns the cube texture as an InternalTexture
  31252. */
  31253. 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;
  31254. /**
  31255. * Update a raw 3D texture
  31256. * @param texture defines the texture to update
  31257. * @param data defines the data to store
  31258. * @param format defines the data format
  31259. * @param invertY defines if data must be stored with Y axis inverted
  31260. * @param compression defines the used compression (can be null)
  31261. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31262. */
  31263. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  31264. /**
  31265. * Creates a new raw 3D texture
  31266. * @param data defines the data used to create the texture
  31267. * @param width defines the width of the texture
  31268. * @param height defines the height of the texture
  31269. * @param depth defines the depth of the texture
  31270. * @param format defines the format of the texture
  31271. * @param generateMipMaps defines if the engine must generate mip levels
  31272. * @param invertY defines if data must be stored with Y axis inverted
  31273. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31274. * @param compression defines the compressed used (can be null)
  31275. * @param textureType defines the compressed used (can be null)
  31276. * @returns a new raw 3D texture (stored in an InternalTexture)
  31277. */
  31278. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31279. private _prepareWebGLTextureContinuation;
  31280. private _prepareWebGLTexture;
  31281. private _convertRGBtoRGBATextureData;
  31282. /** @hidden */
  31283. _releaseFramebufferObjects(texture: InternalTexture): void;
  31284. /** @hidden */
  31285. _releaseTexture(texture: InternalTexture): void;
  31286. private setProgram;
  31287. private _boundUniforms;
  31288. /**
  31289. * Binds an effect to the webGL context
  31290. * @param effect defines the effect to bind
  31291. */
  31292. bindSamplers(effect: Effect): void;
  31293. private _moveBoundTextureOnTop;
  31294. private _getCorrectTextureChannel;
  31295. private _linkTrackers;
  31296. private _removeDesignatedSlot;
  31297. private _activateCurrentTexture;
  31298. /** @hidden */
  31299. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31300. /** @hidden */
  31301. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31302. /**
  31303. * Sets a texture to the webGL context from a postprocess
  31304. * @param channel defines the channel to use
  31305. * @param postProcess defines the source postprocess
  31306. */
  31307. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31308. /**
  31309. * Binds the output of the passed in post process to the texture channel specified
  31310. * @param channel The channel the texture should be bound to
  31311. * @param postProcess The post process which's output should be bound
  31312. */
  31313. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31314. /**
  31315. * Unbind all textures from the webGL context
  31316. */
  31317. unbindAllTextures(): void;
  31318. /**
  31319. * Sets a texture to the according uniform.
  31320. * @param channel The texture channel
  31321. * @param uniform The uniform to set
  31322. * @param texture The texture to apply
  31323. */
  31324. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31325. /**
  31326. * Sets a depth stencil texture from a render target to the according uniform.
  31327. * @param channel The texture channel
  31328. * @param uniform The uniform to set
  31329. * @param texture The render target texture containing the depth stencil texture to apply
  31330. */
  31331. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31332. private _bindSamplerUniformToChannel;
  31333. private _getTextureWrapMode;
  31334. private _setTexture;
  31335. /**
  31336. * Sets an array of texture to the webGL context
  31337. * @param channel defines the channel where the texture array must be set
  31338. * @param uniform defines the associated uniform location
  31339. * @param textures defines the array of textures to bind
  31340. */
  31341. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31342. /** @hidden */
  31343. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31344. private _setTextureParameterFloat;
  31345. private _setTextureParameterInteger;
  31346. /**
  31347. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31348. * @param x defines the x coordinate of the rectangle where pixels must be read
  31349. * @param y defines the y coordinate of the rectangle where pixels must be read
  31350. * @param width defines the width of the rectangle where pixels must be read
  31351. * @param height defines the height of the rectangle where pixels must be read
  31352. * @returns a Uint8Array containing RGBA colors
  31353. */
  31354. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31355. /**
  31356. * Add an externaly attached data from its key.
  31357. * This method call will fail and return false, if such key already exists.
  31358. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31359. * @param key the unique key that identifies the data
  31360. * @param data the data object to associate to the key for this Engine instance
  31361. * @return true if no such key were already present and the data was added successfully, false otherwise
  31362. */
  31363. addExternalData<T>(key: string, data: T): boolean;
  31364. /**
  31365. * Get an externaly attached data from its key
  31366. * @param key the unique key that identifies the data
  31367. * @return the associated data, if present (can be null), or undefined if not present
  31368. */
  31369. getExternalData<T>(key: string): T;
  31370. /**
  31371. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31372. * @param key the unique key that identifies the data
  31373. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31374. * @return the associated data, can be null if the factory returned null.
  31375. */
  31376. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31377. /**
  31378. * Remove an externaly attached data from the Engine instance
  31379. * @param key the unique key that identifies the data
  31380. * @return true if the data was successfully removed, false if it doesn't exist
  31381. */
  31382. removeExternalData(key: string): boolean;
  31383. /**
  31384. * Unbind all vertex attributes from the webGL context
  31385. */
  31386. unbindAllAttributes(): void;
  31387. /**
  31388. * 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
  31389. */
  31390. releaseEffects(): void;
  31391. /**
  31392. * Dispose and release all associated resources
  31393. */
  31394. dispose(): void;
  31395. /**
  31396. * Display the loading screen
  31397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31398. */
  31399. displayLoadingUI(): void;
  31400. /**
  31401. * Hide the loading screen
  31402. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31403. */
  31404. hideLoadingUI(): void;
  31405. /**
  31406. * Gets the current loading screen object
  31407. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31408. */
  31409. /**
  31410. * Sets the current loading screen object
  31411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31412. */
  31413. loadingScreen: ILoadingScreen;
  31414. /**
  31415. * Sets the current loading screen text
  31416. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31417. */
  31418. loadingUIText: string;
  31419. /**
  31420. * Sets the current loading screen background color
  31421. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31422. */
  31423. loadingUIBackgroundColor: string;
  31424. /**
  31425. * Attach a new callback raised when context lost event is fired
  31426. * @param callback defines the callback to call
  31427. */
  31428. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31429. /**
  31430. * Attach a new callback raised when context restored event is fired
  31431. * @param callback defines the callback to call
  31432. */
  31433. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31434. /**
  31435. * Gets the source code of the vertex shader associated with a specific webGL program
  31436. * @param program defines the program to use
  31437. * @returns a string containing the source code of the vertex shader associated with the program
  31438. */
  31439. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31440. /**
  31441. * Gets the source code of the fragment shader associated with a specific webGL program
  31442. * @param program defines the program to use
  31443. * @returns a string containing the source code of the fragment shader associated with the program
  31444. */
  31445. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31446. /**
  31447. * Get the current error code of the webGL context
  31448. * @returns the error code
  31449. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31450. */
  31451. getError(): number;
  31452. /**
  31453. * Gets the current framerate
  31454. * @returns a number representing the framerate
  31455. */
  31456. getFps(): number;
  31457. /**
  31458. * Gets the time spent between current and previous frame
  31459. * @returns a number representing the delta time in ms
  31460. */
  31461. getDeltaTime(): number;
  31462. private _measureFps;
  31463. /** @hidden */
  31464. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31465. private _canRenderToFloatFramebuffer;
  31466. private _canRenderToHalfFloatFramebuffer;
  31467. private _canRenderToFramebuffer;
  31468. /** @hidden */
  31469. _getWebGLTextureType(type: number): number;
  31470. private _getInternalFormat;
  31471. /** @hidden */
  31472. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31473. /** @hidden */
  31474. _getRGBAMultiSampleBufferFormat(type: number): number;
  31475. /** @hidden */
  31476. _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;
  31477. /** @hidden */
  31478. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31479. private _partialLoadFile;
  31480. private _cascadeLoadFiles;
  31481. /**
  31482. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31483. * @returns true if the engine can be created
  31484. * @ignorenaming
  31485. */
  31486. static isSupported(): boolean;
  31487. }
  31488. }
  31489. declare module "babylonjs/Behaviors/behavior" {
  31490. import { Nullable } from "babylonjs/types";
  31491. /**
  31492. * Interface used to define a behavior
  31493. */
  31494. export interface Behavior<T> {
  31495. /** gets or sets behavior's name */
  31496. name: string;
  31497. /**
  31498. * Function called when the behavior needs to be initialized (after attaching it to a target)
  31499. */
  31500. init(): void;
  31501. /**
  31502. * Called when the behavior is attached to a target
  31503. * @param target defines the target where the behavior is attached to
  31504. */
  31505. attach(target: T): void;
  31506. /**
  31507. * Called when the behavior is detached from its target
  31508. */
  31509. detach(): void;
  31510. }
  31511. /**
  31512. * Interface implemented by classes supporting behaviors
  31513. */
  31514. export interface IBehaviorAware<T> {
  31515. /**
  31516. * Attach a behavior
  31517. * @param behavior defines the behavior to attach
  31518. * @returns the current host
  31519. */
  31520. addBehavior(behavior: Behavior<T>): T;
  31521. /**
  31522. * Remove a behavior from the current object
  31523. * @param behavior defines the behavior to detach
  31524. * @returns the current host
  31525. */
  31526. removeBehavior(behavior: Behavior<T>): T;
  31527. /**
  31528. * Gets a behavior using its name to search
  31529. * @param name defines the name to search
  31530. * @returns the behavior or null if not found
  31531. */
  31532. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  31533. }
  31534. }
  31535. declare module "babylonjs/node" {
  31536. import { Scene } from "babylonjs/scene";
  31537. import { Nullable } from "babylonjs/types";
  31538. import { Matrix } from "babylonjs/Maths/math";
  31539. import { Engine } from "babylonjs/Engines/engine";
  31540. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  31541. import { Observable } from "babylonjs/Misc/observable";
  31542. import { Animatable } from "babylonjs/Animations/animatable";
  31543. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31544. import { Animation } from "babylonjs/Animations/animation";
  31545. import { AnimationRange } from "babylonjs/Animations/animation";
  31546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31547. /**
  31548. * Defines how a node can be built from a string name.
  31549. */
  31550. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31551. /**
  31552. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31553. */
  31554. export class Node implements IBehaviorAware<Node> {
  31555. /** @hidden */
  31556. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animation").AnimationRange;
  31557. private static _NodeConstructors;
  31558. /**
  31559. * Add a new node constructor
  31560. * @param type defines the type name of the node to construct
  31561. * @param constructorFunc defines the constructor function
  31562. */
  31563. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31564. /**
  31565. * Returns a node constructor based on type name
  31566. * @param type defines the type name
  31567. * @param name defines the new node name
  31568. * @param scene defines the hosting scene
  31569. * @param options defines optional options to transmit to constructors
  31570. * @returns the new constructor or null
  31571. */
  31572. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31573. /**
  31574. * Gets or sets the name of the node
  31575. */
  31576. name: string;
  31577. /**
  31578. * Gets or sets the id of the node
  31579. */
  31580. id: string;
  31581. /**
  31582. * Gets or sets the unique id of the node
  31583. */
  31584. uniqueId: number;
  31585. /**
  31586. * Gets or sets a string used to store user defined state for the node
  31587. */
  31588. state: string;
  31589. /**
  31590. * Gets or sets an object used to store user defined information for the node
  31591. */
  31592. metadata: any;
  31593. /**
  31594. * Gets or sets a boolean used to define if the node must be serialized
  31595. */
  31596. doNotSerialize: boolean;
  31597. /** @hidden */
  31598. _isDisposed: boolean;
  31599. /**
  31600. * Gets a list of Animations associated with the node
  31601. */
  31602. animations: import("babylonjs/Animations/animation").Animation[];
  31603. protected _ranges: {
  31604. [name: string]: Nullable<AnimationRange>;
  31605. };
  31606. /**
  31607. * Callback raised when the node is ready to be used
  31608. */
  31609. onReady: (node: Node) => void;
  31610. private _isEnabled;
  31611. private _isParentEnabled;
  31612. private _isReady;
  31613. /** @hidden */
  31614. _currentRenderId: number;
  31615. private _parentRenderId;
  31616. protected _childRenderId: number;
  31617. /** @hidden */
  31618. _waitingParentId: Nullable<string>;
  31619. /** @hidden */
  31620. _scene: Scene;
  31621. /** @hidden */
  31622. _cache: any;
  31623. private _parentNode;
  31624. private _children;
  31625. /** @hidden */
  31626. _worldMatrix: Matrix;
  31627. /** @hidden */
  31628. _worldMatrixDeterminant: number;
  31629. /** @hidden */
  31630. private _sceneRootNodesIndex;
  31631. /**
  31632. * Gets a boolean indicating if the node has been disposed
  31633. * @returns true if the node was disposed
  31634. */
  31635. isDisposed(): boolean;
  31636. /**
  31637. * Gets or sets the parent of the node
  31638. */
  31639. parent: Nullable<Node>;
  31640. private addToSceneRootNodes;
  31641. private removeFromSceneRootNodes;
  31642. private _animationPropertiesOverride;
  31643. /**
  31644. * Gets or sets the animation properties override
  31645. */
  31646. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31647. /**
  31648. * Gets a string idenfifying the name of the class
  31649. * @returns "Node" string
  31650. */
  31651. getClassName(): string;
  31652. /** @hidden */
  31653. readonly _isNode: boolean;
  31654. /**
  31655. * An event triggered when the mesh is disposed
  31656. */
  31657. onDisposeObservable: Observable<Node>;
  31658. private _onDisposeObserver;
  31659. /**
  31660. * Sets a callback that will be raised when the node will be disposed
  31661. */
  31662. onDispose: () => void;
  31663. /**
  31664. * Creates a new Node
  31665. * @param name the name and id to be given to this node
  31666. * @param scene the scene this node will be added to
  31667. * @param addToRootNodes the node will be added to scene.rootNodes
  31668. */
  31669. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  31670. /**
  31671. * Gets the scene of the node
  31672. * @returns a scene
  31673. */
  31674. getScene(): Scene;
  31675. /**
  31676. * Gets the engine of the node
  31677. * @returns a Engine
  31678. */
  31679. getEngine(): Engine;
  31680. private _behaviors;
  31681. /**
  31682. * Attach a behavior to the node
  31683. * @see http://doc.babylonjs.com/features/behaviour
  31684. * @param behavior defines the behavior to attach
  31685. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31686. * @returns the current Node
  31687. */
  31688. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31689. /**
  31690. * Remove an attached behavior
  31691. * @see http://doc.babylonjs.com/features/behaviour
  31692. * @param behavior defines the behavior to attach
  31693. * @returns the current Node
  31694. */
  31695. removeBehavior(behavior: Behavior<Node>): Node;
  31696. /**
  31697. * Gets the list of attached behaviors
  31698. * @see http://doc.babylonjs.com/features/behaviour
  31699. */
  31700. readonly behaviors: Behavior<Node>[];
  31701. /**
  31702. * Gets an attached behavior by name
  31703. * @param name defines the name of the behavior to look for
  31704. * @see http://doc.babylonjs.com/features/behaviour
  31705. * @returns null if behavior was not found else the requested behavior
  31706. */
  31707. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31708. /**
  31709. * Returns the latest update of the World matrix
  31710. * @returns a Matrix
  31711. */
  31712. getWorldMatrix(): Matrix;
  31713. /** @hidden */
  31714. _getWorldMatrixDeterminant(): number;
  31715. /**
  31716. * Returns directly the latest state of the mesh World matrix.
  31717. * A Matrix is returned.
  31718. */
  31719. readonly worldMatrixFromCache: Matrix;
  31720. /** @hidden */
  31721. _initCache(): void;
  31722. /** @hidden */
  31723. updateCache(force?: boolean): void;
  31724. /** @hidden */
  31725. _updateCache(ignoreParentClass?: boolean): void;
  31726. /** @hidden */
  31727. _isSynchronized(): boolean;
  31728. /** @hidden */
  31729. _markSyncedWithParent(): void;
  31730. /** @hidden */
  31731. isSynchronizedWithParent(): boolean;
  31732. /** @hidden */
  31733. isSynchronized(): boolean;
  31734. /**
  31735. * Is this node ready to be used/rendered
  31736. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  31737. * @return true if the node is ready
  31738. */
  31739. isReady(completeCheck?: boolean): boolean;
  31740. /**
  31741. * Is this node enabled?
  31742. * 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
  31743. * @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
  31744. * @return whether this node (and its parent) is enabled
  31745. */
  31746. isEnabled(checkAncestors?: boolean): boolean;
  31747. /** @hidden */
  31748. protected _syncParentEnabledState(): void;
  31749. /**
  31750. * Set the enabled state of this node
  31751. * @param value defines the new enabled state
  31752. */
  31753. setEnabled(value: boolean): void;
  31754. /**
  31755. * Is this node a descendant of the given node?
  31756. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  31757. * @param ancestor defines the parent node to inspect
  31758. * @returns a boolean indicating if this node is a descendant of the given node
  31759. */
  31760. isDescendantOf(ancestor: Node): boolean;
  31761. /** @hidden */
  31762. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  31763. /**
  31764. * Will return all nodes that have this node as ascendant
  31765. * @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
  31766. * @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
  31767. * @return all children nodes of all types
  31768. */
  31769. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  31770. /**
  31771. * Get all child-meshes of this node
  31772. * @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
  31773. * @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
  31774. * @returns an array of AbstractMesh
  31775. */
  31776. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  31777. /**
  31778. * Get all direct children of this node
  31779. * @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
  31780. * @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)
  31781. * @returns an array of Node
  31782. */
  31783. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  31784. /** @hidden */
  31785. _setReady(state: boolean): void;
  31786. /**
  31787. * Get an animation by name
  31788. * @param name defines the name of the animation to look for
  31789. * @returns null if not found else the requested animation
  31790. */
  31791. getAnimationByName(name: string): Nullable<Animation>;
  31792. /**
  31793. * Creates an animation range for this node
  31794. * @param name defines the name of the range
  31795. * @param from defines the starting key
  31796. * @param to defines the end key
  31797. */
  31798. createAnimationRange(name: string, from: number, to: number): void;
  31799. /**
  31800. * Delete a specific animation range
  31801. * @param name defines the name of the range to delete
  31802. * @param deleteFrames defines if animation frames from the range must be deleted as well
  31803. */
  31804. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  31805. /**
  31806. * Get an animation range by name
  31807. * @param name defines the name of the animation range to look for
  31808. * @returns null if not found else the requested animation range
  31809. */
  31810. getAnimationRange(name: string): Nullable<AnimationRange>;
  31811. /**
  31812. * Will start the animation sequence
  31813. * @param name defines the range frames for animation sequence
  31814. * @param loop defines if the animation should loop (false by default)
  31815. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  31816. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  31817. * @returns the object created for this animation. If range does not exist, it will return null
  31818. */
  31819. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  31820. /**
  31821. * Serialize animation ranges into a JSON compatible object
  31822. * @returns serialization object
  31823. */
  31824. serializeAnimationRanges(): any;
  31825. /**
  31826. * Computes the world matrix of the node
  31827. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  31828. * @returns the world matrix
  31829. */
  31830. computeWorldMatrix(force?: boolean): Matrix;
  31831. /**
  31832. * Releases resources associated with this node.
  31833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31835. */
  31836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31837. /**
  31838. * Parse animation range data from a serialization object and store them into a given node
  31839. * @param node defines where to store the animation ranges
  31840. * @param parsedNode defines the serialization object to read data from
  31841. * @param scene defines the hosting scene
  31842. */
  31843. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  31844. }
  31845. }
  31846. declare module "babylonjs/Animations/animation" {
  31847. import { Animatable } from "babylonjs/Animations/animatable";
  31848. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  31849. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  31850. import { Path2, Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  31851. import { Nullable } from "babylonjs/types";
  31852. import { Scene } from "babylonjs/scene";
  31853. import { IAnimatable } from "babylonjs/Misc/tools";
  31854. import { Node } from "babylonjs/node";
  31855. /**
  31856. * Represents the range of an animation
  31857. */
  31858. export class AnimationRange {
  31859. /**The name of the animation range**/
  31860. name: string;
  31861. /**The starting frame of the animation */
  31862. from: number;
  31863. /**The ending frame of the animation*/
  31864. to: number;
  31865. /**
  31866. * Initializes the range of an animation
  31867. * @param name The name of the animation range
  31868. * @param from The starting frame of the animation
  31869. * @param to The ending frame of the animation
  31870. */
  31871. constructor(
  31872. /**The name of the animation range**/
  31873. name: string,
  31874. /**The starting frame of the animation */
  31875. from: number,
  31876. /**The ending frame of the animation*/
  31877. to: number);
  31878. /**
  31879. * Makes a copy of the animation range
  31880. * @returns A copy of the animation range
  31881. */
  31882. clone(): AnimationRange;
  31883. }
  31884. /**
  31885. * Composed of a frame, and an action function
  31886. */
  31887. export class AnimationEvent {
  31888. /** The frame for which the event is triggered **/
  31889. frame: number;
  31890. /** The event to perform when triggered **/
  31891. action: (currentFrame: number) => void;
  31892. /** Specifies if the event should be triggered only once**/
  31893. onlyOnce?: boolean | undefined;
  31894. /**
  31895. * Specifies if the animation event is done
  31896. */
  31897. isDone: boolean;
  31898. /**
  31899. * Initializes the animation event
  31900. * @param frame The frame for which the event is triggered
  31901. * @param action The event to perform when triggered
  31902. * @param onlyOnce Specifies if the event should be triggered only once
  31903. */
  31904. constructor(
  31905. /** The frame for which the event is triggered **/
  31906. frame: number,
  31907. /** The event to perform when triggered **/
  31908. action: (currentFrame: number) => void,
  31909. /** Specifies if the event should be triggered only once**/
  31910. onlyOnce?: boolean | undefined);
  31911. /** @hidden */
  31912. _clone(): AnimationEvent;
  31913. }
  31914. /**
  31915. * A cursor which tracks a point on a path
  31916. */
  31917. export class PathCursor {
  31918. private path;
  31919. /**
  31920. * Stores path cursor callbacks for when an onchange event is triggered
  31921. */
  31922. private _onchange;
  31923. /**
  31924. * The value of the path cursor
  31925. */
  31926. value: number;
  31927. /**
  31928. * The animation array of the path cursor
  31929. */
  31930. animations: Animation[];
  31931. /**
  31932. * Initializes the path cursor
  31933. * @param path The path to track
  31934. */
  31935. constructor(path: Path2);
  31936. /**
  31937. * Gets the cursor point on the path
  31938. * @returns A point on the path cursor at the cursor location
  31939. */
  31940. getPoint(): Vector3;
  31941. /**
  31942. * Moves the cursor ahead by the step amount
  31943. * @param step The amount to move the cursor forward
  31944. * @returns This path cursor
  31945. */
  31946. moveAhead(step?: number): PathCursor;
  31947. /**
  31948. * Moves the cursor behind by the step amount
  31949. * @param step The amount to move the cursor back
  31950. * @returns This path cursor
  31951. */
  31952. moveBack(step?: number): PathCursor;
  31953. /**
  31954. * Moves the cursor by the step amount
  31955. * If the step amount is greater than one, an exception is thrown
  31956. * @param step The amount to move the cursor
  31957. * @returns This path cursor
  31958. */
  31959. move(step: number): PathCursor;
  31960. /**
  31961. * Ensures that the value is limited between zero and one
  31962. * @returns This path cursor
  31963. */
  31964. private ensureLimits;
  31965. /**
  31966. * Runs onchange callbacks on change (used by the animation engine)
  31967. * @returns This path cursor
  31968. */
  31969. private raiseOnChange;
  31970. /**
  31971. * Executes a function on change
  31972. * @param f A path cursor onchange callback
  31973. * @returns This path cursor
  31974. */
  31975. onchange(f: (cursor: PathCursor) => void): PathCursor;
  31976. }
  31977. /**
  31978. * Defines an interface which represents an animation key frame
  31979. */
  31980. export interface IAnimationKey {
  31981. /**
  31982. * Frame of the key frame
  31983. */
  31984. frame: number;
  31985. /**
  31986. * Value at the specifies key frame
  31987. */
  31988. value: any;
  31989. /**
  31990. * The input tangent for the cubic hermite spline
  31991. */
  31992. inTangent?: any;
  31993. /**
  31994. * The output tangent for the cubic hermite spline
  31995. */
  31996. outTangent?: any;
  31997. /**
  31998. * The animation interpolation type
  31999. */
  32000. interpolation?: AnimationKeyInterpolation;
  32001. }
  32002. /**
  32003. * Enum for the animation key frame interpolation type
  32004. */
  32005. export enum AnimationKeyInterpolation {
  32006. /**
  32007. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  32008. */
  32009. STEP = 1
  32010. }
  32011. /**
  32012. * Class used to store any kind of animation
  32013. */
  32014. export class Animation {
  32015. /**Name of the animation */
  32016. name: string;
  32017. /**Property to animate */
  32018. targetProperty: string;
  32019. /**The frames per second of the animation */
  32020. framePerSecond: number;
  32021. /**The data type of the animation */
  32022. dataType: number;
  32023. /**The loop mode of the animation */
  32024. loopMode?: number | undefined;
  32025. /**Specifies if blending should be enabled */
  32026. enableBlending?: boolean | undefined;
  32027. /**
  32028. * Use matrix interpolation instead of using direct key value when animating matrices
  32029. */
  32030. static AllowMatricesInterpolation: boolean;
  32031. /**
  32032. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32033. */
  32034. static AllowMatrixDecomposeForInterpolation: boolean;
  32035. /**
  32036. * Stores the key frames of the animation
  32037. */
  32038. private _keys;
  32039. /**
  32040. * Stores the easing function of the animation
  32041. */
  32042. private _easingFunction;
  32043. /**
  32044. * @hidden Internal use only
  32045. */
  32046. _runtimeAnimations: RuntimeAnimation[];
  32047. /**
  32048. * The set of event that will be linked to this animation
  32049. */
  32050. private _events;
  32051. /**
  32052. * Stores an array of target property paths
  32053. */
  32054. targetPropertyPath: string[];
  32055. /**
  32056. * Stores the blending speed of the animation
  32057. */
  32058. blendingSpeed: number;
  32059. /**
  32060. * Stores the animation ranges for the animation
  32061. */
  32062. private _ranges;
  32063. /**
  32064. * @hidden Internal use
  32065. */
  32066. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32067. /**
  32068. * Sets up an animation
  32069. * @param property The property to animate
  32070. * @param animationType The animation type to apply
  32071. * @param framePerSecond The frames per second of the animation
  32072. * @param easingFunction The easing function used in the animation
  32073. * @returns The created animation
  32074. */
  32075. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32076. /**
  32077. * Create and start an animation on a node
  32078. * @param name defines the name of the global animation that will be run on all nodes
  32079. * @param node defines the root node where the animation will take place
  32080. * @param targetProperty defines property to animate
  32081. * @param framePerSecond defines the number of frame per second yo use
  32082. * @param totalFrame defines the number of frames in total
  32083. * @param from defines the initial value
  32084. * @param to defines the final value
  32085. * @param loopMode defines which loop mode you want to use (off by default)
  32086. * @param easingFunction defines the easing function to use (linear by default)
  32087. * @param onAnimationEnd defines the callback to call when animation end
  32088. * @returns the animatable created for this animation
  32089. */
  32090. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32091. /**
  32092. * Create and start an animation on a node and its descendants
  32093. * @param name defines the name of the global animation that will be run on all nodes
  32094. * @param node defines the root node where the animation will take place
  32095. * @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
  32096. * @param targetProperty defines property to animate
  32097. * @param framePerSecond defines the number of frame per second to use
  32098. * @param totalFrame defines the number of frames in total
  32099. * @param from defines the initial value
  32100. * @param to defines the final value
  32101. * @param loopMode defines which loop mode you want to use (off by default)
  32102. * @param easingFunction defines the easing function to use (linear by default)
  32103. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32104. * @returns the list of animatables created for all nodes
  32105. * @example https://www.babylonjs-playground.com/#MH0VLI
  32106. */
  32107. 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[]>;
  32108. /**
  32109. * Creates a new animation, merges it with the existing animations and starts it
  32110. * @param name Name of the animation
  32111. * @param node Node which contains the scene that begins the animations
  32112. * @param targetProperty Specifies which property to animate
  32113. * @param framePerSecond The frames per second of the animation
  32114. * @param totalFrame The total number of frames
  32115. * @param from The frame at the beginning of the animation
  32116. * @param to The frame at the end of the animation
  32117. * @param loopMode Specifies the loop mode of the animation
  32118. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32119. * @param onAnimationEnd Callback to run once the animation is complete
  32120. * @returns Nullable animation
  32121. */
  32122. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32123. /**
  32124. * Transition property of an host to the target Value
  32125. * @param property The property to transition
  32126. * @param targetValue The target Value of the property
  32127. * @param host The object where the property to animate belongs
  32128. * @param scene Scene used to run the animation
  32129. * @param frameRate Framerate (in frame/s) to use
  32130. * @param transition The transition type we want to use
  32131. * @param duration The duration of the animation, in milliseconds
  32132. * @param onAnimationEnd Callback trigger at the end of the animation
  32133. * @returns Nullable animation
  32134. */
  32135. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32136. /**
  32137. * Return the array of runtime animations currently using this animation
  32138. */
  32139. readonly runtimeAnimations: RuntimeAnimation[];
  32140. /**
  32141. * Specifies if any of the runtime animations are currently running
  32142. */
  32143. readonly hasRunningRuntimeAnimations: boolean;
  32144. /**
  32145. * Initializes the animation
  32146. * @param name Name of the animation
  32147. * @param targetProperty Property to animate
  32148. * @param framePerSecond The frames per second of the animation
  32149. * @param dataType The data type of the animation
  32150. * @param loopMode The loop mode of the animation
  32151. * @param enableBlendings Specifies if blending should be enabled
  32152. */
  32153. constructor(
  32154. /**Name of the animation */
  32155. name: string,
  32156. /**Property to animate */
  32157. targetProperty: string,
  32158. /**The frames per second of the animation */
  32159. framePerSecond: number,
  32160. /**The data type of the animation */
  32161. dataType: number,
  32162. /**The loop mode of the animation */
  32163. loopMode?: number | undefined,
  32164. /**Specifies if blending should be enabled */
  32165. enableBlending?: boolean | undefined);
  32166. /**
  32167. * Converts the animation to a string
  32168. * @param fullDetails support for multiple levels of logging within scene loading
  32169. * @returns String form of the animation
  32170. */
  32171. toString(fullDetails?: boolean): string;
  32172. /**
  32173. * Add an event to this animation
  32174. * @param event Event to add
  32175. */
  32176. addEvent(event: AnimationEvent): void;
  32177. /**
  32178. * Remove all events found at the given frame
  32179. * @param frame The frame to remove events from
  32180. */
  32181. removeEvents(frame: number): void;
  32182. /**
  32183. * Retrieves all the events from the animation
  32184. * @returns Events from the animation
  32185. */
  32186. getEvents(): AnimationEvent[];
  32187. /**
  32188. * Creates an animation range
  32189. * @param name Name of the animation range
  32190. * @param from Starting frame of the animation range
  32191. * @param to Ending frame of the animation
  32192. */
  32193. createRange(name: string, from: number, to: number): void;
  32194. /**
  32195. * Deletes an animation range by name
  32196. * @param name Name of the animation range to delete
  32197. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32198. */
  32199. deleteRange(name: string, deleteFrames?: boolean): void;
  32200. /**
  32201. * Gets the animation range by name, or null if not defined
  32202. * @param name Name of the animation range
  32203. * @returns Nullable animation range
  32204. */
  32205. getRange(name: string): Nullable<AnimationRange>;
  32206. /**
  32207. * Gets the key frames from the animation
  32208. * @returns The key frames of the animation
  32209. */
  32210. getKeys(): Array<IAnimationKey>;
  32211. /**
  32212. * Gets the highest frame rate of the animation
  32213. * @returns Highest frame rate of the animation
  32214. */
  32215. getHighestFrame(): number;
  32216. /**
  32217. * Gets the easing function of the animation
  32218. * @returns Easing function of the animation
  32219. */
  32220. getEasingFunction(): IEasingFunction;
  32221. /**
  32222. * Sets the easing function of the animation
  32223. * @param easingFunction A custom mathematical formula for animation
  32224. */
  32225. setEasingFunction(easingFunction: EasingFunction): void;
  32226. /**
  32227. * Interpolates a scalar linearly
  32228. * @param startValue Start value of the animation curve
  32229. * @param endValue End value of the animation curve
  32230. * @param gradient Scalar amount to interpolate
  32231. * @returns Interpolated scalar value
  32232. */
  32233. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32234. /**
  32235. * Interpolates a scalar cubically
  32236. * @param startValue Start value of the animation curve
  32237. * @param outTangent End tangent of the animation
  32238. * @param endValue End value of the animation curve
  32239. * @param inTangent Start tangent of the animation curve
  32240. * @param gradient Scalar amount to interpolate
  32241. * @returns Interpolated scalar value
  32242. */
  32243. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32244. /**
  32245. * Interpolates a quaternion using a spherical linear interpolation
  32246. * @param startValue Start value of the animation curve
  32247. * @param endValue End value of the animation curve
  32248. * @param gradient Scalar amount to interpolate
  32249. * @returns Interpolated quaternion value
  32250. */
  32251. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32252. /**
  32253. * Interpolates a quaternion cubically
  32254. * @param startValue Start value of the animation curve
  32255. * @param outTangent End tangent of the animation curve
  32256. * @param endValue End value of the animation curve
  32257. * @param inTangent Start tangent of the animation curve
  32258. * @param gradient Scalar amount to interpolate
  32259. * @returns Interpolated quaternion value
  32260. */
  32261. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32262. /**
  32263. * Interpolates a Vector3 linearl
  32264. * @param startValue Start value of the animation curve
  32265. * @param endValue End value of the animation curve
  32266. * @param gradient Scalar amount to interpolate
  32267. * @returns Interpolated scalar value
  32268. */
  32269. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32270. /**
  32271. * Interpolates a Vector3 cubically
  32272. * @param startValue Start value of the animation curve
  32273. * @param outTangent End tangent of the animation
  32274. * @param endValue End value of the animation curve
  32275. * @param inTangent Start tangent of the animation curve
  32276. * @param gradient Scalar amount to interpolate
  32277. * @returns InterpolatedVector3 value
  32278. */
  32279. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32280. /**
  32281. * Interpolates a Vector2 linearly
  32282. * @param startValue Start value of the animation curve
  32283. * @param endValue End value of the animation curve
  32284. * @param gradient Scalar amount to interpolate
  32285. * @returns Interpolated Vector2 value
  32286. */
  32287. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32288. /**
  32289. * Interpolates a Vector2 cubically
  32290. * @param startValue Start value of the animation curve
  32291. * @param outTangent End tangent of the animation
  32292. * @param endValue End value of the animation curve
  32293. * @param inTangent Start tangent of the animation curve
  32294. * @param gradient Scalar amount to interpolate
  32295. * @returns Interpolated Vector2 value
  32296. */
  32297. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32298. /**
  32299. * Interpolates a size linearly
  32300. * @param startValue Start value of the animation curve
  32301. * @param endValue End value of the animation curve
  32302. * @param gradient Scalar amount to interpolate
  32303. * @returns Interpolated Size value
  32304. */
  32305. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32306. /**
  32307. * Interpolates a Color3 linearly
  32308. * @param startValue Start value of the animation curve
  32309. * @param endValue End value of the animation curve
  32310. * @param gradient Scalar amount to interpolate
  32311. * @returns Interpolated Color3 value
  32312. */
  32313. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32314. /**
  32315. * @hidden Internal use only
  32316. */
  32317. _getKeyValue(value: any): any;
  32318. /**
  32319. * @hidden Internal use only
  32320. */
  32321. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  32322. /**
  32323. * Defines the function to use to interpolate matrices
  32324. * @param startValue defines the start matrix
  32325. * @param endValue defines the end matrix
  32326. * @param gradient defines the gradient between both matrices
  32327. * @param result defines an optional target matrix where to store the interpolation
  32328. * @returns the interpolated matrix
  32329. */
  32330. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32331. /**
  32332. * Makes a copy of the animation
  32333. * @returns Cloned animation
  32334. */
  32335. clone(): Animation;
  32336. /**
  32337. * Sets the key frames of the animation
  32338. * @param values The animation key frames to set
  32339. */
  32340. setKeys(values: Array<IAnimationKey>): void;
  32341. /**
  32342. * Serializes the animation to an object
  32343. * @returns Serialized object
  32344. */
  32345. serialize(): any;
  32346. /**
  32347. * Float animation type
  32348. */
  32349. private static _ANIMATIONTYPE_FLOAT;
  32350. /**
  32351. * Vector3 animation type
  32352. */
  32353. private static _ANIMATIONTYPE_VECTOR3;
  32354. /**
  32355. * Quaternion animation type
  32356. */
  32357. private static _ANIMATIONTYPE_QUATERNION;
  32358. /**
  32359. * Matrix animation type
  32360. */
  32361. private static _ANIMATIONTYPE_MATRIX;
  32362. /**
  32363. * Color3 animation type
  32364. */
  32365. private static _ANIMATIONTYPE_COLOR3;
  32366. /**
  32367. * Vector2 animation type
  32368. */
  32369. private static _ANIMATIONTYPE_VECTOR2;
  32370. /**
  32371. * Size animation type
  32372. */
  32373. private static _ANIMATIONTYPE_SIZE;
  32374. /**
  32375. * Relative Loop Mode
  32376. */
  32377. private static _ANIMATIONLOOPMODE_RELATIVE;
  32378. /**
  32379. * Cycle Loop Mode
  32380. */
  32381. private static _ANIMATIONLOOPMODE_CYCLE;
  32382. /**
  32383. * Constant Loop Mode
  32384. */
  32385. private static _ANIMATIONLOOPMODE_CONSTANT;
  32386. /**
  32387. * Get the float animation type
  32388. */
  32389. static readonly ANIMATIONTYPE_FLOAT: number;
  32390. /**
  32391. * Get the Vector3 animation type
  32392. */
  32393. static readonly ANIMATIONTYPE_VECTOR3: number;
  32394. /**
  32395. * Get the Vector2 animation type
  32396. */
  32397. static readonly ANIMATIONTYPE_VECTOR2: number;
  32398. /**
  32399. * Get the Size animation type
  32400. */
  32401. static readonly ANIMATIONTYPE_SIZE: number;
  32402. /**
  32403. * Get the Quaternion animation type
  32404. */
  32405. static readonly ANIMATIONTYPE_QUATERNION: number;
  32406. /**
  32407. * Get the Matrix animation type
  32408. */
  32409. static readonly ANIMATIONTYPE_MATRIX: number;
  32410. /**
  32411. * Get the Color3 animation type
  32412. */
  32413. static readonly ANIMATIONTYPE_COLOR3: number;
  32414. /**
  32415. * Get the Relative Loop Mode
  32416. */
  32417. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32418. /**
  32419. * Get the Cycle Loop Mode
  32420. */
  32421. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32422. /**
  32423. * Get the Constant Loop Mode
  32424. */
  32425. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32426. /** @hidden */
  32427. static _UniversalLerp(left: any, right: any, amount: number): any;
  32428. /**
  32429. * Parses an animation object and creates an animation
  32430. * @param parsedAnimation Parsed animation object
  32431. * @returns Animation object
  32432. */
  32433. static Parse(parsedAnimation: any): Animation;
  32434. /**
  32435. * Appends the serialized animations from the source animations
  32436. * @param source Source containing the animations
  32437. * @param destination Target to store the animations
  32438. */
  32439. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32440. }
  32441. }
  32442. declare module "babylonjs/Shaders/fxaa.fragment" {
  32443. export var fxaaPixelShader: {
  32444. name: string;
  32445. shader: string;
  32446. };
  32447. }
  32448. declare module "babylonjs/Shaders/fxaa.vertex" {
  32449. export var fxaaVertexShader: {
  32450. name: string;
  32451. shader: string;
  32452. };
  32453. }
  32454. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  32455. import { Nullable } from "babylonjs/types";
  32456. import { Camera } from "babylonjs/Cameras/camera";
  32457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  32458. import { Engine } from "babylonjs/Engines/engine";
  32459. import "Shaders/fxaa.fragment";
  32460. import "Shaders/fxaa.vertex";
  32461. /**
  32462. * Fxaa post process
  32463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  32464. */
  32465. export class FxaaPostProcess extends PostProcess {
  32466. /** @hidden */
  32467. texelWidth: number;
  32468. /** @hidden */
  32469. texelHeight: number;
  32470. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  32471. private _getDefines;
  32472. }
  32473. }
  32474. declare module "babylonjs/Misc/tga" {
  32475. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32476. /**
  32477. * Based on jsTGALoader - Javascript loader for TGA file
  32478. * By Vincent Thibault
  32479. * @see http://blog.robrowser.com/javascript-tga-loader.html
  32480. */
  32481. export class TGATools {
  32482. private static _TYPE_INDEXED;
  32483. private static _TYPE_RGB;
  32484. private static _TYPE_GREY;
  32485. private static _TYPE_RLE_INDEXED;
  32486. private static _TYPE_RLE_RGB;
  32487. private static _TYPE_RLE_GREY;
  32488. private static _ORIGIN_MASK;
  32489. private static _ORIGIN_SHIFT;
  32490. private static _ORIGIN_BL;
  32491. private static _ORIGIN_BR;
  32492. private static _ORIGIN_UL;
  32493. private static _ORIGIN_UR;
  32494. /**
  32495. * Gets the header of a TGA file
  32496. * @param data defines the TGA data
  32497. * @returns the header
  32498. */
  32499. static GetTGAHeader(data: Uint8Array): any;
  32500. /**
  32501. * Uploads TGA content to a Babylon Texture
  32502. * @hidden
  32503. */
  32504. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  32505. /** @hidden */
  32506. 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;
  32507. /** @hidden */
  32508. 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;
  32509. /** @hidden */
  32510. 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;
  32511. /** @hidden */
  32512. 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;
  32513. /** @hidden */
  32514. 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;
  32515. /** @hidden */
  32516. 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;
  32517. }
  32518. }
  32519. declare module "babylonjs/Misc/tools" {
  32520. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  32521. import { Animation } from "babylonjs/Animations/animation";
  32522. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  32523. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32524. import { Camera } from "babylonjs/Cameras/camera";
  32525. import { Observable } from "babylonjs/Misc/observable";
  32526. import { DomManagement } from "babylonjs/Misc/domManagement";
  32527. import { Engine } from "babylonjs/Engines/engine";
  32528. /**
  32529. * Interface for any object that can request an animation frame
  32530. */
  32531. export interface ICustomAnimationFrameRequester {
  32532. /**
  32533. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32534. */
  32535. renderFunction?: Function;
  32536. /**
  32537. * Called to request the next frame to render to
  32538. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32539. */
  32540. requestAnimationFrame: Function;
  32541. /**
  32542. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32543. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32544. */
  32545. requestID?: number;
  32546. }
  32547. /**
  32548. * Interface containing an array of animations
  32549. */
  32550. export interface IAnimatable {
  32551. /**
  32552. * Array of animations
  32553. */
  32554. animations: Array<Animation>;
  32555. }
  32556. /** Interface used by value gradients (color, factor, ...) */
  32557. export interface IValueGradient {
  32558. /**
  32559. * Gets or sets the gradient value (between 0 and 1)
  32560. */
  32561. gradient: number;
  32562. }
  32563. /** Class used to store color4 gradient */
  32564. export class ColorGradient implements IValueGradient {
  32565. /**
  32566. * Gets or sets the gradient value (between 0 and 1)
  32567. */
  32568. gradient: number;
  32569. /**
  32570. * Gets or sets first associated color
  32571. */
  32572. color1: Color4;
  32573. /**
  32574. * Gets or sets second associated color
  32575. */
  32576. color2?: Color4;
  32577. /**
  32578. * Will get a color picked randomly between color1 and color2.
  32579. * If color2 is undefined then color1 will be used
  32580. * @param result defines the target Color4 to store the result in
  32581. */
  32582. getColorToRef(result: Color4): void;
  32583. }
  32584. /** Class used to store color 3 gradient */
  32585. export class Color3Gradient implements IValueGradient {
  32586. /**
  32587. * Gets or sets the gradient value (between 0 and 1)
  32588. */
  32589. gradient: number;
  32590. /**
  32591. * Gets or sets the associated color
  32592. */
  32593. color: Color3;
  32594. }
  32595. /** Class used to store factor gradient */
  32596. export class FactorGradient implements IValueGradient {
  32597. /**
  32598. * Gets or sets the gradient value (between 0 and 1)
  32599. */
  32600. gradient: number;
  32601. /**
  32602. * Gets or sets first associated factor
  32603. */
  32604. factor1: number;
  32605. /**
  32606. * Gets or sets second associated factor
  32607. */
  32608. factor2?: number;
  32609. /**
  32610. * Will get a number picked randomly between factor1 and factor2.
  32611. * If factor2 is undefined then factor1 will be used
  32612. * @returns the picked number
  32613. */
  32614. getFactor(): number;
  32615. }
  32616. /**
  32617. * @ignore
  32618. * Application error to support additional information when loading a file
  32619. */
  32620. export class LoadFileError extends Error {
  32621. /** defines the optional XHR request */
  32622. request?: XMLHttpRequest | undefined;
  32623. private static _setPrototypeOf;
  32624. /**
  32625. * Creates a new LoadFileError
  32626. * @param message defines the message of the error
  32627. * @param request defines the optional XHR request
  32628. */
  32629. constructor(message: string,
  32630. /** defines the optional XHR request */
  32631. request?: XMLHttpRequest | undefined);
  32632. }
  32633. /**
  32634. * Class used to define a retry strategy when error happens while loading assets
  32635. */
  32636. export class RetryStrategy {
  32637. /**
  32638. * Function used to defines an exponential back off strategy
  32639. * @param maxRetries defines the maximum number of retries (3 by default)
  32640. * @param baseInterval defines the interval between retries
  32641. * @returns the strategy function to use
  32642. */
  32643. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32644. }
  32645. /**
  32646. * File request interface
  32647. */
  32648. export interface IFileRequest {
  32649. /**
  32650. * Raised when the request is complete (success or error).
  32651. */
  32652. onCompleteObservable: Observable<IFileRequest>;
  32653. /**
  32654. * Aborts the request for a file.
  32655. */
  32656. abort: () => void;
  32657. }
  32658. /**
  32659. * Class containing a set of static utilities functions
  32660. */
  32661. export class Tools {
  32662. /**
  32663. * Gets or sets the base URL to use to load assets
  32664. */
  32665. static BaseUrl: string;
  32666. /**
  32667. * Enable/Disable Custom HTTP Request Headers globally.
  32668. * default = false
  32669. * @see CustomRequestHeaders
  32670. */
  32671. static UseCustomRequestHeaders: boolean;
  32672. /**
  32673. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32674. * i.e. when loading files, where the server/service expects an Authorization header.
  32675. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  32676. */
  32677. static CustomRequestHeaders: {
  32678. [key: string]: string;
  32679. };
  32680. /**
  32681. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32682. */
  32683. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32684. /**
  32685. * Default behaviour for cors in the application.
  32686. * It can be a string if the expected behavior is identical in the entire app.
  32687. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32688. */
  32689. static CorsBehavior: string | ((url: string | string[]) => string);
  32690. /**
  32691. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32692. * @ignorenaming
  32693. */
  32694. static UseFallbackTexture: boolean;
  32695. /**
  32696. * Use this object to register external classes like custom textures or material
  32697. * to allow the laoders to instantiate them
  32698. */
  32699. static RegisteredExternalClasses: {
  32700. [key: string]: Object;
  32701. };
  32702. /**
  32703. * Texture content used if a texture cannot loaded
  32704. * @ignorenaming
  32705. */
  32706. static fallbackTexture: string;
  32707. /**
  32708. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32709. * @param u defines the coordinate on X axis
  32710. * @param v defines the coordinate on Y axis
  32711. * @param width defines the width of the source data
  32712. * @param height defines the height of the source data
  32713. * @param pixels defines the source byte array
  32714. * @param color defines the output color
  32715. */
  32716. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32717. /**
  32718. * Interpolates between a and b via alpha
  32719. * @param a The lower value (returned when alpha = 0)
  32720. * @param b The upper value (returned when alpha = 1)
  32721. * @param alpha The interpolation-factor
  32722. * @return The mixed value
  32723. */
  32724. static Mix(a: number, b: number, alpha: number): number;
  32725. /**
  32726. * Tries to instantiate a new object from a given class name
  32727. * @param className defines the class name to instantiate
  32728. * @returns the new object or null if the system was not able to do the instantiation
  32729. */
  32730. static Instantiate(className: string): any;
  32731. /**
  32732. * Provides a slice function that will work even on IE
  32733. * @param data defines the array to slice
  32734. * @param start defines the start of the data (optional)
  32735. * @param end defines the end of the data (optional)
  32736. * @returns the new sliced array
  32737. */
  32738. static Slice<T>(data: T, start?: number, end?: number): T;
  32739. /**
  32740. * Polyfill for setImmediate
  32741. * @param action defines the action to execute after the current execution block
  32742. */
  32743. static SetImmediate(action: () => void): void;
  32744. /**
  32745. * Function indicating if a number is an exponent of 2
  32746. * @param value defines the value to test
  32747. * @returns true if the value is an exponent of 2
  32748. */
  32749. static IsExponentOfTwo(value: number): boolean;
  32750. private static _tmpFloatArray;
  32751. /**
  32752. * Returns the nearest 32-bit single precision float representation of a Number
  32753. * @param value A Number. If the parameter is of a different type, it will get converted
  32754. * to a number or to NaN if it cannot be converted
  32755. * @returns number
  32756. */
  32757. static FloatRound(value: number): number;
  32758. /**
  32759. * Find the next highest power of two.
  32760. * @param x Number to start search from.
  32761. * @return Next highest power of two.
  32762. */
  32763. static CeilingPOT(x: number): number;
  32764. /**
  32765. * Find the next lowest power of two.
  32766. * @param x Number to start search from.
  32767. * @return Next lowest power of two.
  32768. */
  32769. static FloorPOT(x: number): number;
  32770. /**
  32771. * Find the nearest power of two.
  32772. * @param x Number to start search from.
  32773. * @return Next nearest power of two.
  32774. */
  32775. static NearestPOT(x: number): number;
  32776. /**
  32777. * Get the closest exponent of two
  32778. * @param value defines the value to approximate
  32779. * @param max defines the maximum value to return
  32780. * @param mode defines how to define the closest value
  32781. * @returns closest exponent of two of the given value
  32782. */
  32783. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32784. /**
  32785. * Extracts the filename from a path
  32786. * @param path defines the path to use
  32787. * @returns the filename
  32788. */
  32789. static GetFilename(path: string): string;
  32790. /**
  32791. * Extracts the "folder" part of a path (everything before the filename).
  32792. * @param uri The URI to extract the info from
  32793. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32794. * @returns The "folder" part of the path
  32795. */
  32796. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32797. /**
  32798. * Extracts text content from a DOM element hierarchy
  32799. * @param element defines the root element
  32800. * @returns a string
  32801. */
  32802. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32803. /**
  32804. * Convert an angle in radians to degrees
  32805. * @param angle defines the angle to convert
  32806. * @returns the angle in degrees
  32807. */
  32808. static ToDegrees(angle: number): number;
  32809. /**
  32810. * Convert an angle in degrees to radians
  32811. * @param angle defines the angle to convert
  32812. * @returns the angle in radians
  32813. */
  32814. static ToRadians(angle: number): number;
  32815. /**
  32816. * Encode a buffer to a base64 string
  32817. * @param buffer defines the buffer to encode
  32818. * @returns the encoded string
  32819. */
  32820. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32821. /**
  32822. * Extracts minimum and maximum values from a list of indexed positions
  32823. * @param positions defines the positions to use
  32824. * @param indices defines the indices to the positions
  32825. * @param indexStart defines the start index
  32826. * @param indexCount defines the end index
  32827. * @param bias defines bias value to add to the result
  32828. * @return minimum and maximum values
  32829. */
  32830. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32831. minimum: Vector3;
  32832. maximum: Vector3;
  32833. };
  32834. /**
  32835. * Extracts minimum and maximum values from a list of positions
  32836. * @param positions defines the positions to use
  32837. * @param start defines the start index in the positions array
  32838. * @param count defines the number of positions to handle
  32839. * @param bias defines bias value to add to the result
  32840. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32841. * @return minimum and maximum values
  32842. */
  32843. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32844. minimum: Vector3;
  32845. maximum: Vector3;
  32846. };
  32847. /**
  32848. * Returns an array if obj is not an array
  32849. * @param obj defines the object to evaluate as an array
  32850. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32851. * @returns either obj directly if obj is an array or a new array containing obj
  32852. */
  32853. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32854. /**
  32855. * Gets the pointer prefix to use
  32856. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32857. */
  32858. static GetPointerPrefix(): string;
  32859. /**
  32860. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32861. * @param func - the function to be called
  32862. * @param requester - the object that will request the next frame. Falls back to window.
  32863. * @returns frame number
  32864. */
  32865. static QueueNewFrame(func: () => void, requester?: any): number;
  32866. /**
  32867. * Ask the browser to promote the current element to fullscreen rendering mode
  32868. * @param element defines the DOM element to promote
  32869. */
  32870. static RequestFullscreen(element: HTMLElement): void;
  32871. /**
  32872. * Asks the browser to exit fullscreen mode
  32873. */
  32874. static ExitFullscreen(): void;
  32875. /**
  32876. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32877. * @param url define the url we are trying
  32878. * @param element define the dom element where to configure the cors policy
  32879. */
  32880. static SetCorsBehavior(url: string | string[], element: {
  32881. crossOrigin: string | null;
  32882. }): void;
  32883. /**
  32884. * Removes unwanted characters from an url
  32885. * @param url defines the url to clean
  32886. * @returns the cleaned url
  32887. */
  32888. static CleanUrl(url: string): string;
  32889. /**
  32890. * Gets or sets a function used to pre-process url before using them to load assets
  32891. */
  32892. static PreprocessUrl: (url: string) => string;
  32893. /**
  32894. * Loads an image as an HTMLImageElement.
  32895. * @param input url string, ArrayBuffer, or Blob to load
  32896. * @param onLoad callback called when the image successfully loads
  32897. * @param onError callback called when the image fails to load
  32898. * @param offlineProvider offline provider for caching
  32899. * @returns the HTMLImageElement of the loaded image
  32900. */
  32901. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32902. /**
  32903. * Loads a file
  32904. * @param url url string, ArrayBuffer, or Blob to load
  32905. * @param onSuccess callback called when the file successfully loads
  32906. * @param onProgress callback called while file is loading (if the server supports this mode)
  32907. * @param offlineProvider defines the offline provider for caching
  32908. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32909. * @param onError callback called when the file fails to load
  32910. * @returns a file request object
  32911. */
  32912. 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;
  32913. /**
  32914. * Load a script (identified by an url). When the url returns, the
  32915. * content of this file is added into a new script element, attached to the DOM (body element)
  32916. * @param scriptUrl defines the url of the script to laod
  32917. * @param onSuccess defines the callback called when the script is loaded
  32918. * @param onError defines the callback to call if an error occurs
  32919. */
  32920. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32921. /**
  32922. * Loads a file from a blob
  32923. * @param fileToLoad defines the blob to use
  32924. * @param callback defines the callback to call when data is loaded
  32925. * @param progressCallback defines the callback to call during loading process
  32926. * @returns a file request object
  32927. */
  32928. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32929. /**
  32930. * Loads a file
  32931. * @param fileToLoad defines the file to load
  32932. * @param callback defines the callback to call when data is loaded
  32933. * @param progressCallBack defines the callback to call during loading process
  32934. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32935. * @returns a file request object
  32936. */
  32937. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32938. /**
  32939. * Creates a data url from a given string content
  32940. * @param content defines the content to convert
  32941. * @returns the new data url link
  32942. */
  32943. static FileAsURL(content: string): string;
  32944. /**
  32945. * Format the given number to a specific decimal format
  32946. * @param value defines the number to format
  32947. * @param decimals defines the number of decimals to use
  32948. * @returns the formatted string
  32949. */
  32950. static Format(value: number, decimals?: number): string;
  32951. /**
  32952. * Checks if a given vector is inside a specific range
  32953. * @param v defines the vector to test
  32954. * @param min defines the minimum range
  32955. * @param max defines the maximum range
  32956. */
  32957. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32958. /**
  32959. * Tries to copy an object by duplicating every property
  32960. * @param source defines the source object
  32961. * @param destination defines the target object
  32962. * @param doNotCopyList defines a list of properties to avoid
  32963. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32964. */
  32965. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32966. /**
  32967. * Gets a boolean indicating if the given object has no own property
  32968. * @param obj defines the object to test
  32969. * @returns true if object has no own property
  32970. */
  32971. static IsEmpty(obj: any): boolean;
  32972. /**
  32973. * Function used to register events at window level
  32974. * @param events defines the events to register
  32975. */
  32976. static RegisterTopRootEvents(events: {
  32977. name: string;
  32978. handler: Nullable<(e: FocusEvent) => any>;
  32979. }[]): void;
  32980. /**
  32981. * Function used to unregister events from window level
  32982. * @param events defines the events to unregister
  32983. */
  32984. static UnregisterTopRootEvents(events: {
  32985. name: string;
  32986. handler: Nullable<(e: FocusEvent) => any>;
  32987. }[]): void;
  32988. /**
  32989. * Dumps the current bound framebuffer
  32990. * @param width defines the rendering width
  32991. * @param height defines the rendering height
  32992. * @param engine defines the hosting engine
  32993. * @param successCallback defines the callback triggered once the data are available
  32994. * @param mimeType defines the mime type of the result
  32995. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32996. */
  32997. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32998. /**
  32999. * Converts the canvas data to blob.
  33000. * This acts as a polyfill for browsers not supporting the to blob function.
  33001. * @param canvas Defines the canvas to extract the data from
  33002. * @param successCallback Defines the callback triggered once the data are available
  33003. * @param mimeType Defines the mime type of the result
  33004. */
  33005. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33006. /**
  33007. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33008. * @param successCallback defines the callback triggered once the data are available
  33009. * @param mimeType defines the mime type of the result
  33010. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33011. */
  33012. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33013. /**
  33014. * Downloads a blob in the browser
  33015. * @param blob defines the blob to download
  33016. * @param fileName defines the name of the downloaded file
  33017. */
  33018. static Download(blob: Blob, fileName: string): void;
  33019. /**
  33020. * Captures a screenshot of the current rendering
  33021. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33022. * @param engine defines the rendering engine
  33023. * @param camera defines the source camera
  33024. * @param size This parameter can be set to a single number or to an object with the
  33025. * following (optional) properties: precision, width, height. If a single number is passed,
  33026. * it will be used for both width and height. If an object is passed, the screenshot size
  33027. * will be derived from the parameters. The precision property is a multiplier allowing
  33028. * rendering at a higher or lower resolution
  33029. * @param successCallback defines the callback receives a single parameter which contains the
  33030. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33031. * src parameter of an <img> to display it
  33032. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33033. * Check your browser for supported MIME types
  33034. */
  33035. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  33036. /**
  33037. * Generates an image screenshot from the specified camera.
  33038. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33039. * @param engine The engine to use for rendering
  33040. * @param camera The camera to use for rendering
  33041. * @param size This parameter can be set to a single number or to an object with the
  33042. * following (optional) properties: precision, width, height. If a single number is passed,
  33043. * it will be used for both width and height. If an object is passed, the screenshot size
  33044. * will be derived from the parameters. The precision property is a multiplier allowing
  33045. * rendering at a higher or lower resolution
  33046. * @param successCallback The callback receives a single parameter which contains the
  33047. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33048. * src parameter of an <img> to display it
  33049. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33050. * Check your browser for supported MIME types
  33051. * @param samples Texture samples (default: 1)
  33052. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33053. * @param fileName A name for for the downloaded file.
  33054. */
  33055. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33056. /**
  33057. * Validates if xhr data is correct
  33058. * @param xhr defines the request to validate
  33059. * @param dataType defines the expected data type
  33060. * @returns true if data is correct
  33061. */
  33062. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  33063. /**
  33064. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33065. * Be aware Math.random() could cause collisions, but:
  33066. * "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"
  33067. * @returns a pseudo random id
  33068. */
  33069. static RandomId(): string;
  33070. /**
  33071. * Test if the given uri is a base64 string
  33072. * @param uri The uri to test
  33073. * @return True if the uri is a base64 string or false otherwise
  33074. */
  33075. static IsBase64(uri: string): boolean;
  33076. /**
  33077. * Decode the given base64 uri.
  33078. * @param uri The uri to decode
  33079. * @return The decoded base64 data.
  33080. */
  33081. static DecodeBase64(uri: string): ArrayBuffer;
  33082. /**
  33083. * No log
  33084. */
  33085. static readonly NoneLogLevel: number;
  33086. /**
  33087. * Only message logs
  33088. */
  33089. static readonly MessageLogLevel: number;
  33090. /**
  33091. * Only warning logs
  33092. */
  33093. static readonly WarningLogLevel: number;
  33094. /**
  33095. * Only error logs
  33096. */
  33097. static readonly ErrorLogLevel: number;
  33098. /**
  33099. * All logs
  33100. */
  33101. static readonly AllLogLevel: number;
  33102. /**
  33103. * Gets a value indicating the number of loading errors
  33104. * @ignorenaming
  33105. */
  33106. static readonly errorsCount: number;
  33107. /**
  33108. * Callback called when a new log is added
  33109. */
  33110. static OnNewCacheEntry: (entry: string) => void;
  33111. /**
  33112. * Log a message to the console
  33113. */
  33114. static Log(message: string): void;
  33115. /**
  33116. * Write a warning message to the console
  33117. */
  33118. static Warn(message: string): void;
  33119. /**
  33120. * Write an error message to the console
  33121. */
  33122. static Error(message: string): void;
  33123. /**
  33124. * Gets current log cache (list of logs)
  33125. */
  33126. static readonly LogCache: string;
  33127. /**
  33128. * Clears the log cache
  33129. */
  33130. static ClearLogCache(): void;
  33131. /**
  33132. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33133. */
  33134. static LogLevels: number;
  33135. /**
  33136. * Checks if the loaded document was accessed via `file:`-Protocol.
  33137. * @returns boolean
  33138. */
  33139. static IsFileURL(): boolean;
  33140. /**
  33141. * Checks if the window object exists
  33142. * @returns true if the window object exists
  33143. */
  33144. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33145. /**
  33146. * No performance log
  33147. */
  33148. static readonly PerformanceNoneLogLevel: number;
  33149. /**
  33150. * Use user marks to log performance
  33151. */
  33152. static readonly PerformanceUserMarkLogLevel: number;
  33153. /**
  33154. * Log performance to the console
  33155. */
  33156. static readonly PerformanceConsoleLogLevel: number;
  33157. private static _performance;
  33158. /**
  33159. * Sets the current performance log level
  33160. */
  33161. static PerformanceLogLevel: number;
  33162. private static _StartPerformanceCounterDisabled;
  33163. private static _EndPerformanceCounterDisabled;
  33164. private static _StartUserMark;
  33165. private static _EndUserMark;
  33166. private static _StartPerformanceConsole;
  33167. private static _EndPerformanceConsole;
  33168. /**
  33169. * Injects the @see CustomRequestHeaders into the given request
  33170. * @param request the request that should be used for injection
  33171. */
  33172. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  33173. /**
  33174. * Starts a performance counter
  33175. */
  33176. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33177. /**
  33178. * Ends a specific performance coutner
  33179. */
  33180. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33181. /**
  33182. * Gets either window.performance.now() if supported or Date.now() else
  33183. */
  33184. static readonly Now: number;
  33185. /**
  33186. * This method will return the name of the class used to create the instance of the given object.
  33187. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33188. * @param object the object to get the class name from
  33189. * @param isType defines if the object is actually a type
  33190. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33191. */
  33192. static GetClassName(object: any, isType?: boolean): string;
  33193. /**
  33194. * Gets the first element of an array satisfying a given predicate
  33195. * @param array defines the array to browse
  33196. * @param predicate defines the predicate to use
  33197. * @returns null if not found or the element
  33198. */
  33199. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33200. /**
  33201. * This method will return the name of the full name of the class, including its owning module (if any).
  33202. * 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).
  33203. * @param object the object to get the class name from
  33204. * @param isType defines if the object is actually a type
  33205. * @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.
  33206. * @ignorenaming
  33207. */
  33208. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33209. /**
  33210. * Returns a promise that resolves after the given amount of time.
  33211. * @param delay Number of milliseconds to delay
  33212. * @returns Promise that resolves after the given amount of time
  33213. */
  33214. static DelayAsync(delay: number): Promise<void>;
  33215. /**
  33216. * Gets the current gradient from an array of IValueGradient
  33217. * @param ratio defines the current ratio to get
  33218. * @param gradients defines the array of IValueGradient
  33219. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  33220. */
  33221. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  33222. }
  33223. /**
  33224. * This class is used to track a performance counter which is number based.
  33225. * The user has access to many properties which give statistics of different nature.
  33226. *
  33227. * The implementer can track two kinds of Performance Counter: time and count.
  33228. * 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.
  33229. * 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.
  33230. */
  33231. export class PerfCounter {
  33232. /**
  33233. * Gets or sets a global boolean to turn on and off all the counters
  33234. */
  33235. static Enabled: boolean;
  33236. /**
  33237. * Returns the smallest value ever
  33238. */
  33239. readonly min: number;
  33240. /**
  33241. * Returns the biggest value ever
  33242. */
  33243. readonly max: number;
  33244. /**
  33245. * Returns the average value since the performance counter is running
  33246. */
  33247. readonly average: number;
  33248. /**
  33249. * Returns the average value of the last second the counter was monitored
  33250. */
  33251. readonly lastSecAverage: number;
  33252. /**
  33253. * Returns the current value
  33254. */
  33255. readonly current: number;
  33256. /**
  33257. * Gets the accumulated total
  33258. */
  33259. readonly total: number;
  33260. /**
  33261. * Gets the total value count
  33262. */
  33263. readonly count: number;
  33264. /**
  33265. * Creates a new counter
  33266. */
  33267. constructor();
  33268. /**
  33269. * Call this method to start monitoring a new frame.
  33270. * 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.
  33271. */
  33272. fetchNewFrame(): void;
  33273. /**
  33274. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33275. * @param newCount the count value to add to the monitored count
  33276. * @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.
  33277. */
  33278. addCount(newCount: number, fetchResult: boolean): void;
  33279. /**
  33280. * Start monitoring this performance counter
  33281. */
  33282. beginMonitoring(): void;
  33283. /**
  33284. * Compute the time lapsed since the previous beginMonitoring() call.
  33285. * @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
  33286. */
  33287. endMonitoring(newFrame?: boolean): void;
  33288. private _fetchResult;
  33289. private _startMonitoringTime;
  33290. private _min;
  33291. private _max;
  33292. private _average;
  33293. private _current;
  33294. private _totalValueCount;
  33295. private _totalAccumulated;
  33296. private _lastSecAverage;
  33297. private _lastSecAccumulated;
  33298. private _lastSecTime;
  33299. private _lastSecValueCount;
  33300. }
  33301. /**
  33302. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33303. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33304. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33305. * @param name The name of the class, case should be preserved
  33306. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33307. */
  33308. export function className(name: string, module?: string): (target: Object) => void;
  33309. /**
  33310. * An implementation of a loop for asynchronous functions.
  33311. */
  33312. export class AsyncLoop {
  33313. /**
  33314. * Defines the number of iterations for the loop
  33315. */
  33316. iterations: number;
  33317. /**
  33318. * Defines the current index of the loop.
  33319. */
  33320. index: number;
  33321. private _done;
  33322. private _fn;
  33323. private _successCallback;
  33324. /**
  33325. * Constructor.
  33326. * @param iterations the number of iterations.
  33327. * @param func the function to run each iteration
  33328. * @param successCallback the callback that will be called upon succesful execution
  33329. * @param offset starting offset.
  33330. */
  33331. constructor(
  33332. /**
  33333. * Defines the number of iterations for the loop
  33334. */
  33335. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33336. /**
  33337. * Execute the next iteration. Must be called after the last iteration was finished.
  33338. */
  33339. executeNext(): void;
  33340. /**
  33341. * Break the loop and run the success callback.
  33342. */
  33343. breakLoop(): void;
  33344. /**
  33345. * Create and run an async loop.
  33346. * @param iterations the number of iterations.
  33347. * @param fn the function to run each iteration
  33348. * @param successCallback the callback that will be called upon succesful execution
  33349. * @param offset starting offset.
  33350. * @returns the created async loop object
  33351. */
  33352. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33353. /**
  33354. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33355. * @param iterations total number of iterations
  33356. * @param syncedIterations number of synchronous iterations in each async iteration.
  33357. * @param fn the function to call each iteration.
  33358. * @param callback a success call back that will be called when iterating stops.
  33359. * @param breakFunction a break condition (optional)
  33360. * @param timeout timeout settings for the setTimeout function. default - 0.
  33361. * @returns the created async loop object
  33362. */
  33363. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33364. }
  33365. }
  33366. declare module "babylonjs/Materials/pushMaterial" {
  33367. import { Nullable } from "babylonjs/types";
  33368. import { Scene } from "babylonjs/scene";
  33369. import { Matrix } from "babylonjs/Maths/math";
  33370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33371. import { Mesh } from "babylonjs/Meshes/mesh";
  33372. import { Material } from "babylonjs/Materials/material";
  33373. import { Effect } from "babylonjs/Materials/effect";
  33374. /**
  33375. * Base class of materials working in push mode in babylon JS
  33376. * @hidden
  33377. */
  33378. export class PushMaterial extends Material {
  33379. protected _activeEffect: Effect;
  33380. protected _normalMatrix: Matrix;
  33381. /**
  33382. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  33383. * This means that the material can keep using a previous shader while a new one is being compiled.
  33384. * This is mostly used when shader parallel compilation is supported (true by default)
  33385. */
  33386. allowShaderHotSwapping: boolean;
  33387. constructor(name: string, scene: Scene);
  33388. getEffect(): Effect;
  33389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  33390. /**
  33391. * Binds the given world matrix to the active effect
  33392. *
  33393. * @param world the matrix to bind
  33394. */
  33395. bindOnlyWorldMatrix(world: Matrix): void;
  33396. /**
  33397. * Binds the given normal matrix to the active effect
  33398. *
  33399. * @param normalMatrix the matrix to bind
  33400. */
  33401. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  33402. bind(world: Matrix, mesh?: Mesh): void;
  33403. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  33404. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  33405. }
  33406. }
  33407. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  33408. export var defaultFragmentDeclaration: {
  33409. name: string;
  33410. shader: string;
  33411. };
  33412. }
  33413. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  33414. export var defaultUboDeclaration: {
  33415. name: string;
  33416. shader: string;
  33417. };
  33418. }
  33419. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  33420. export var lightFragmentDeclaration: {
  33421. name: string;
  33422. shader: string;
  33423. };
  33424. }
  33425. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  33426. export var lightUboDeclaration: {
  33427. name: string;
  33428. shader: string;
  33429. };
  33430. }
  33431. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  33432. export var lightsFragmentFunctions: {
  33433. name: string;
  33434. shader: string;
  33435. };
  33436. }
  33437. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  33438. export var shadowsFragmentFunctions: {
  33439. name: string;
  33440. shader: string;
  33441. };
  33442. }
  33443. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  33444. export var fresnelFunction: {
  33445. name: string;
  33446. shader: string;
  33447. };
  33448. }
  33449. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  33450. export var reflectionFunction: {
  33451. name: string;
  33452. shader: string;
  33453. };
  33454. }
  33455. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  33456. export var bumpFragmentFunctions: {
  33457. name: string;
  33458. shader: string;
  33459. };
  33460. }
  33461. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  33462. export var logDepthDeclaration: {
  33463. name: string;
  33464. shader: string;
  33465. };
  33466. }
  33467. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  33468. export var bumpFragment: {
  33469. name: string;
  33470. shader: string;
  33471. };
  33472. }
  33473. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  33474. export var depthPrePass: {
  33475. name: string;
  33476. shader: string;
  33477. };
  33478. }
  33479. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  33480. export var lightFragment: {
  33481. name: string;
  33482. shader: string;
  33483. };
  33484. }
  33485. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  33486. export var logDepthFragment: {
  33487. name: string;
  33488. shader: string;
  33489. };
  33490. }
  33491. declare module "babylonjs/Shaders/default.fragment" {
  33492. import "Shaders/ShadersInclude/defaultFragmentDeclaration";
  33493. import "Shaders/ShadersInclude/defaultUboDeclaration";
  33494. import "Shaders/ShadersInclude/helperFunctions";
  33495. import "Shaders/ShadersInclude/lightFragmentDeclaration";
  33496. import "Shaders/ShadersInclude/lightUboDeclaration";
  33497. import "Shaders/ShadersInclude/lightsFragmentFunctions";
  33498. import "Shaders/ShadersInclude/shadowsFragmentFunctions";
  33499. import "Shaders/ShadersInclude/fresnelFunction";
  33500. import "Shaders/ShadersInclude/reflectionFunction";
  33501. import "Shaders/ShadersInclude/imageProcessingDeclaration";
  33502. import "Shaders/ShadersInclude/imageProcessingFunctions";
  33503. import "Shaders/ShadersInclude/bumpFragmentFunctions";
  33504. import "Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  33505. import "Shaders/ShadersInclude/logDepthDeclaration";
  33506. import "Shaders/ShadersInclude/fogFragmentDeclaration";
  33507. import "Shaders/ShadersInclude/clipPlaneFragment";
  33508. import "Shaders/ShadersInclude/bumpFragment";
  33509. import "Shaders/ShadersInclude/depthPrePass";
  33510. import "Shaders/ShadersInclude/lightFragment";
  33511. import "Shaders/ShadersInclude/logDepthFragment";
  33512. import "Shaders/ShadersInclude/fogFragment";
  33513. export var defaultPixelShader: {
  33514. name: string;
  33515. shader: string;
  33516. };
  33517. }
  33518. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  33519. export var defaultVertexDeclaration: {
  33520. name: string;
  33521. shader: string;
  33522. };
  33523. }
  33524. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  33525. export var bumpVertexDeclaration: {
  33526. name: string;
  33527. shader: string;
  33528. };
  33529. }
  33530. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  33531. export var bumpVertex: {
  33532. name: string;
  33533. shader: string;
  33534. };
  33535. }
  33536. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  33537. export var fogVertex: {
  33538. name: string;
  33539. shader: string;
  33540. };
  33541. }
  33542. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  33543. export var shadowsVertex: {
  33544. name: string;
  33545. shader: string;
  33546. };
  33547. }
  33548. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  33549. export var pointCloudVertex: {
  33550. name: string;
  33551. shader: string;
  33552. };
  33553. }
  33554. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  33555. export var logDepthVertex: {
  33556. name: string;
  33557. shader: string;
  33558. };
  33559. }
  33560. declare module "babylonjs/Shaders/default.vertex" {
  33561. import "Shaders/ShadersInclude/defaultVertexDeclaration";
  33562. import "Shaders/ShadersInclude/defaultUboDeclaration";
  33563. import "Shaders/ShadersInclude/helperFunctions";
  33564. import "Shaders/ShadersInclude/bonesDeclaration";
  33565. import "Shaders/ShadersInclude/instancesDeclaration";
  33566. import "Shaders/ShadersInclude/bumpVertexDeclaration";
  33567. import "Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  33568. import "Shaders/ShadersInclude/fogVertexDeclaration";
  33569. import "Shaders/ShadersInclude/lightFragmentDeclaration";
  33570. import "Shaders/ShadersInclude/lightUboDeclaration";
  33571. import "Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  33572. import "Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  33573. import "Shaders/ShadersInclude/logDepthDeclaration";
  33574. import "Shaders/ShadersInclude/morphTargetsVertex";
  33575. import "Shaders/ShadersInclude/instancesVertex";
  33576. import "Shaders/ShadersInclude/bonesVertex";
  33577. import "Shaders/ShadersInclude/bumpVertex";
  33578. import "Shaders/ShadersInclude/clipPlaneVertex";
  33579. import "Shaders/ShadersInclude/fogVertex";
  33580. import "Shaders/ShadersInclude/shadowsVertex";
  33581. import "Shaders/ShadersInclude/pointCloudVertex";
  33582. import "Shaders/ShadersInclude/logDepthVertex";
  33583. export var defaultVertexShader: {
  33584. name: string;
  33585. shader: string;
  33586. };
  33587. }
  33588. declare module "babylonjs/Materials/standardMaterial" {
  33589. import { SmartArray } from "babylonjs/Misc/smartArray";
  33590. import { IAnimatable } from "babylonjs/Misc/tools";
  33591. import { Nullable } from "babylonjs/types";
  33592. import { Scene } from "babylonjs/scene";
  33593. import { Matrix, Color3 } from "babylonjs/Maths/math";
  33594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33596. import { Mesh } from "babylonjs/Meshes/mesh";
  33597. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  33598. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  33599. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  33600. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  33601. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  33602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33603. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33604. import "Shaders/default.fragment";
  33605. import "Shaders/default.vertex";
  33606. /** @hidden */
  33607. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  33608. MAINUV1: boolean;
  33609. MAINUV2: boolean;
  33610. DIFFUSE: boolean;
  33611. DIFFUSEDIRECTUV: number;
  33612. AMBIENT: boolean;
  33613. AMBIENTDIRECTUV: number;
  33614. OPACITY: boolean;
  33615. OPACITYDIRECTUV: number;
  33616. OPACITYRGB: boolean;
  33617. REFLECTION: boolean;
  33618. EMISSIVE: boolean;
  33619. EMISSIVEDIRECTUV: number;
  33620. SPECULAR: boolean;
  33621. SPECULARDIRECTUV: number;
  33622. BUMP: boolean;
  33623. BUMPDIRECTUV: number;
  33624. PARALLAX: boolean;
  33625. PARALLAXOCCLUSION: boolean;
  33626. SPECULAROVERALPHA: boolean;
  33627. CLIPPLANE: boolean;
  33628. CLIPPLANE2: boolean;
  33629. CLIPPLANE3: boolean;
  33630. CLIPPLANE4: boolean;
  33631. ALPHATEST: boolean;
  33632. DEPTHPREPASS: boolean;
  33633. ALPHAFROMDIFFUSE: boolean;
  33634. POINTSIZE: boolean;
  33635. FOG: boolean;
  33636. SPECULARTERM: boolean;
  33637. DIFFUSEFRESNEL: boolean;
  33638. OPACITYFRESNEL: boolean;
  33639. REFLECTIONFRESNEL: boolean;
  33640. REFRACTIONFRESNEL: boolean;
  33641. EMISSIVEFRESNEL: boolean;
  33642. FRESNEL: boolean;
  33643. NORMAL: boolean;
  33644. UV1: boolean;
  33645. UV2: boolean;
  33646. VERTEXCOLOR: boolean;
  33647. VERTEXALPHA: boolean;
  33648. NUM_BONE_INFLUENCERS: number;
  33649. BonesPerMesh: number;
  33650. BONETEXTURE: boolean;
  33651. INSTANCES: boolean;
  33652. GLOSSINESS: boolean;
  33653. ROUGHNESS: boolean;
  33654. EMISSIVEASILLUMINATION: boolean;
  33655. LINKEMISSIVEWITHDIFFUSE: boolean;
  33656. REFLECTIONFRESNELFROMSPECULAR: boolean;
  33657. LIGHTMAP: boolean;
  33658. LIGHTMAPDIRECTUV: number;
  33659. OBJECTSPACE_NORMALMAP: boolean;
  33660. USELIGHTMAPASSHADOWMAP: boolean;
  33661. REFLECTIONMAP_3D: boolean;
  33662. REFLECTIONMAP_SPHERICAL: boolean;
  33663. REFLECTIONMAP_PLANAR: boolean;
  33664. REFLECTIONMAP_CUBIC: boolean;
  33665. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  33666. REFLECTIONMAP_PROJECTION: boolean;
  33667. REFLECTIONMAP_SKYBOX: boolean;
  33668. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  33669. REFLECTIONMAP_EXPLICIT: boolean;
  33670. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  33671. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  33672. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  33673. INVERTCUBICMAP: boolean;
  33674. LOGARITHMICDEPTH: boolean;
  33675. REFRACTION: boolean;
  33676. REFRACTIONMAP_3D: boolean;
  33677. REFLECTIONOVERALPHA: boolean;
  33678. TWOSIDEDLIGHTING: boolean;
  33679. SHADOWFLOAT: boolean;
  33680. MORPHTARGETS: boolean;
  33681. MORPHTARGETS_NORMAL: boolean;
  33682. MORPHTARGETS_TANGENT: boolean;
  33683. NUM_MORPH_INFLUENCERS: number;
  33684. NONUNIFORMSCALING: boolean;
  33685. PREMULTIPLYALPHA: boolean;
  33686. IMAGEPROCESSING: boolean;
  33687. VIGNETTE: boolean;
  33688. VIGNETTEBLENDMODEMULTIPLY: boolean;
  33689. VIGNETTEBLENDMODEOPAQUE: boolean;
  33690. TONEMAPPING: boolean;
  33691. TONEMAPPING_ACES: boolean;
  33692. CONTRAST: boolean;
  33693. COLORCURVES: boolean;
  33694. COLORGRADING: boolean;
  33695. COLORGRADING3D: boolean;
  33696. SAMPLER3DGREENDEPTH: boolean;
  33697. SAMPLER3DBGRMAP: boolean;
  33698. IMAGEPROCESSINGPOSTPROCESS: boolean;
  33699. /**
  33700. * If the reflection texture on this material is in linear color space
  33701. * @hidden
  33702. */
  33703. IS_REFLECTION_LINEAR: boolean;
  33704. /**
  33705. * If the refraction texture on this material is in linear color space
  33706. * @hidden
  33707. */
  33708. IS_REFRACTION_LINEAR: boolean;
  33709. EXPOSURE: boolean;
  33710. constructor();
  33711. setReflectionMode(modeToEnable: string): void;
  33712. }
  33713. /**
  33714. * This is the default material used in Babylon. It is the best trade off between quality
  33715. * and performances.
  33716. * @see http://doc.babylonjs.com/babylon101/materials
  33717. */
  33718. export class StandardMaterial extends PushMaterial {
  33719. private _diffuseTexture;
  33720. /**
  33721. * The basic texture of the material as viewed under a light.
  33722. */
  33723. diffuseTexture: Nullable<BaseTexture>;
  33724. private _ambientTexture;
  33725. /**
  33726. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  33727. */
  33728. ambientTexture: Nullable<BaseTexture>;
  33729. private _opacityTexture;
  33730. /**
  33731. * Define the transparency of the material from a texture.
  33732. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  33733. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  33734. */
  33735. opacityTexture: Nullable<BaseTexture>;
  33736. private _reflectionTexture;
  33737. /**
  33738. * Define the texture used to display the reflection.
  33739. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  33740. */
  33741. reflectionTexture: Nullable<BaseTexture>;
  33742. private _emissiveTexture;
  33743. /**
  33744. * Define texture of the material as if self lit.
  33745. * This will be mixed in the final result even in the absence of light.
  33746. */
  33747. emissiveTexture: Nullable<BaseTexture>;
  33748. private _specularTexture;
  33749. /**
  33750. * Define how the color and intensity of the highlight given by the light in the material.
  33751. */
  33752. specularTexture: Nullable<BaseTexture>;
  33753. private _bumpTexture;
  33754. /**
  33755. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  33756. * 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.
  33757. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  33758. */
  33759. bumpTexture: Nullable<BaseTexture>;
  33760. private _lightmapTexture;
  33761. /**
  33762. * Complex lighting can be computationally expensive to compute at runtime.
  33763. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  33764. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  33765. */
  33766. lightmapTexture: Nullable<BaseTexture>;
  33767. private _refractionTexture;
  33768. /**
  33769. * Define the texture used to display the refraction.
  33770. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  33771. */
  33772. refractionTexture: Nullable<BaseTexture>;
  33773. /**
  33774. * The color of the material lit by the environmental background lighting.
  33775. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  33776. */
  33777. ambientColor: Color3;
  33778. /**
  33779. * The basic color of the material as viewed under a light.
  33780. */
  33781. diffuseColor: Color3;
  33782. /**
  33783. * Define how the color and intensity of the highlight given by the light in the material.
  33784. */
  33785. specularColor: Color3;
  33786. /**
  33787. * Define the color of the material as if self lit.
  33788. * This will be mixed in the final result even in the absence of light.
  33789. */
  33790. emissiveColor: Color3;
  33791. /**
  33792. * Defines how sharp are the highlights in the material.
  33793. * The bigger the value the sharper giving a more glossy feeling to the result.
  33794. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  33795. */
  33796. specularPower: number;
  33797. private _useAlphaFromDiffuseTexture;
  33798. /**
  33799. * Does the transparency come from the diffuse texture alpha channel.
  33800. */
  33801. useAlphaFromDiffuseTexture: boolean;
  33802. private _useEmissiveAsIllumination;
  33803. /**
  33804. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  33805. */
  33806. useEmissiveAsIllumination: boolean;
  33807. private _linkEmissiveWithDiffuse;
  33808. /**
  33809. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  33810. * the emissive level when the final color is close to one.
  33811. */
  33812. linkEmissiveWithDiffuse: boolean;
  33813. private _useSpecularOverAlpha;
  33814. /**
  33815. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  33816. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33817. */
  33818. useSpecularOverAlpha: boolean;
  33819. private _useReflectionOverAlpha;
  33820. /**
  33821. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33822. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33823. */
  33824. useReflectionOverAlpha: boolean;
  33825. private _disableLighting;
  33826. /**
  33827. * Does lights from the scene impacts this material.
  33828. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  33829. */
  33830. disableLighting: boolean;
  33831. private _useObjectSpaceNormalMap;
  33832. /**
  33833. * Allows using an object space normal map (instead of tangent space).
  33834. */
  33835. useObjectSpaceNormalMap: boolean;
  33836. private _useParallax;
  33837. /**
  33838. * Is parallax enabled or not.
  33839. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  33840. */
  33841. useParallax: boolean;
  33842. private _useParallaxOcclusion;
  33843. /**
  33844. * Is parallax occlusion enabled or not.
  33845. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  33846. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  33847. */
  33848. useParallaxOcclusion: boolean;
  33849. /**
  33850. * 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.
  33851. */
  33852. parallaxScaleBias: number;
  33853. private _roughness;
  33854. /**
  33855. * Helps to define how blurry the reflections should appears in the material.
  33856. */
  33857. roughness: number;
  33858. /**
  33859. * In case of refraction, define the value of the indice of refraction.
  33860. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  33861. */
  33862. indexOfRefraction: number;
  33863. /**
  33864. * Invert the refraction texture alongside the y axis.
  33865. * It can be useful with procedural textures or probe for instance.
  33866. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  33867. */
  33868. invertRefractionY: boolean;
  33869. /**
  33870. * Defines the alpha limits in alpha test mode.
  33871. */
  33872. alphaCutOff: number;
  33873. private _useLightmapAsShadowmap;
  33874. /**
  33875. * In case of light mapping, define whether the map contains light or shadow informations.
  33876. */
  33877. useLightmapAsShadowmap: boolean;
  33878. private _diffuseFresnelParameters;
  33879. /**
  33880. * Define the diffuse fresnel parameters of the material.
  33881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  33882. */
  33883. diffuseFresnelParameters: FresnelParameters;
  33884. private _opacityFresnelParameters;
  33885. /**
  33886. * Define the opacity fresnel parameters of the material.
  33887. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  33888. */
  33889. opacityFresnelParameters: FresnelParameters;
  33890. private _reflectionFresnelParameters;
  33891. /**
  33892. * Define the reflection fresnel parameters of the material.
  33893. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  33894. */
  33895. reflectionFresnelParameters: FresnelParameters;
  33896. private _refractionFresnelParameters;
  33897. /**
  33898. * Define the refraction fresnel parameters of the material.
  33899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  33900. */
  33901. refractionFresnelParameters: FresnelParameters;
  33902. private _emissiveFresnelParameters;
  33903. /**
  33904. * Define the emissive fresnel parameters of the material.
  33905. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  33906. */
  33907. emissiveFresnelParameters: FresnelParameters;
  33908. private _useReflectionFresnelFromSpecular;
  33909. /**
  33910. * If true automatically deducts the fresnels values from the material specularity.
  33911. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  33912. */
  33913. useReflectionFresnelFromSpecular: boolean;
  33914. private _useGlossinessFromSpecularMapAlpha;
  33915. /**
  33916. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  33917. */
  33918. useGlossinessFromSpecularMapAlpha: boolean;
  33919. private _maxSimultaneousLights;
  33920. /**
  33921. * Defines the maximum number of lights that can be used in the material
  33922. */
  33923. maxSimultaneousLights: number;
  33924. private _invertNormalMapX;
  33925. /**
  33926. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33927. */
  33928. invertNormalMapX: boolean;
  33929. private _invertNormalMapY;
  33930. /**
  33931. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33932. */
  33933. invertNormalMapY: boolean;
  33934. private _twoSidedLighting;
  33935. /**
  33936. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33937. */
  33938. twoSidedLighting: boolean;
  33939. /**
  33940. * Default configuration related to image processing available in the standard Material.
  33941. */
  33942. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33943. /**
  33944. * Gets the image processing configuration used either in this material.
  33945. */
  33946. /**
  33947. * Sets the Default image processing configuration used either in the this material.
  33948. *
  33949. * If sets to null, the scene one is in use.
  33950. */
  33951. imageProcessingConfiguration: ImageProcessingConfiguration;
  33952. /**
  33953. * Keep track of the image processing observer to allow dispose and replace.
  33954. */
  33955. private _imageProcessingObserver;
  33956. /**
  33957. * Attaches a new image processing configuration to the Standard Material.
  33958. * @param configuration
  33959. */
  33960. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33961. /**
  33962. * Gets wether the color curves effect is enabled.
  33963. */
  33964. /**
  33965. * Sets wether the color curves effect is enabled.
  33966. */
  33967. cameraColorCurvesEnabled: boolean;
  33968. /**
  33969. * Gets wether the color grading effect is enabled.
  33970. */
  33971. /**
  33972. * Gets wether the color grading effect is enabled.
  33973. */
  33974. cameraColorGradingEnabled: boolean;
  33975. /**
  33976. * Gets wether tonemapping is enabled or not.
  33977. */
  33978. /**
  33979. * Sets wether tonemapping is enabled or not
  33980. */
  33981. cameraToneMappingEnabled: boolean;
  33982. /**
  33983. * The camera exposure used on this material.
  33984. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33985. * This corresponds to a photographic exposure.
  33986. */
  33987. /**
  33988. * The camera exposure used on this material.
  33989. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33990. * This corresponds to a photographic exposure.
  33991. */
  33992. cameraExposure: number;
  33993. /**
  33994. * Gets The camera contrast used on this material.
  33995. */
  33996. /**
  33997. * Sets The camera contrast used on this material.
  33998. */
  33999. cameraContrast: number;
  34000. /**
  34001. * Gets the Color Grading 2D Lookup Texture.
  34002. */
  34003. /**
  34004. * Sets the Color Grading 2D Lookup Texture.
  34005. */
  34006. cameraColorGradingTexture: Nullable<BaseTexture>;
  34007. /**
  34008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34010. * 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;
  34011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34012. */
  34013. /**
  34014. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34015. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34016. * 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;
  34017. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34018. */
  34019. cameraColorCurves: Nullable<ColorCurves>;
  34020. /**
  34021. * Custom callback helping to override the default shader used in the material.
  34022. */
  34023. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  34024. protected _renderTargets: SmartArray<RenderTargetTexture>;
  34025. protected _worldViewProjectionMatrix: Matrix;
  34026. protected _globalAmbientColor: Color3;
  34027. protected _useLogarithmicDepth: boolean;
  34028. /**
  34029. * Instantiates a new standard material.
  34030. * This is the default material used in Babylon. It is the best trade off between quality
  34031. * and performances.
  34032. * @see http://doc.babylonjs.com/babylon101/materials
  34033. * @param name Define the name of the material in the scene
  34034. * @param scene Define the scene the material belong to
  34035. */
  34036. constructor(name: string, scene: Scene);
  34037. /**
  34038. * Gets a boolean indicating that current material needs to register RTT
  34039. */
  34040. readonly hasRenderTargetTextures: boolean;
  34041. /**
  34042. * Gets the current class name of the material e.g. "StandardMaterial"
  34043. * Mainly use in serialization.
  34044. * @returns the class name
  34045. */
  34046. getClassName(): string;
  34047. /**
  34048. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  34049. * You can try switching to logarithmic depth.
  34050. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  34051. */
  34052. useLogarithmicDepth: boolean;
  34053. /**
  34054. * Specifies if the material will require alpha blending
  34055. * @returns a boolean specifying if alpha blending is needed
  34056. */
  34057. needAlphaBlending(): boolean;
  34058. /**
  34059. * Specifies if this material should be rendered in alpha test mode
  34060. * @returns a boolean specifying if an alpha test is needed.
  34061. */
  34062. needAlphaTesting(): boolean;
  34063. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  34064. /**
  34065. * Get the texture used for alpha test purpose.
  34066. * @returns the diffuse texture in case of the standard material.
  34067. */
  34068. getAlphaTestTexture(): Nullable<BaseTexture>;
  34069. /**
  34070. * Get if the submesh is ready to be used and all its information available.
  34071. * Child classes can use it to update shaders
  34072. * @param mesh defines the mesh to check
  34073. * @param subMesh defines which submesh to check
  34074. * @param useInstances specifies that instances should be used
  34075. * @returns a boolean indicating that the submesh is ready or not
  34076. */
  34077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34078. /**
  34079. * Builds the material UBO layouts.
  34080. * Used internally during the effect preparation.
  34081. */
  34082. buildUniformLayout(): void;
  34083. /**
  34084. * Unbinds the material from the mesh
  34085. */
  34086. unbind(): void;
  34087. /**
  34088. * Binds the submesh to this material by preparing the effect and shader to draw
  34089. * @param world defines the world transformation matrix
  34090. * @param mesh defines the mesh containing the submesh
  34091. * @param subMesh defines the submesh to bind the material to
  34092. */
  34093. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34094. /**
  34095. * Get the list of animatables in the material.
  34096. * @returns the list of animatables object used in the material
  34097. */
  34098. getAnimatables(): IAnimatable[];
  34099. /**
  34100. * Gets the active textures from the material
  34101. * @returns an array of textures
  34102. */
  34103. getActiveTextures(): BaseTexture[];
  34104. /**
  34105. * Specifies if the material uses a texture
  34106. * @param texture defines the texture to check against the material
  34107. * @returns a boolean specifying if the material uses the texture
  34108. */
  34109. hasTexture(texture: BaseTexture): boolean;
  34110. /**
  34111. * Disposes the material
  34112. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  34113. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  34114. */
  34115. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34116. /**
  34117. * Makes a duplicate of the material, and gives it a new name
  34118. * @param name defines the new name for the duplicated material
  34119. * @returns the cloned material
  34120. */
  34121. clone(name: string): StandardMaterial;
  34122. /**
  34123. * Serializes this material in a JSON representation
  34124. * @returns the serialized material object
  34125. */
  34126. serialize(): any;
  34127. /**
  34128. * Creates a standard material from parsed material data
  34129. * @param source defines the JSON represnetation of the material
  34130. * @param scene defines the hosting scene
  34131. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  34132. * @returns a new material
  34133. */
  34134. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  34135. private static _DiffuseTextureEnabled;
  34136. /**
  34137. * Are diffuse textures enabled in the application.
  34138. */
  34139. static DiffuseTextureEnabled: boolean;
  34140. private static _AmbientTextureEnabled;
  34141. /**
  34142. * Are ambient textures enabled in the application.
  34143. */
  34144. static AmbientTextureEnabled: boolean;
  34145. private static _OpacityTextureEnabled;
  34146. /**
  34147. * Are opacity textures enabled in the application.
  34148. */
  34149. static OpacityTextureEnabled: boolean;
  34150. private static _ReflectionTextureEnabled;
  34151. /**
  34152. * Are reflection textures enabled in the application.
  34153. */
  34154. static ReflectionTextureEnabled: boolean;
  34155. private static _EmissiveTextureEnabled;
  34156. /**
  34157. * Are emissive textures enabled in the application.
  34158. */
  34159. static EmissiveTextureEnabled: boolean;
  34160. private static _SpecularTextureEnabled;
  34161. /**
  34162. * Are specular textures enabled in the application.
  34163. */
  34164. static SpecularTextureEnabled: boolean;
  34165. private static _BumpTextureEnabled;
  34166. /**
  34167. * Are bump textures enabled in the application.
  34168. */
  34169. static BumpTextureEnabled: boolean;
  34170. private static _LightmapTextureEnabled;
  34171. /**
  34172. * Are lightmap textures enabled in the application.
  34173. */
  34174. static LightmapTextureEnabled: boolean;
  34175. private static _RefractionTextureEnabled;
  34176. /**
  34177. * Are refraction textures enabled in the application.
  34178. */
  34179. static RefractionTextureEnabled: boolean;
  34180. private static _ColorGradingTextureEnabled;
  34181. /**
  34182. * Are color grading textures enabled in the application.
  34183. */
  34184. static ColorGradingTextureEnabled: boolean;
  34185. private static _FresnelEnabled;
  34186. /**
  34187. * Are fresnels enabled in the application.
  34188. */
  34189. static FresnelEnabled: boolean;
  34190. }
  34191. }
  34192. declare module "babylonjs/Collisions/collisionCoordinator" {
  34193. import { Nullable } from "babylonjs/types";
  34194. import { Scene } from "babylonjs/scene";
  34195. import { Vector3 } from "babylonjs/Maths/math";
  34196. import { Collider } from "babylonjs/Collisions/collider";
  34197. import { Geometry } from "babylonjs/Meshes/geometry";
  34198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34199. /** @hidden */
  34200. export interface ICollisionCoordinator {
  34201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34202. init(scene: Scene): void;
  34203. destroy(): void;
  34204. onMeshAdded(mesh: AbstractMesh): void;
  34205. onMeshUpdated(mesh: AbstractMesh): void;
  34206. onMeshRemoved(mesh: AbstractMesh): void;
  34207. onGeometryAdded(geometry: Geometry): void;
  34208. onGeometryUpdated(geometry: Geometry): void;
  34209. onGeometryDeleted(geometry: Geometry): void;
  34210. }
  34211. /** @hidden */
  34212. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  34213. private _scene;
  34214. private _scaledPosition;
  34215. private _scaledVelocity;
  34216. private _finalPosition;
  34217. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34218. init(scene: Scene): void;
  34219. destroy(): void;
  34220. onMeshAdded(mesh: AbstractMesh): void;
  34221. onMeshUpdated(mesh: AbstractMesh): void;
  34222. onMeshRemoved(mesh: AbstractMesh): void;
  34223. onGeometryAdded(geometry: Geometry): void;
  34224. onGeometryUpdated(geometry: Geometry): void;
  34225. onGeometryDeleted(geometry: Geometry): void;
  34226. private _collideWithWorld;
  34227. }
  34228. }
  34229. declare module "babylonjs/scene" {
  34230. import { Nullable } from "babylonjs/types";
  34231. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  34232. import { Observable } from "babylonjs/Misc/observable";
  34233. import { SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34234. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  34235. import { Geometry } from "babylonjs/Meshes/geometry";
  34236. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34239. import { Mesh } from "babylonjs/Meshes/mesh";
  34240. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34241. import { Bone } from "babylonjs/Bones/bone";
  34242. import { Skeleton } from "babylonjs/Bones/skeleton";
  34243. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34244. import { Camera } from "babylonjs/Cameras/camera";
  34245. import { AbstractScene } from "babylonjs/abstractScene";
  34246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34247. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34248. import { Material } from "babylonjs/Materials/material";
  34249. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34250. import { Effect } from "babylonjs/Materials/effect";
  34251. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34252. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34253. import { Animation } from "babylonjs/Animations/animation";
  34254. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34255. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34256. import { Animatable } from "babylonjs/Animations/animatable";
  34257. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34258. import { Light } from "babylonjs/Lights/light";
  34259. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34260. import { Collider } from "babylonjs/Collisions/collider";
  34261. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34262. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34263. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34264. import { ActionManager } from "babylonjs/Actions/actionManager";
  34265. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34266. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34267. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34268. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34269. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  34270. import { Engine } from "babylonjs/Engines/engine";
  34271. import { Ray } from "babylonjs/Culling/ray";
  34272. import { Node } from "babylonjs/node";
  34273. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34274. /**
  34275. * Define an interface for all classes that will hold resources
  34276. */
  34277. export interface IDisposable {
  34278. /**
  34279. * Releases all held resources
  34280. */
  34281. dispose(): void;
  34282. }
  34283. /** Interface defining initialization parameters for Scene class */
  34284. export interface SceneOptions {
  34285. /**
  34286. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  34287. * It will improve performance when the number of geometries becomes important.
  34288. */
  34289. useGeometryIdsMap?: boolean;
  34290. /**
  34291. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34292. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34293. */
  34294. useMaterialMeshMap?: boolean;
  34295. /**
  34296. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34297. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34298. */
  34299. useClonedMeshhMap?: boolean;
  34300. }
  34301. /**
  34302. * Represents a scene to be rendered by the engine.
  34303. * @see http://doc.babylonjs.com/features/scene
  34304. */
  34305. export class Scene extends AbstractScene implements IAnimatable {
  34306. private static _uniqueIdCounter;
  34307. /** The fog is deactivated */
  34308. static readonly FOGMODE_NONE: number;
  34309. /** The fog density is following an exponential function */
  34310. static readonly FOGMODE_EXP: number;
  34311. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34312. static readonly FOGMODE_EXP2: number;
  34313. /** The fog density is following a linear function. */
  34314. static readonly FOGMODE_LINEAR: number;
  34315. /**
  34316. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34318. */
  34319. static MinDeltaTime: number;
  34320. /**
  34321. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34323. */
  34324. static MaxDeltaTime: number;
  34325. /** @hidden */
  34326. readonly _isScene: boolean;
  34327. /**
  34328. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34329. */
  34330. autoClear: boolean;
  34331. /**
  34332. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34333. */
  34334. autoClearDepthAndStencil: boolean;
  34335. /**
  34336. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34337. */
  34338. clearColor: Color4;
  34339. /**
  34340. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34341. */
  34342. ambientColor: Color3;
  34343. /** @hidden */
  34344. _environmentBRDFTexture: BaseTexture;
  34345. /** @hidden */
  34346. protected _environmentTexture: Nullable<BaseTexture>;
  34347. /**
  34348. * Texture used in all pbr material as the reflection texture.
  34349. * As in the majority of the scene they are the same (exception for multi room and so on),
  34350. * this is easier to reference from here than from all the materials.
  34351. */
  34352. /**
  34353. * Texture used in all pbr material as the reflection texture.
  34354. * As in the majority of the scene they are the same (exception for multi room and so on),
  34355. * this is easier to set here than in all the materials.
  34356. */
  34357. environmentTexture: Nullable<BaseTexture>;
  34358. /** @hidden */
  34359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34360. /**
  34361. * Default image processing configuration used either in the rendering
  34362. * Forward main pass or through the imageProcessingPostProcess if present.
  34363. * As in the majority of the scene they are the same (exception for multi camera),
  34364. * this is easier to reference from here than from all the materials and post process.
  34365. *
  34366. * No setter as we it is a shared configuration, you can set the values instead.
  34367. */
  34368. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34369. private _forceWireframe;
  34370. /**
  34371. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34372. */
  34373. forceWireframe: boolean;
  34374. private _forcePointsCloud;
  34375. /**
  34376. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34377. */
  34378. forcePointsCloud: boolean;
  34379. /**
  34380. * Gets or sets the active clipplane 1
  34381. */
  34382. clipPlane: Nullable<Plane>;
  34383. /**
  34384. * Gets or sets the active clipplane 2
  34385. */
  34386. clipPlane2: Nullable<Plane>;
  34387. /**
  34388. * Gets or sets the active clipplane 3
  34389. */
  34390. clipPlane3: Nullable<Plane>;
  34391. /**
  34392. * Gets or sets the active clipplane 4
  34393. */
  34394. clipPlane4: Nullable<Plane>;
  34395. /**
  34396. * Gets or sets a boolean indicating if animations are enabled
  34397. */
  34398. animationsEnabled: boolean;
  34399. private _animationPropertiesOverride;
  34400. /**
  34401. * Gets or sets the animation properties override
  34402. */
  34403. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34404. /**
  34405. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34406. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34407. */
  34408. useConstantAnimationDeltaTime: boolean;
  34409. /**
  34410. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34411. * Please note that it requires to run a ray cast through the scene on every frame
  34412. */
  34413. constantlyUpdateMeshUnderPointer: boolean;
  34414. /**
  34415. * Defines the HTML cursor to use when hovering over interactive elements
  34416. */
  34417. hoverCursor: string;
  34418. /**
  34419. * Defines the HTML default cursor to use (empty by default)
  34420. */
  34421. defaultCursor: string;
  34422. /**
  34423. * This is used to call preventDefault() on pointer down
  34424. * in order to block unwanted artifacts like system double clicks
  34425. */
  34426. preventDefaultOnPointerDown: boolean;
  34427. /**
  34428. * This is used to call preventDefault() on pointer up
  34429. * in order to block unwanted artifacts like system double clicks
  34430. */
  34431. preventDefaultOnPointerUp: boolean;
  34432. /**
  34433. * Gets or sets user defined metadata
  34434. */
  34435. metadata: any;
  34436. /**
  34437. * Gets the name of the plugin used to load this scene (null by default)
  34438. */
  34439. loadingPluginName: string;
  34440. /**
  34441. * Use this array to add regular expressions used to disable offline support for specific urls
  34442. */
  34443. disableOfflineSupportExceptionRules: RegExp[];
  34444. /**
  34445. * An event triggered when the scene is disposed.
  34446. */
  34447. onDisposeObservable: Observable<Scene>;
  34448. private _onDisposeObserver;
  34449. /** Sets a function to be executed when this scene is disposed. */
  34450. onDispose: () => void;
  34451. /**
  34452. * An event triggered before rendering the scene (right after animations and physics)
  34453. */
  34454. onBeforeRenderObservable: Observable<Scene>;
  34455. private _onBeforeRenderObserver;
  34456. /** Sets a function to be executed before rendering this scene */
  34457. beforeRender: Nullable<() => void>;
  34458. /**
  34459. * An event triggered after rendering the scene
  34460. */
  34461. onAfterRenderObservable: Observable<Scene>;
  34462. private _onAfterRenderObserver;
  34463. /** Sets a function to be executed after rendering this scene */
  34464. afterRender: Nullable<() => void>;
  34465. /**
  34466. * An event triggered before animating the scene
  34467. */
  34468. onBeforeAnimationsObservable: Observable<Scene>;
  34469. /**
  34470. * An event triggered after animations processing
  34471. */
  34472. onAfterAnimationsObservable: Observable<Scene>;
  34473. /**
  34474. * An event triggered before draw calls are ready to be sent
  34475. */
  34476. onBeforeDrawPhaseObservable: Observable<Scene>;
  34477. /**
  34478. * An event triggered after draw calls have been sent
  34479. */
  34480. onAfterDrawPhaseObservable: Observable<Scene>;
  34481. /**
  34482. * An event triggered when the scene is ready
  34483. */
  34484. onReadyObservable: Observable<Scene>;
  34485. /**
  34486. * An event triggered before rendering a camera
  34487. */
  34488. onBeforeCameraRenderObservable: Observable<Camera>;
  34489. private _onBeforeCameraRenderObserver;
  34490. /** Sets a function to be executed before rendering a camera*/
  34491. beforeCameraRender: () => void;
  34492. /**
  34493. * An event triggered after rendering a camera
  34494. */
  34495. onAfterCameraRenderObservable: Observable<Camera>;
  34496. private _onAfterCameraRenderObserver;
  34497. /** Sets a function to be executed after rendering a camera*/
  34498. afterCameraRender: () => void;
  34499. /**
  34500. * An event triggered when active meshes evaluation is about to start
  34501. */
  34502. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34503. /**
  34504. * An event triggered when active meshes evaluation is done
  34505. */
  34506. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34507. /**
  34508. * An event triggered when particles rendering is about to start
  34509. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34510. */
  34511. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34512. /**
  34513. * An event triggered when particles rendering is done
  34514. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34515. */
  34516. onAfterParticlesRenderingObservable: Observable<Scene>;
  34517. /**
  34518. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34519. */
  34520. onDataLoadedObservable: Observable<Scene>;
  34521. /**
  34522. * An event triggered when a camera is created
  34523. */
  34524. onNewCameraAddedObservable: Observable<Camera>;
  34525. /**
  34526. * An event triggered when a camera is removed
  34527. */
  34528. onCameraRemovedObservable: Observable<Camera>;
  34529. /**
  34530. * An event triggered when a light is created
  34531. */
  34532. onNewLightAddedObservable: Observable<Light>;
  34533. /**
  34534. * An event triggered when a light is removed
  34535. */
  34536. onLightRemovedObservable: Observable<Light>;
  34537. /**
  34538. * An event triggered when a geometry is created
  34539. */
  34540. onNewGeometryAddedObservable: Observable<Geometry>;
  34541. /**
  34542. * An event triggered when a geometry is removed
  34543. */
  34544. onGeometryRemovedObservable: Observable<Geometry>;
  34545. /**
  34546. * An event triggered when a transform node is created
  34547. */
  34548. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34549. /**
  34550. * An event triggered when a transform node is removed
  34551. */
  34552. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34553. /**
  34554. * An event triggered when a mesh is created
  34555. */
  34556. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34557. /**
  34558. * An event triggered when a mesh is removed
  34559. */
  34560. onMeshRemovedObservable: Observable<AbstractMesh>;
  34561. /**
  34562. * An event triggered when a material is created
  34563. */
  34564. onNewMaterialAddedObservable: Observable<Material>;
  34565. /**
  34566. * An event triggered when a material is removed
  34567. */
  34568. onMaterialRemovedObservable: Observable<Material>;
  34569. /**
  34570. * An event triggered when a texture is created
  34571. */
  34572. onNewTextureAddedObservable: Observable<BaseTexture>;
  34573. /**
  34574. * An event triggered when a texture is removed
  34575. */
  34576. onTextureRemovedObservable: Observable<BaseTexture>;
  34577. /**
  34578. * An event triggered when render targets are about to be rendered
  34579. * Can happen multiple times per frame.
  34580. */
  34581. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34582. /**
  34583. * An event triggered when render targets were rendered.
  34584. * Can happen multiple times per frame.
  34585. */
  34586. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34587. /**
  34588. * An event triggered before calculating deterministic simulation step
  34589. */
  34590. onBeforeStepObservable: Observable<Scene>;
  34591. /**
  34592. * An event triggered after calculating deterministic simulation step
  34593. */
  34594. onAfterStepObservable: Observable<Scene>;
  34595. /**
  34596. * An event triggered when the activeCamera property is updated
  34597. */
  34598. onActiveCameraChanged: Observable<Scene>;
  34599. /**
  34600. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34601. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34602. * 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)
  34603. */
  34604. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34605. /**
  34606. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34607. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34608. * 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)
  34609. */
  34610. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34611. /**
  34612. * This Observable will when a mesh has been imported into the scene.
  34613. */
  34614. onMeshImportedObservable: Observable<AbstractMesh>;
  34615. private _registeredForLateAnimationBindings;
  34616. /**
  34617. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34618. */
  34619. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34620. /**
  34621. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34622. */
  34623. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34624. /**
  34625. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34626. */
  34627. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34628. private _onPointerMove;
  34629. private _onPointerDown;
  34630. private _onPointerUp;
  34631. /** Callback called when a pointer move is detected */
  34632. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34633. /** Callback called when a pointer down is detected */
  34634. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34635. /** Callback called when a pointer up is detected */
  34636. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34637. /** Callback called when a pointer pick is detected */
  34638. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34639. /**
  34640. * 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).
  34641. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34642. */
  34643. onPrePointerObservable: Observable<PointerInfoPre>;
  34644. /**
  34645. * Observable event triggered each time an input event is received from the rendering canvas
  34646. */
  34647. onPointerObservable: Observable<PointerInfo>;
  34648. /**
  34649. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34650. */
  34651. readonly unTranslatedPointer: Vector2;
  34652. /** The distance in pixel that you have to move to prevent some events */
  34653. static DragMovementThreshold: number;
  34654. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34655. static LongPressDelay: number;
  34656. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34657. static DoubleClickDelay: number;
  34658. /** If you need to check double click without raising a single click at first click, enable this flag */
  34659. static ExclusiveDoubleClickMode: boolean;
  34660. private _initClickEvent;
  34661. private _initActionManager;
  34662. private _delayedSimpleClick;
  34663. private _delayedSimpleClickTimeout;
  34664. private _previousDelayedSimpleClickTimeout;
  34665. private _meshPickProceed;
  34666. private _previousButtonPressed;
  34667. private _currentPickResult;
  34668. private _previousPickResult;
  34669. private _totalPointersPressed;
  34670. private _doubleClickOccured;
  34671. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34672. cameraToUseForPointers: Nullable<Camera>;
  34673. private _pointerX;
  34674. private _pointerY;
  34675. private _unTranslatedPointerX;
  34676. private _unTranslatedPointerY;
  34677. private _startingPointerPosition;
  34678. private _previousStartingPointerPosition;
  34679. private _startingPointerTime;
  34680. private _previousStartingPointerTime;
  34681. private _pointerCaptures;
  34682. private _timeAccumulator;
  34683. private _currentStepId;
  34684. private _currentInternalStep;
  34685. /** @hidden */
  34686. _mirroredCameraPosition: Nullable<Vector3>;
  34687. /**
  34688. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34689. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34690. */
  34691. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34692. /**
  34693. * Observable event triggered each time an keyboard event is received from the hosting window
  34694. */
  34695. onKeyboardObservable: Observable<KeyboardInfo>;
  34696. private _onKeyDown;
  34697. private _onKeyUp;
  34698. private _onCanvasFocusObserver;
  34699. private _onCanvasBlurObserver;
  34700. private _useRightHandedSystem;
  34701. /**
  34702. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34703. */
  34704. useRightHandedSystem: boolean;
  34705. /**
  34706. * Sets the step Id used by deterministic lock step
  34707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34708. * @param newStepId defines the step Id
  34709. */
  34710. setStepId(newStepId: number): void;
  34711. /**
  34712. * Gets the step Id used by deterministic lock step
  34713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34714. * @returns the step Id
  34715. */
  34716. getStepId(): number;
  34717. /**
  34718. * Gets the internal step used by deterministic lock step
  34719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34720. * @returns the internal step
  34721. */
  34722. getInternalStep(): number;
  34723. private _fogEnabled;
  34724. /**
  34725. * Gets or sets a boolean indicating if fog is enabled on this scene
  34726. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34727. * (Default is true)
  34728. */
  34729. fogEnabled: boolean;
  34730. private _fogMode;
  34731. /**
  34732. * Gets or sets the fog mode to use
  34733. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34734. * | mode | value |
  34735. * | --- | --- |
  34736. * | FOGMODE_NONE | 0 |
  34737. * | FOGMODE_EXP | 1 |
  34738. * | FOGMODE_EXP2 | 2 |
  34739. * | FOGMODE_LINEAR | 3 |
  34740. */
  34741. fogMode: number;
  34742. /**
  34743. * Gets or sets the fog color to use
  34744. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34745. * (Default is Color3(0.2, 0.2, 0.3))
  34746. */
  34747. fogColor: Color3;
  34748. /**
  34749. * Gets or sets the fog density to use
  34750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34751. * (Default is 0.1)
  34752. */
  34753. fogDensity: number;
  34754. /**
  34755. * Gets or sets the fog start distance to use
  34756. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34757. * (Default is 0)
  34758. */
  34759. fogStart: number;
  34760. /**
  34761. * Gets or sets the fog end distance to use
  34762. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34763. * (Default is 1000)
  34764. */
  34765. fogEnd: number;
  34766. private _shadowsEnabled;
  34767. /**
  34768. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34769. */
  34770. shadowsEnabled: boolean;
  34771. private _lightsEnabled;
  34772. /**
  34773. * Gets or sets a boolean indicating if lights are enabled on this scene
  34774. */
  34775. lightsEnabled: boolean;
  34776. /** All of the active cameras added to this scene. */
  34777. activeCameras: Camera[];
  34778. private _activeCamera;
  34779. /** Gets or sets the current active camera */
  34780. activeCamera: Nullable<Camera>;
  34781. private _defaultMaterial;
  34782. /** The default material used on meshes when no material is affected */
  34783. /** The default material used on meshes when no material is affected */
  34784. defaultMaterial: Material;
  34785. private _texturesEnabled;
  34786. /**
  34787. * Gets or sets a boolean indicating if textures are enabled on this scene
  34788. */
  34789. texturesEnabled: boolean;
  34790. /**
  34791. * Gets or sets a boolean indicating if particles are enabled on this scene
  34792. */
  34793. particlesEnabled: boolean;
  34794. /**
  34795. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34796. */
  34797. spritesEnabled: boolean;
  34798. private _skeletonsEnabled;
  34799. /**
  34800. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34801. */
  34802. skeletonsEnabled: boolean;
  34803. /**
  34804. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34805. */
  34806. lensFlaresEnabled: boolean;
  34807. /**
  34808. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34810. */
  34811. collisionsEnabled: boolean;
  34812. /** @hidden */
  34813. collisionCoordinator: ICollisionCoordinator;
  34814. /**
  34815. * Defines the gravity applied to this scene (used only for collisions)
  34816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34817. */
  34818. gravity: Vector3;
  34819. /**
  34820. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34821. */
  34822. postProcessesEnabled: boolean;
  34823. /**
  34824. * The list of postprocesses added to the scene
  34825. */
  34826. postProcesses: PostProcess[];
  34827. /**
  34828. * Gets the current postprocess manager
  34829. */
  34830. postProcessManager: PostProcessManager;
  34831. /**
  34832. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34833. */
  34834. renderTargetsEnabled: boolean;
  34835. /**
  34836. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34837. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34838. */
  34839. dumpNextRenderTargets: boolean;
  34840. /**
  34841. * The list of user defined render targets added to the scene
  34842. */
  34843. customRenderTargets: RenderTargetTexture[];
  34844. /**
  34845. * Defines if texture loading must be delayed
  34846. * If true, textures will only be loaded when they need to be rendered
  34847. */
  34848. useDelayedTextureLoading: boolean;
  34849. /**
  34850. * Gets the list of meshes imported to the scene through SceneLoader
  34851. */
  34852. importedMeshesFiles: String[];
  34853. /**
  34854. * Gets or sets a boolean indicating if probes are enabled on this scene
  34855. */
  34856. probesEnabled: boolean;
  34857. /**
  34858. * Gets or sets the current offline provider to use to store scene data
  34859. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34860. */
  34861. offlineProvider: IOfflineProvider;
  34862. /**
  34863. * Gets or sets the action manager associated with the scene
  34864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34865. */
  34866. actionManager: ActionManager;
  34867. private _meshesForIntersections;
  34868. /**
  34869. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34870. */
  34871. proceduralTexturesEnabled: boolean;
  34872. private _engine;
  34873. private _totalVertices;
  34874. /** @hidden */
  34875. _activeIndices: PerfCounter;
  34876. /** @hidden */
  34877. _activeParticles: PerfCounter;
  34878. /** @hidden */
  34879. _activeBones: PerfCounter;
  34880. private _animationRatio;
  34881. private _animationTimeLast;
  34882. private _animationTime;
  34883. /**
  34884. * Gets or sets a general scale for animation speed
  34885. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34886. */
  34887. animationTimeScale: number;
  34888. /** @hidden */
  34889. _cachedMaterial: Nullable<Material>;
  34890. /** @hidden */
  34891. _cachedEffect: Nullable<Effect>;
  34892. /** @hidden */
  34893. _cachedVisibility: Nullable<number>;
  34894. private _renderId;
  34895. private _frameId;
  34896. private _executeWhenReadyTimeoutId;
  34897. private _intermediateRendering;
  34898. private _viewUpdateFlag;
  34899. private _projectionUpdateFlag;
  34900. private _alternateViewUpdateFlag;
  34901. private _alternateProjectionUpdateFlag;
  34902. /** @hidden */
  34903. _toBeDisposed: Nullable<IDisposable>[];
  34904. private _activeRequests;
  34905. private _pendingData;
  34906. private _isDisposed;
  34907. /**
  34908. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34909. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34910. */
  34911. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34912. private _activeMeshes;
  34913. private _processedMaterials;
  34914. private _renderTargets;
  34915. /** @hidden */
  34916. _activeParticleSystems: SmartArray<IParticleSystem>;
  34917. private _activeSkeletons;
  34918. private _softwareSkinnedMeshes;
  34919. private _renderingManager;
  34920. /** @hidden */
  34921. _activeAnimatables: Animatable[];
  34922. private _transformMatrix;
  34923. private _sceneUbo;
  34924. private _alternateSceneUbo;
  34925. private _pickWithRayInverseMatrix;
  34926. private _viewMatrix;
  34927. private _projectionMatrix;
  34928. private _alternateViewMatrix;
  34929. private _alternateProjectionMatrix;
  34930. private _alternateTransformMatrix;
  34931. private _useAlternateCameraConfiguration;
  34932. private _alternateRendering;
  34933. private _wheelEventName;
  34934. /** @hidden */
  34935. _forcedViewPosition: Nullable<Vector3>;
  34936. /** @hidden */
  34937. readonly _isAlternateRenderingEnabled: boolean;
  34938. private _frustumPlanes;
  34939. /**
  34940. * Gets the list of frustum planes (built from the active camera)
  34941. */
  34942. readonly frustumPlanes: Plane[];
  34943. /**
  34944. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34945. * This is useful if there are more lights that the maximum simulteanous authorized
  34946. */
  34947. requireLightSorting: boolean;
  34948. /** @hidden */
  34949. readonly useMaterialMeshMap: boolean;
  34950. /** @hidden */
  34951. readonly useClonedMeshhMap: boolean;
  34952. private _pointerOverMesh;
  34953. private _pickedDownMesh;
  34954. private _pickedUpMesh;
  34955. private _externalData;
  34956. private _uid;
  34957. /**
  34958. * @hidden
  34959. * Backing store of defined scene components.
  34960. */
  34961. _components: ISceneComponent[];
  34962. /**
  34963. * @hidden
  34964. * Backing store of defined scene components.
  34965. */
  34966. _serializableComponents: ISceneSerializableComponent[];
  34967. /**
  34968. * List of components to register on the next registration step.
  34969. */
  34970. private _transientComponents;
  34971. /**
  34972. * Registers the transient components if needed.
  34973. */
  34974. private _registerTransientComponents;
  34975. /**
  34976. * @hidden
  34977. * Add a component to the scene.
  34978. * Note that the ccomponent could be registered on th next frame if this is called after
  34979. * the register component stage.
  34980. * @param component Defines the component to add to the scene
  34981. */
  34982. _addComponent(component: ISceneComponent): void;
  34983. /**
  34984. * @hidden
  34985. * Gets a component from the scene.
  34986. * @param name defines the name of the component to retrieve
  34987. * @returns the component or null if not present
  34988. */
  34989. _getComponent(name: string): Nullable<ISceneComponent>;
  34990. /**
  34991. * @hidden
  34992. * Defines the actions happening before camera updates.
  34993. */
  34994. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34995. /**
  34996. * @hidden
  34997. * Defines the actions happening before clear the canvas.
  34998. */
  34999. _beforeClearStage: Stage<SimpleStageAction>;
  35000. /**
  35001. * @hidden
  35002. * Defines the actions when collecting render targets for the frame.
  35003. */
  35004. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35005. /**
  35006. * @hidden
  35007. * Defines the actions happening for one camera in the frame.
  35008. */
  35009. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35010. /**
  35011. * @hidden
  35012. * Defines the actions happening during the per mesh ready checks.
  35013. */
  35014. _isReadyForMeshStage: Stage<MeshStageAction>;
  35015. /**
  35016. * @hidden
  35017. * Defines the actions happening before evaluate active mesh checks.
  35018. */
  35019. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35020. /**
  35021. * @hidden
  35022. * Defines the actions happening during the evaluate sub mesh checks.
  35023. */
  35024. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35025. /**
  35026. * @hidden
  35027. * Defines the actions happening during the active mesh stage.
  35028. */
  35029. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35030. /**
  35031. * @hidden
  35032. * Defines the actions happening during the per camera render target step.
  35033. */
  35034. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  35035. /**
  35036. * @hidden
  35037. * Defines the actions happening just before the active camera is drawing.
  35038. */
  35039. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35040. /**
  35041. * @hidden
  35042. * Defines the actions happening just before a render target is drawing.
  35043. */
  35044. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35045. /**
  35046. * @hidden
  35047. * Defines the actions happening just before a rendering group is drawing.
  35048. */
  35049. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35050. /**
  35051. * @hidden
  35052. * Defines the actions happening just before a mesh is drawing.
  35053. */
  35054. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35055. /**
  35056. * @hidden
  35057. * Defines the actions happening just after a mesh has been drawn.
  35058. */
  35059. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35060. /**
  35061. * @hidden
  35062. * Defines the actions happening just after a rendering group has been drawn.
  35063. */
  35064. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35065. /**
  35066. * @hidden
  35067. * Defines the actions happening just after the active camera has been drawn.
  35068. */
  35069. _afterCameraDrawStage: Stage<CameraStageAction>;
  35070. /**
  35071. * @hidden
  35072. * Defines the actions happening just after a render target has been drawn.
  35073. */
  35074. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35075. /**
  35076. * @hidden
  35077. * Defines the actions happening just after rendering all cameras and computing intersections.
  35078. */
  35079. _afterRenderStage: Stage<SimpleStageAction>;
  35080. /**
  35081. * @hidden
  35082. * Defines the actions happening when a pointer move event happens.
  35083. */
  35084. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35085. /**
  35086. * @hidden
  35087. * Defines the actions happening when a pointer down event happens.
  35088. */
  35089. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35090. /**
  35091. * @hidden
  35092. * Defines the actions happening when a pointer up event happens.
  35093. */
  35094. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35095. /**
  35096. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35097. */
  35098. private geometriesById;
  35099. /**
  35100. * Creates a new Scene
  35101. * @param engine defines the engine to use to render this scene
  35102. */
  35103. constructor(engine: Engine, options?: SceneOptions);
  35104. private _defaultMeshCandidates;
  35105. /**
  35106. * @hidden
  35107. */
  35108. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35109. private _defaultSubMeshCandidates;
  35110. /**
  35111. * @hidden
  35112. */
  35113. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35114. /**
  35115. * Sets the default candidate providers for the scene.
  35116. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35117. * and getCollidingSubMeshCandidates to their default function
  35118. */
  35119. setDefaultCandidateProviders(): void;
  35120. /**
  35121. * Gets a boolean indicating if collisions are processed on a web worker
  35122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  35123. */
  35124. workerCollisions: boolean;
  35125. /**
  35126. * Gets the mesh that is currently under the pointer
  35127. */
  35128. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35129. /**
  35130. * Gets the current on-screen X position of the pointer
  35131. */
  35132. readonly pointerX: number;
  35133. /**
  35134. * Gets the current on-screen Y position of the pointer
  35135. */
  35136. readonly pointerY: number;
  35137. /**
  35138. * Gets the cached material (ie. the latest rendered one)
  35139. * @returns the cached material
  35140. */
  35141. getCachedMaterial(): Nullable<Material>;
  35142. /**
  35143. * Gets the cached effect (ie. the latest rendered one)
  35144. * @returns the cached effect
  35145. */
  35146. getCachedEffect(): Nullable<Effect>;
  35147. /**
  35148. * Gets the cached visibility state (ie. the latest rendered one)
  35149. * @returns the cached visibility state
  35150. */
  35151. getCachedVisibility(): Nullable<number>;
  35152. /**
  35153. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35154. * @param material defines the current material
  35155. * @param effect defines the current effect
  35156. * @param visibility defines the current visibility state
  35157. * @returns true if one parameter is not cached
  35158. */
  35159. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35160. /**
  35161. * Gets the engine associated with the scene
  35162. * @returns an Engine
  35163. */
  35164. getEngine(): Engine;
  35165. /**
  35166. * Gets the total number of vertices rendered per frame
  35167. * @returns the total number of vertices rendered per frame
  35168. */
  35169. getTotalVertices(): number;
  35170. /**
  35171. * Gets the performance counter for total vertices
  35172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35173. */
  35174. readonly totalVerticesPerfCounter: PerfCounter;
  35175. /**
  35176. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35177. * @returns the total number of active indices rendered per frame
  35178. */
  35179. getActiveIndices(): number;
  35180. /**
  35181. * Gets the performance counter for active indices
  35182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35183. */
  35184. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35185. /**
  35186. * Gets the total number of active particles rendered per frame
  35187. * @returns the total number of active particles rendered per frame
  35188. */
  35189. getActiveParticles(): number;
  35190. /**
  35191. * Gets the performance counter for active particles
  35192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35193. */
  35194. readonly activeParticlesPerfCounter: PerfCounter;
  35195. /**
  35196. * Gets the total number of active bones rendered per frame
  35197. * @returns the total number of active bones rendered per frame
  35198. */
  35199. getActiveBones(): number;
  35200. /**
  35201. * Gets the performance counter for active bones
  35202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35203. */
  35204. readonly activeBonesPerfCounter: PerfCounter;
  35205. /**
  35206. * Gets the array of active meshes
  35207. * @returns an array of AbstractMesh
  35208. */
  35209. getActiveMeshes(): SmartArray<AbstractMesh>;
  35210. /**
  35211. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35212. * @returns a number
  35213. */
  35214. getAnimationRatio(): number;
  35215. /**
  35216. * Gets an unique Id for the current render phase
  35217. * @returns a number
  35218. */
  35219. getRenderId(): number;
  35220. /**
  35221. * Gets an unique Id for the current frame
  35222. * @returns a number
  35223. */
  35224. getFrameId(): number;
  35225. /** Call this function if you want to manually increment the render Id*/
  35226. incrementRenderId(): void;
  35227. private _updatePointerPosition;
  35228. private _createUbo;
  35229. private _createAlternateUbo;
  35230. private _setRayOnPointerInfo;
  35231. /**
  35232. * Use this method to simulate a pointer move on a mesh
  35233. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35234. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35235. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35236. * @returns the current scene
  35237. */
  35238. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35239. private _processPointerMove;
  35240. private _checkPrePointerObservable;
  35241. /**
  35242. * Use this method to simulate a pointer down on a mesh
  35243. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35244. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35245. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35246. * @returns the current scene
  35247. */
  35248. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35249. private _processPointerDown;
  35250. /**
  35251. * Use this method to simulate a pointer up on a mesh
  35252. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35253. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35254. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35255. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35256. * @returns the current scene
  35257. */
  35258. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35259. private _processPointerUp;
  35260. /**
  35261. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35262. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35263. * @returns true if the pointer was captured
  35264. */
  35265. isPointerCaptured(pointerId?: number): boolean;
  35266. /** @hidden */
  35267. _isPointerSwiping(): boolean;
  35268. /**
  35269. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35270. * @param attachUp defines if you want to attach events to pointerup
  35271. * @param attachDown defines if you want to attach events to pointerdown
  35272. * @param attachMove defines if you want to attach events to pointermove
  35273. */
  35274. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35275. /** Detaches all event handlers*/
  35276. detachControl(): void;
  35277. /**
  35278. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35279. * Delay loaded resources are not taking in account
  35280. * @return true if all required resources are ready
  35281. */
  35282. isReady(): boolean;
  35283. /** Resets all cached information relative to material (including effect and visibility) */
  35284. resetCachedMaterial(): void;
  35285. /**
  35286. * Registers a function to be called before every frame render
  35287. * @param func defines the function to register
  35288. */
  35289. registerBeforeRender(func: () => void): void;
  35290. /**
  35291. * Unregisters a function called before every frame render
  35292. * @param func defines the function to unregister
  35293. */
  35294. unregisterBeforeRender(func: () => void): void;
  35295. /**
  35296. * Registers a function to be called after every frame render
  35297. * @param func defines the function to register
  35298. */
  35299. registerAfterRender(func: () => void): void;
  35300. /**
  35301. * Unregisters a function called after every frame render
  35302. * @param func defines the function to unregister
  35303. */
  35304. unregisterAfterRender(func: () => void): void;
  35305. private _executeOnceBeforeRender;
  35306. /**
  35307. * The provided function will run before render once and will be disposed afterwards.
  35308. * A timeout delay can be provided so that the function will be executed in N ms.
  35309. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35310. * @param func The function to be executed.
  35311. * @param timeout optional delay in ms
  35312. */
  35313. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35314. /** @hidden */
  35315. _addPendingData(data: any): void;
  35316. /** @hidden */
  35317. _removePendingData(data: any): void;
  35318. /**
  35319. * Returns the number of items waiting to be loaded
  35320. * @returns the number of items waiting to be loaded
  35321. */
  35322. getWaitingItemsCount(): number;
  35323. /**
  35324. * Returns a boolean indicating if the scene is still loading data
  35325. */
  35326. readonly isLoading: boolean;
  35327. /**
  35328. * Registers a function to be executed when the scene is ready
  35329. * @param {Function} func - the function to be executed
  35330. */
  35331. executeWhenReady(func: () => void): void;
  35332. /**
  35333. * Returns a promise that resolves when the scene is ready
  35334. * @returns A promise that resolves when the scene is ready
  35335. */
  35336. whenReadyAsync(): Promise<void>;
  35337. /** @hidden */
  35338. _checkIsReady(): void;
  35339. /**
  35340. * Will start the animation sequence of a given target
  35341. * @param target defines the target
  35342. * @param from defines from which frame should animation start
  35343. * @param to defines until which frame should animation run.
  35344. * @param weight defines the weight to apply to the animation (1.0 by default)
  35345. * @param loop defines if the animation loops
  35346. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  35347. * @param onAnimationEnd defines the function to be executed when the animation ends
  35348. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  35349. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  35350. * @returns the animatable object created for this animation
  35351. */
  35352. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  35353. /**
  35354. * Will start the animation sequence of a given target
  35355. * @param target defines the target
  35356. * @param from defines from which frame should animation start
  35357. * @param to defines until which frame should animation run.
  35358. * @param loop defines if the animation loops
  35359. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  35360. * @param onAnimationEnd defines the function to be executed when the animation ends
  35361. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  35362. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  35363. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  35364. * @returns the animatable object created for this animation
  35365. */
  35366. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  35367. /**
  35368. * Will start the animation sequence of a given target and its hierarchy
  35369. * @param target defines the target
  35370. * @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.
  35371. * @param from defines from which frame should animation start
  35372. * @param to defines until which frame should animation run.
  35373. * @param loop defines if the animation loops
  35374. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  35375. * @param onAnimationEnd defines the function to be executed when the animation ends
  35376. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  35377. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  35378. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  35379. * @returns the list of created animatables
  35380. */
  35381. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  35382. /**
  35383. * Begin a new animation on a given node
  35384. * @param target defines the target where the animation will take place
  35385. * @param animations defines the list of animations to start
  35386. * @param from defines the initial value
  35387. * @param to defines the final value
  35388. * @param loop defines if you want animation to loop (off by default)
  35389. * @param speedRatio defines the speed ratio to apply to all animations
  35390. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  35391. * @returns the list of created animatables
  35392. */
  35393. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  35394. /**
  35395. * Begin a new animation on a given node and its hierarchy
  35396. * @param target defines the root node where the animation will take place
  35397. * @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.
  35398. * @param animations defines the list of animations to start
  35399. * @param from defines the initial value
  35400. * @param to defines the final value
  35401. * @param loop defines if you want animation to loop (off by default)
  35402. * @param speedRatio defines the speed ratio to apply to all animations
  35403. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  35404. * @returns the list of animatables created for all nodes
  35405. */
  35406. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  35407. /**
  35408. * Gets the animatable associated with a specific target
  35409. * @param target defines the target of the animatable
  35410. * @returns the required animatable if found
  35411. */
  35412. getAnimatableByTarget(target: any): Nullable<Animatable>;
  35413. /**
  35414. * Gets all animatables associated with a given target
  35415. * @param target defines the target to look animatables for
  35416. * @returns an array of Animatables
  35417. */
  35418. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  35419. /**
  35420. * Gets all animatable attached to the scene
  35421. */
  35422. readonly animatables: Animatable[];
  35423. /**
  35424. * Will stop the animation of the given target
  35425. * @param target - the target
  35426. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35427. * @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)
  35428. */
  35429. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35430. /**
  35431. * Stops and removes all animations that have been applied to the scene
  35432. */
  35433. stopAllAnimations(): void;
  35434. private _animate;
  35435. /** @hidden */
  35436. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  35437. private _processLateAnimationBindingsForMatrices;
  35438. private _processLateAnimationBindingsForQuaternions;
  35439. private _processLateAnimationBindings;
  35440. /** @hidden */
  35441. _switchToAlternateCameraConfiguration(active: boolean): void;
  35442. /**
  35443. * Gets the current view matrix
  35444. * @returns a Matrix
  35445. */
  35446. getViewMatrix(): Matrix;
  35447. /**
  35448. * Gets the current projection matrix
  35449. * @returns a Matrix
  35450. */
  35451. getProjectionMatrix(): Matrix;
  35452. /**
  35453. * Gets the current transform matrix
  35454. * @returns a Matrix made of View * Projection
  35455. */
  35456. getTransformMatrix(): Matrix;
  35457. /**
  35458. * Sets the current transform matrix
  35459. * @param view defines the View matrix to use
  35460. * @param projection defines the Projection matrix to use
  35461. */
  35462. setTransformMatrix(view: Matrix, projection: Matrix): void;
  35463. /** @hidden */
  35464. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  35465. /**
  35466. * Gets the uniform buffer used to store scene data
  35467. * @returns a UniformBuffer
  35468. */
  35469. getSceneUniformBuffer(): UniformBuffer;
  35470. /**
  35471. * Gets an unique (relatively to the current scene) Id
  35472. * @returns an unique number for the scene
  35473. */
  35474. getUniqueId(): number;
  35475. /**
  35476. * Add a mesh to the list of scene's meshes
  35477. * @param newMesh defines the mesh to add
  35478. * @param recursive if all child meshes should also be added to the scene
  35479. */
  35480. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35481. /**
  35482. * Remove a mesh for the list of scene's meshes
  35483. * @param toRemove defines the mesh to remove
  35484. * @param recursive if all child meshes should also be removed from the scene
  35485. * @returns the index where the mesh was in the mesh list
  35486. */
  35487. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35488. /**
  35489. * Add a transform node to the list of scene's transform nodes
  35490. * @param newTransformNode defines the transform node to add
  35491. */
  35492. addTransformNode(newTransformNode: TransformNode): void;
  35493. /**
  35494. * Remove a transform node for the list of scene's transform nodes
  35495. * @param toRemove defines the transform node to remove
  35496. * @returns the index where the transform node was in the transform node list
  35497. */
  35498. removeTransformNode(toRemove: TransformNode): number;
  35499. /**
  35500. * Remove a skeleton for the list of scene's skeletons
  35501. * @param toRemove defines the skeleton to remove
  35502. * @returns the index where the skeleton was in the skeleton list
  35503. */
  35504. removeSkeleton(toRemove: Skeleton): number;
  35505. /**
  35506. * Remove a morph target for the list of scene's morph targets
  35507. * @param toRemove defines the morph target to remove
  35508. * @returns the index where the morph target was in the morph target list
  35509. */
  35510. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35511. /**
  35512. * Remove a light for the list of scene's lights
  35513. * @param toRemove defines the light to remove
  35514. * @returns the index where the light was in the light list
  35515. */
  35516. removeLight(toRemove: Light): number;
  35517. /**
  35518. * Remove a camera for the list of scene's cameras
  35519. * @param toRemove defines the camera to remove
  35520. * @returns the index where the camera was in the camera list
  35521. */
  35522. removeCamera(toRemove: Camera): number;
  35523. /**
  35524. * Remove a particle system for the list of scene's particle systems
  35525. * @param toRemove defines the particle system to remove
  35526. * @returns the index where the particle system was in the particle system list
  35527. */
  35528. removeParticleSystem(toRemove: IParticleSystem): number;
  35529. /**
  35530. * Remove a animation for the list of scene's animations
  35531. * @param toRemove defines the animation to remove
  35532. * @returns the index where the animation was in the animation list
  35533. */
  35534. removeAnimation(toRemove: Animation): number;
  35535. /**
  35536. * Removes the given animation group from this scene.
  35537. * @param toRemove The animation group to remove
  35538. * @returns The index of the removed animation group
  35539. */
  35540. removeAnimationGroup(toRemove: AnimationGroup): number;
  35541. /**
  35542. * Removes the given multi-material from this scene.
  35543. * @param toRemove The multi-material to remove
  35544. * @returns The index of the removed multi-material
  35545. */
  35546. removeMultiMaterial(toRemove: MultiMaterial): number;
  35547. /**
  35548. * Removes the given material from this scene.
  35549. * @param toRemove The material to remove
  35550. * @returns The index of the removed material
  35551. */
  35552. removeMaterial(toRemove: Material): number;
  35553. /**
  35554. * Removes the given action manager from this scene.
  35555. * @param toRemove The action manager to remove
  35556. * @returns The index of the removed action manager
  35557. */
  35558. removeActionManager(toRemove: ActionManager): number;
  35559. /**
  35560. * Removes the given texture from this scene.
  35561. * @param toRemove The texture to remove
  35562. * @returns The index of the removed texture
  35563. */
  35564. removeTexture(toRemove: BaseTexture): number;
  35565. /**
  35566. * Adds the given light to this scene
  35567. * @param newLight The light to add
  35568. */
  35569. addLight(newLight: Light): void;
  35570. /**
  35571. * Sorts the list list based on light priorities
  35572. */
  35573. sortLightsByPriority(): void;
  35574. /**
  35575. * Adds the given camera to this scene
  35576. * @param newCamera The camera to add
  35577. */
  35578. addCamera(newCamera: Camera): void;
  35579. /**
  35580. * Adds the given skeleton to this scene
  35581. * @param newSkeleton The skeleton to add
  35582. */
  35583. addSkeleton(newSkeleton: Skeleton): void;
  35584. /**
  35585. * Adds the given particle system to this scene
  35586. * @param newParticleSystem The particle system to add
  35587. */
  35588. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35589. /**
  35590. * Adds the given animation to this scene
  35591. * @param newAnimation The animation to add
  35592. */
  35593. addAnimation(newAnimation: Animation): void;
  35594. /**
  35595. * Adds the given animation group to this scene.
  35596. * @param newAnimationGroup The animation group to add
  35597. */
  35598. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35599. /**
  35600. * Adds the given multi-material to this scene
  35601. * @param newMultiMaterial The multi-material to add
  35602. */
  35603. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35604. /**
  35605. * Adds the given material to this scene
  35606. * @param newMaterial The material to add
  35607. */
  35608. addMaterial(newMaterial: Material): void;
  35609. /**
  35610. * Adds the given morph target to this scene
  35611. * @param newMorphTargetManager The morph target to add
  35612. */
  35613. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35614. /**
  35615. * Adds the given geometry to this scene
  35616. * @param newGeometry The geometry to add
  35617. */
  35618. addGeometry(newGeometry: Geometry): void;
  35619. /**
  35620. * Adds the given action manager to this scene
  35621. * @param newActionManager The action manager to add
  35622. */
  35623. addActionManager(newActionManager: ActionManager): void;
  35624. /**
  35625. * Adds the given texture to this scene.
  35626. * @param newTexture The texture to add
  35627. */
  35628. addTexture(newTexture: BaseTexture): void;
  35629. /**
  35630. * Switch active camera
  35631. * @param newCamera defines the new active camera
  35632. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35633. */
  35634. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35635. /**
  35636. * sets the active camera of the scene using its ID
  35637. * @param id defines the camera's ID
  35638. * @return the new active camera or null if none found.
  35639. */
  35640. setActiveCameraByID(id: string): Nullable<Camera>;
  35641. /**
  35642. * sets the active camera of the scene using its name
  35643. * @param name defines the camera's name
  35644. * @returns the new active camera or null if none found.
  35645. */
  35646. setActiveCameraByName(name: string): Nullable<Camera>;
  35647. /**
  35648. * get an animation group using its name
  35649. * @param name defines the material's name
  35650. * @return the animation group or null if none found.
  35651. */
  35652. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35653. /**
  35654. * get a material using its id
  35655. * @param id defines the material's ID
  35656. * @return the material or null if none found.
  35657. */
  35658. getMaterialByID(id: string): Nullable<Material>;
  35659. /**
  35660. * Gets a material using its name
  35661. * @param name defines the material's name
  35662. * @return the material or null if none found.
  35663. */
  35664. getMaterialByName(name: string): Nullable<Material>;
  35665. /**
  35666. * Gets a camera using its id
  35667. * @param id defines the id to look for
  35668. * @returns the camera or null if not found
  35669. */
  35670. getCameraByID(id: string): Nullable<Camera>;
  35671. /**
  35672. * Gets a camera using its unique id
  35673. * @param uniqueId defines the unique id to look for
  35674. * @returns the camera or null if not found
  35675. */
  35676. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35677. /**
  35678. * Gets a camera using its name
  35679. * @param name defines the camera's name
  35680. * @return the camera or null if none found.
  35681. */
  35682. getCameraByName(name: string): Nullable<Camera>;
  35683. /**
  35684. * Gets a bone using its id
  35685. * @param id defines the bone's id
  35686. * @return the bone or null if not found
  35687. */
  35688. getBoneByID(id: string): Nullable<Bone>;
  35689. /**
  35690. * Gets a bone using its id
  35691. * @param name defines the bone's name
  35692. * @return the bone or null if not found
  35693. */
  35694. getBoneByName(name: string): Nullable<Bone>;
  35695. /**
  35696. * Gets a light node using its name
  35697. * @param name defines the the light's name
  35698. * @return the light or null if none found.
  35699. */
  35700. getLightByName(name: string): Nullable<Light>;
  35701. /**
  35702. * Gets a light node using its id
  35703. * @param id defines the light's id
  35704. * @return the light or null if none found.
  35705. */
  35706. getLightByID(id: string): Nullable<Light>;
  35707. /**
  35708. * Gets a light node using its scene-generated unique ID
  35709. * @param uniqueId defines the light's unique id
  35710. * @return the light or null if none found.
  35711. */
  35712. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35713. /**
  35714. * Gets a particle system by id
  35715. * @param id defines the particle system id
  35716. * @return the corresponding system or null if none found
  35717. */
  35718. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35719. /**
  35720. * Gets a geometry using its ID
  35721. * @param id defines the geometry's id
  35722. * @return the geometry or null if none found.
  35723. */
  35724. getGeometryByID(id: string): Nullable<Geometry>;
  35725. private _getGeometryByUniqueID;
  35726. /**
  35727. * Add a new geometry to this scene
  35728. * @param geometry defines the geometry to be added to the scene.
  35729. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35730. * @return a boolean defining if the geometry was added or not
  35731. */
  35732. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35733. /**
  35734. * Removes an existing geometry
  35735. * @param geometry defines the geometry to be removed from the scene
  35736. * @return a boolean defining if the geometry was removed or not
  35737. */
  35738. removeGeometry(geometry: Geometry): boolean;
  35739. /**
  35740. * Gets the list of geometries attached to the scene
  35741. * @returns an array of Geometry
  35742. */
  35743. getGeometries(): Geometry[];
  35744. /**
  35745. * Gets the first added mesh found of a given ID
  35746. * @param id defines the id to search for
  35747. * @return the mesh found or null if not found at all
  35748. */
  35749. getMeshByID(id: string): Nullable<AbstractMesh>;
  35750. /**
  35751. * Gets a list of meshes using their id
  35752. * @param id defines the id to search for
  35753. * @returns a list of meshes
  35754. */
  35755. getMeshesByID(id: string): Array<AbstractMesh>;
  35756. /**
  35757. * Gets the first added transform node found of a given ID
  35758. * @param id defines the id to search for
  35759. * @return the found transform node or null if not found at all.
  35760. */
  35761. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35762. /**
  35763. * Gets a list of transform nodes using their id
  35764. * @param id defines the id to search for
  35765. * @returns a list of transform nodes
  35766. */
  35767. getTransformNodesByID(id: string): Array<TransformNode>;
  35768. /**
  35769. * Gets a mesh with its auto-generated unique id
  35770. * @param uniqueId defines the unique id to search for
  35771. * @return the found mesh or null if not found at all.
  35772. */
  35773. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35774. /**
  35775. * Gets a the last added mesh using a given id
  35776. * @param id defines the id to search for
  35777. * @return the found mesh or null if not found at all.
  35778. */
  35779. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35780. /**
  35781. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35782. * @param id defines the id to search for
  35783. * @return the found node or null if not found at all
  35784. */
  35785. getLastEntryByID(id: string): Nullable<Node>;
  35786. /**
  35787. * Gets a node (Mesh, Camera, Light) using a given id
  35788. * @param id defines the id to search for
  35789. * @return the found node or null if not found at all
  35790. */
  35791. getNodeByID(id: string): Nullable<Node>;
  35792. /**
  35793. * Gets a node (Mesh, Camera, Light) using a given name
  35794. * @param name defines the name to search for
  35795. * @return the found node or null if not found at all.
  35796. */
  35797. getNodeByName(name: string): Nullable<Node>;
  35798. /**
  35799. * Gets a mesh using a given name
  35800. * @param name defines the name to search for
  35801. * @return the found mesh or null if not found at all.
  35802. */
  35803. getMeshByName(name: string): Nullable<AbstractMesh>;
  35804. /**
  35805. * Gets a transform node using a given name
  35806. * @param name defines the name to search for
  35807. * @return the found transform node or null if not found at all.
  35808. */
  35809. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35810. /**
  35811. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35812. * @param id defines the id to search for
  35813. * @return the found skeleton or null if not found at all.
  35814. */
  35815. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35816. /**
  35817. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35818. * @param id defines the id to search for
  35819. * @return the found skeleton or null if not found at all.
  35820. */
  35821. getSkeletonById(id: string): Nullable<Skeleton>;
  35822. /**
  35823. * Gets a skeleton using a given name
  35824. * @param name defines the name to search for
  35825. * @return the found skeleton or null if not found at all.
  35826. */
  35827. getSkeletonByName(name: string): Nullable<Skeleton>;
  35828. /**
  35829. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35830. * @param id defines the id to search for
  35831. * @return the found morph target manager or null if not found at all.
  35832. */
  35833. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35834. /**
  35835. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35836. * @param id defines the id to search for
  35837. * @return the found morph target or null if not found at all.
  35838. */
  35839. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35840. /**
  35841. * Gets a boolean indicating if the given mesh is active
  35842. * @param mesh defines the mesh to look for
  35843. * @returns true if the mesh is in the active list
  35844. */
  35845. isActiveMesh(mesh: AbstractMesh): boolean;
  35846. /**
  35847. * Return a unique id as a string which can serve as an identifier for the scene
  35848. */
  35849. readonly uid: string;
  35850. /**
  35851. * Add an externaly attached data from its key.
  35852. * This method call will fail and return false, if such key already exists.
  35853. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35854. * @param key the unique key that identifies the data
  35855. * @param data the data object to associate to the key for this Engine instance
  35856. * @return true if no such key were already present and the data was added successfully, false otherwise
  35857. */
  35858. addExternalData<T>(key: string, data: T): boolean;
  35859. /**
  35860. * Get an externaly attached data from its key
  35861. * @param key the unique key that identifies the data
  35862. * @return the associated data, if present (can be null), or undefined if not present
  35863. */
  35864. getExternalData<T>(key: string): Nullable<T>;
  35865. /**
  35866. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35867. * @param key the unique key that identifies the data
  35868. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35869. * @return the associated data, can be null if the factory returned null.
  35870. */
  35871. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35872. /**
  35873. * Remove an externaly attached data from the Engine instance
  35874. * @param key the unique key that identifies the data
  35875. * @return true if the data was successfully removed, false if it doesn't exist
  35876. */
  35877. removeExternalData(key: string): boolean;
  35878. private _evaluateSubMesh;
  35879. /**
  35880. * Clear the processed materials smart array preventing retention point in material dispose.
  35881. */
  35882. freeProcessedMaterials(): void;
  35883. private _preventFreeActiveMeshesAndRenderingGroups;
  35884. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35885. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35886. * when disposing several meshes in a row or a hierarchy of meshes.
  35887. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35888. */
  35889. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35890. /**
  35891. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35892. */
  35893. freeActiveMeshes(): void;
  35894. /**
  35895. * Clear the info related to rendering groups preventing retention points during dispose.
  35896. */
  35897. freeRenderingGroups(): void;
  35898. /** @hidden */
  35899. _isInIntermediateRendering(): boolean;
  35900. /**
  35901. * Lambda returning the list of potentially active meshes.
  35902. */
  35903. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35904. /**
  35905. * Lambda returning the list of potentially active sub meshes.
  35906. */
  35907. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35908. /**
  35909. * Lambda returning the list of potentially intersecting sub meshes.
  35910. */
  35911. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35912. /**
  35913. * Lambda returning the list of potentially colliding sub meshes.
  35914. */
  35915. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35916. private _activeMeshesFrozen;
  35917. /**
  35918. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35919. * @returns the current scene
  35920. */
  35921. freezeActiveMeshes(): Scene;
  35922. /**
  35923. * Use this function to restart evaluating active meshes on every frame
  35924. * @returns the current scene
  35925. */
  35926. unfreezeActiveMeshes(): Scene;
  35927. private _evaluateActiveMeshes;
  35928. private _activeMesh;
  35929. /**
  35930. * Update the transform matrix to update from the current active camera
  35931. * @param force defines a boolean used to force the update even if cache is up to date
  35932. */
  35933. updateTransformMatrix(force?: boolean): void;
  35934. /**
  35935. * 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)
  35936. * @param alternateCamera defines the camera to use
  35937. */
  35938. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  35939. /** @hidden */
  35940. _allowPostProcessClearColor: boolean;
  35941. private _renderForCamera;
  35942. private _processSubCameras;
  35943. private _checkIntersections;
  35944. /** @hidden */
  35945. _advancePhysicsEngineStep(step: number): void;
  35946. /**
  35947. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35948. */
  35949. getDeterministicFrameTime: () => number;
  35950. /**
  35951. * Render the scene
  35952. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35953. */
  35954. render(updateCameras?: boolean): void;
  35955. /**
  35956. * Freeze all materials
  35957. * A frozen material will not be updatable but should be faster to render
  35958. */
  35959. freezeMaterials(): void;
  35960. /**
  35961. * Unfreeze all materials
  35962. * A frozen material will not be updatable but should be faster to render
  35963. */
  35964. unfreezeMaterials(): void;
  35965. /**
  35966. * Releases all held ressources
  35967. */
  35968. dispose(): void;
  35969. /**
  35970. * Gets if the scene is already disposed
  35971. */
  35972. readonly isDisposed: boolean;
  35973. /**
  35974. * Call this function to reduce memory footprint of the scene.
  35975. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35976. */
  35977. clearCachedVertexData(): void;
  35978. /**
  35979. * This function will remove the local cached buffer data from texture.
  35980. * It will save memory but will prevent the texture from being rebuilt
  35981. */
  35982. cleanCachedTextureBuffer(): void;
  35983. /**
  35984. * Get the world extend vectors with an optional filter
  35985. *
  35986. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35987. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35988. */
  35989. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35990. min: Vector3;
  35991. max: Vector3;
  35992. };
  35993. /**
  35994. * Creates a ray that can be used to pick in the scene
  35995. * @param x defines the x coordinate of the origin (on-screen)
  35996. * @param y defines the y coordinate of the origin (on-screen)
  35997. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35998. * @param camera defines the camera to use for the picking
  35999. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36000. * @returns a Ray
  36001. */
  36002. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36003. /**
  36004. * Creates a ray that can be used to pick in the scene
  36005. * @param x defines the x coordinate of the origin (on-screen)
  36006. * @param y defines the y coordinate of the origin (on-screen)
  36007. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36008. * @param result defines the ray where to store the picking ray
  36009. * @param camera defines the camera to use for the picking
  36010. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36011. * @returns the current scene
  36012. */
  36013. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36014. /**
  36015. * Creates a ray that can be used to pick in the scene
  36016. * @param x defines the x coordinate of the origin (on-screen)
  36017. * @param y defines the y coordinate of the origin (on-screen)
  36018. * @param camera defines the camera to use for the picking
  36019. * @returns a Ray
  36020. */
  36021. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36022. /**
  36023. * Creates a ray that can be used to pick in the scene
  36024. * @param x defines the x coordinate of the origin (on-screen)
  36025. * @param y defines the y coordinate of the origin (on-screen)
  36026. * @param result defines the ray where to store the picking ray
  36027. * @param camera defines the camera to use for the picking
  36028. * @returns the current scene
  36029. */
  36030. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36031. private _internalPick;
  36032. private _internalMultiPick;
  36033. private _tempPickingRay;
  36034. /** Launch a ray to try to pick a mesh in the scene
  36035. * @param x position on screen
  36036. * @param y position on screen
  36037. * @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
  36038. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36039. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36040. * @returns a PickingInfo
  36041. */
  36042. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  36043. private _cachedRayForTransform;
  36044. /** Use the given ray to pick a mesh in the scene
  36045. * @param ray The ray to use to pick meshes
  36046. * @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
  36047. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36048. * @returns a PickingInfo
  36049. */
  36050. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36051. /**
  36052. * Launch a ray to try to pick a mesh in the scene
  36053. * @param x X position on screen
  36054. * @param y Y position on screen
  36055. * @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
  36056. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36057. * @returns an array of PickingInfo
  36058. */
  36059. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  36060. /**
  36061. * Launch a ray to try to pick a mesh in the scene
  36062. * @param ray Ray to use
  36063. * @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
  36064. * @returns an array of PickingInfo
  36065. */
  36066. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  36067. /**
  36068. * Force the value of meshUnderPointer
  36069. * @param mesh defines the mesh to use
  36070. */
  36071. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36072. /**
  36073. * Gets the mesh under the pointer
  36074. * @returns a Mesh or null if no mesh is under the pointer
  36075. */
  36076. getPointerOverMesh(): Nullable<AbstractMesh>;
  36077. /** @hidden */
  36078. _rebuildGeometries(): void;
  36079. /** @hidden */
  36080. _rebuildTextures(): void;
  36081. private _getByTags;
  36082. /**
  36083. * Get a list of meshes by tags
  36084. * @param tagsQuery defines the tags query to use
  36085. * @param forEach defines a predicate used to filter results
  36086. * @returns an array of Mesh
  36087. */
  36088. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36089. /**
  36090. * Get a list of cameras by tags
  36091. * @param tagsQuery defines the tags query to use
  36092. * @param forEach defines a predicate used to filter results
  36093. * @returns an array of Camera
  36094. */
  36095. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36096. /**
  36097. * Get a list of lights by tags
  36098. * @param tagsQuery defines the tags query to use
  36099. * @param forEach defines a predicate used to filter results
  36100. * @returns an array of Light
  36101. */
  36102. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36103. /**
  36104. * Get a list of materials by tags
  36105. * @param tagsQuery defines the tags query to use
  36106. * @param forEach defines a predicate used to filter results
  36107. * @returns an array of Material
  36108. */
  36109. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36110. /**
  36111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36112. * This allowed control for front to back rendering or reversly depending of the special needs.
  36113. *
  36114. * @param renderingGroupId The rendering group id corresponding to its index
  36115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36118. */
  36119. 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;
  36120. /**
  36121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36122. *
  36123. * @param renderingGroupId The rendering group id corresponding to its index
  36124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36125. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36126. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36127. */
  36128. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36129. /**
  36130. * Gets the current auto clear configuration for one rendering group of the rendering
  36131. * manager.
  36132. * @param index the rendering group index to get the information for
  36133. * @returns The auto clear setup for the requested rendering group
  36134. */
  36135. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36136. private _blockMaterialDirtyMechanism;
  36137. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36138. blockMaterialDirtyMechanism: boolean;
  36139. /**
  36140. * Will flag all materials as dirty to trigger new shader compilation
  36141. * @param flag defines the flag used to specify which material part must be marked as dirty
  36142. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36143. */
  36144. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36145. /** @hidden */
  36146. _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;
  36147. /** @hidden */
  36148. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36149. }
  36150. }
  36151. declare module "babylonjs/abstractScene" {
  36152. import { Scene } from "babylonjs/scene";
  36153. import { Nullable } from "babylonjs/types";
  36154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36155. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36156. import { Geometry } from "babylonjs/Meshes/geometry";
  36157. import { Skeleton } from "babylonjs/Bones/skeleton";
  36158. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36159. import { AssetContainer } from "babylonjs/assetContainer";
  36160. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36161. import { Animation } from "babylonjs/Animations/animation";
  36162. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36164. import { Material } from "babylonjs/Materials/material";
  36165. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36166. import { ActionManager } from "babylonjs/Actions/actionManager";
  36167. import { Camera } from "babylonjs/Cameras/camera";
  36168. import { Light } from "babylonjs/Lights/light";
  36169. import { Node } from "babylonjs/node";
  36170. /**
  36171. * Defines how the parser contract is defined.
  36172. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36173. */
  36174. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36175. /**
  36176. * Defines how the individual parser contract is defined.
  36177. * These parser can parse an individual asset
  36178. */
  36179. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36180. /**
  36181. * Base class of the scene acting as a container for the different elements composing a scene.
  36182. * This class is dynamically extended by the different components of the scene increasing
  36183. * flexibility and reducing coupling
  36184. */
  36185. export abstract class AbstractScene {
  36186. /**
  36187. * Stores the list of available parsers in the application.
  36188. */
  36189. private static _BabylonFileParsers;
  36190. /**
  36191. * Stores the list of available individual parsers in the application.
  36192. */
  36193. private static _IndividualBabylonFileParsers;
  36194. /**
  36195. * Adds a parser in the list of available ones
  36196. * @param name Defines the name of the parser
  36197. * @param parser Defines the parser to add
  36198. */
  36199. static AddParser(name: string, parser: BabylonFileParser): void;
  36200. /**
  36201. * Gets a general parser from the list of avaialble ones
  36202. * @param name Defines the name of the parser
  36203. * @returns the requested parser or null
  36204. */
  36205. static GetParser(name: string): Nullable<BabylonFileParser>;
  36206. /**
  36207. * Adds n individual parser in the list of available ones
  36208. * @param name Defines the name of the parser
  36209. * @param parser Defines the parser to add
  36210. */
  36211. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36212. /**
  36213. * Gets an individual parser from the list of avaialble ones
  36214. * @param name Defines the name of the parser
  36215. * @returns the requested parser or null
  36216. */
  36217. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36218. /**
  36219. * Parser json data and populate both a scene and its associated container object
  36220. * @param jsonData Defines the data to parse
  36221. * @param scene Defines the scene to parse the data for
  36222. * @param container Defines the container attached to the parsing sequence
  36223. * @param rootUrl Defines the root url of the data
  36224. */
  36225. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36226. /**
  36227. * Gets the list of root nodes (ie. nodes with no parent)
  36228. */
  36229. rootNodes: Node[];
  36230. /** All of the cameras added to this scene
  36231. * @see http://doc.babylonjs.com/babylon101/cameras
  36232. */
  36233. cameras: Camera[];
  36234. /**
  36235. * All of the lights added to this scene
  36236. * @see http://doc.babylonjs.com/babylon101/lights
  36237. */
  36238. lights: Light[];
  36239. /**
  36240. * All of the (abstract) meshes added to this scene
  36241. */
  36242. meshes: AbstractMesh[];
  36243. /**
  36244. * The list of skeletons added to the scene
  36245. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36246. */
  36247. skeletons: Skeleton[];
  36248. /**
  36249. * All of the particle systems added to this scene
  36250. * @see http://doc.babylonjs.com/babylon101/particles
  36251. */
  36252. particleSystems: IParticleSystem[];
  36253. /**
  36254. * Gets a list of Animations associated with the scene
  36255. */
  36256. animations: Animation[];
  36257. /**
  36258. * All of the animation groups added to this scene
  36259. * @see http://doc.babylonjs.com/how_to/group
  36260. */
  36261. animationGroups: AnimationGroup[];
  36262. /**
  36263. * All of the multi-materials added to this scene
  36264. * @see http://doc.babylonjs.com/how_to/multi_materials
  36265. */
  36266. multiMaterials: MultiMaterial[];
  36267. /**
  36268. * All of the materials added to this scene
  36269. * In the context of a Scene, it is not supposed to be modified manually.
  36270. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  36271. * Note also that the order of the Material wihin the array is not significant and might change.
  36272. * @see http://doc.babylonjs.com/babylon101/materials
  36273. */
  36274. materials: Material[];
  36275. /**
  36276. * The list of morph target managers added to the scene
  36277. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36278. */
  36279. morphTargetManagers: MorphTargetManager[];
  36280. /**
  36281. * The list of geometries used in the scene.
  36282. */
  36283. geometries: Geometry[];
  36284. /**
  36285. * All of the tranform nodes added to this scene
  36286. * In the context of a Scene, it is not supposed to be modified manually.
  36287. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36288. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36289. * @see http://doc.babylonjs.com/how_to/transformnode
  36290. */
  36291. transformNodes: TransformNode[];
  36292. /**
  36293. * ActionManagers available on the scene.
  36294. */
  36295. actionManagers: ActionManager[];
  36296. /**
  36297. * Textures to keep.
  36298. */
  36299. textures: BaseTexture[];
  36300. }
  36301. }
  36302. declare module "babylonjs/Audio/soundTrack" {
  36303. import { Sound } from "babylonjs/Audio/sound";
  36304. import { Analyser } from "babylonjs/Audio/analyser";
  36305. import { Scene } from "babylonjs/scene";
  36306. /**
  36307. * Options allowed during the creation of a sound track.
  36308. */
  36309. export interface ISoundTrackOptions {
  36310. /**
  36311. * The volume the sound track should take during creation
  36312. */
  36313. volume?: number;
  36314. /**
  36315. * Define if the sound track is the main sound track of the scene
  36316. */
  36317. mainTrack?: boolean;
  36318. }
  36319. /**
  36320. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36321. * It will be also used in a future release to apply effects on a specific track.
  36322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36323. */
  36324. export class SoundTrack {
  36325. /**
  36326. * The unique identifier of the sound track in the scene.
  36327. */
  36328. id: number;
  36329. /**
  36330. * The list of sounds included in the sound track.
  36331. */
  36332. soundCollection: Array<Sound>;
  36333. private _outputAudioNode;
  36334. private _scene;
  36335. private _isMainTrack;
  36336. private _connectedAnalyser;
  36337. private _options;
  36338. private _isInitialized;
  36339. /**
  36340. * Creates a new sound track.
  36341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36342. * @param scene Define the scene the sound track belongs to
  36343. * @param options
  36344. */
  36345. constructor(scene: Scene, options?: ISoundTrackOptions);
  36346. private _initializeSoundTrackAudioGraph;
  36347. /**
  36348. * Release the sound track and its associated resources
  36349. */
  36350. dispose(): void;
  36351. /**
  36352. * Adds a sound to this sound track
  36353. * @param sound define the cound to add
  36354. * @ignoreNaming
  36355. */
  36356. AddSound(sound: Sound): void;
  36357. /**
  36358. * Removes a sound to this sound track
  36359. * @param sound define the cound to remove
  36360. * @ignoreNaming
  36361. */
  36362. RemoveSound(sound: Sound): void;
  36363. /**
  36364. * Set a global volume for the full sound track.
  36365. * @param newVolume Define the new volume of the sound track
  36366. */
  36367. setVolume(newVolume: number): void;
  36368. /**
  36369. * Switch the panning model to HRTF:
  36370. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36372. */
  36373. switchPanningModelToHRTF(): void;
  36374. /**
  36375. * Switch the panning model to Equal Power:
  36376. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36378. */
  36379. switchPanningModelToEqualPower(): void;
  36380. /**
  36381. * Connect the sound track to an audio analyser allowing some amazing
  36382. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36384. * @param analyser The analyser to connect to the engine
  36385. */
  36386. connectToAnalyser(analyser: Analyser): void;
  36387. }
  36388. }
  36389. declare module "babylonjs/Audio/audioSceneComponent" {
  36390. import { Sound } from "babylonjs/Audio/sound";
  36391. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36392. import { Nullable } from "babylonjs/types";
  36393. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36394. import { Scene } from "babylonjs/scene";
  36395. import { AbstractScene } from "babylonjs/abstractScene";
  36396. module "babylonjs/abstractScene" {
  36397. interface AbstractScene {
  36398. /**
  36399. * The list of sounds used in the scene.
  36400. */
  36401. sounds: Nullable<Array<Sound>>;
  36402. }
  36403. }
  36404. module "babylonjs/scene" {
  36405. interface Scene {
  36406. /**
  36407. * @hidden
  36408. * Backing field
  36409. */
  36410. _mainSoundTrack: SoundTrack;
  36411. /**
  36412. * The main sound track played by the scene.
  36413. * It cotains your primary collection of sounds.
  36414. */
  36415. mainSoundTrack: SoundTrack;
  36416. /**
  36417. * The list of sound tracks added to the scene
  36418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36419. */
  36420. soundTracks: Nullable<Array<SoundTrack>>;
  36421. /**
  36422. * Gets a sound using a given name
  36423. * @param name defines the name to search for
  36424. * @return the found sound or null if not found at all.
  36425. */
  36426. getSoundByName(name: string): Nullable<Sound>;
  36427. /**
  36428. * Gets or sets if audio support is enabled
  36429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36430. */
  36431. audioEnabled: boolean;
  36432. /**
  36433. * Gets or sets if audio will be output to headphones
  36434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36435. */
  36436. headphone: boolean;
  36437. }
  36438. }
  36439. /**
  36440. * Defines the sound scene component responsible to manage any sounds
  36441. * in a given scene.
  36442. */
  36443. export class AudioSceneComponent implements ISceneSerializableComponent {
  36444. /**
  36445. * The component name helpfull to identify the component in the list of scene components.
  36446. */
  36447. readonly name: string;
  36448. /**
  36449. * The scene the component belongs to.
  36450. */
  36451. scene: Scene;
  36452. private _audioEnabled;
  36453. /**
  36454. * Gets whether audio is enabled or not.
  36455. * Please use related enable/disable method to switch state.
  36456. */
  36457. readonly audioEnabled: boolean;
  36458. private _headphone;
  36459. /**
  36460. * Gets whether audio is outputing to headphone or not.
  36461. * Please use the according Switch methods to change output.
  36462. */
  36463. readonly headphone: boolean;
  36464. /**
  36465. * Creates a new instance of the component for the given scene
  36466. * @param scene Defines the scene to register the component in
  36467. */
  36468. constructor(scene: Scene);
  36469. /**
  36470. * Registers the component in a given scene
  36471. */
  36472. register(): void;
  36473. /**
  36474. * Rebuilds the elements related to this component in case of
  36475. * context lost for instance.
  36476. */
  36477. rebuild(): void;
  36478. /**
  36479. * Serializes the component data to the specified json object
  36480. * @param serializationObject The object to serialize to
  36481. */
  36482. serialize(serializationObject: any): void;
  36483. /**
  36484. * Adds all the element from the container to the scene
  36485. * @param container the container holding the elements
  36486. */
  36487. addFromContainer(container: AbstractScene): void;
  36488. /**
  36489. * Removes all the elements in the container from the scene
  36490. * @param container contains the elements to remove
  36491. */
  36492. removeFromContainer(container: AbstractScene): void;
  36493. /**
  36494. * Disposes the component and the associated ressources.
  36495. */
  36496. dispose(): void;
  36497. /**
  36498. * Disables audio in the associated scene.
  36499. */
  36500. disableAudio(): void;
  36501. /**
  36502. * Enables audio in the associated scene.
  36503. */
  36504. enableAudio(): void;
  36505. /**
  36506. * Switch audio to headphone output.
  36507. */
  36508. switchAudioModeForHeadphones(): void;
  36509. /**
  36510. * Switch audio to normal speakers.
  36511. */
  36512. switchAudioModeForNormalSpeakers(): void;
  36513. private _afterRender;
  36514. }
  36515. }
  36516. declare module "babylonjs/Audio/sound" {
  36517. import { Observable } from "babylonjs/Misc/observable";
  36518. import { Vector3 } from "babylonjs/Maths/math";
  36519. import { Nullable } from "babylonjs/types";
  36520. import { Scene } from "babylonjs/scene";
  36521. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36522. /**
  36523. * Defines a sound that can be played in the application.
  36524. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36526. */
  36527. export class Sound {
  36528. /**
  36529. * The name of the sound in the scene.
  36530. */
  36531. name: string;
  36532. /**
  36533. * Does the sound autoplay once loaded.
  36534. */
  36535. autoplay: boolean;
  36536. /**
  36537. * Does the sound loop after it finishes playing once.
  36538. */
  36539. loop: boolean;
  36540. /**
  36541. * Does the sound use a custom attenuation curve to simulate the falloff
  36542. * happening when the source gets further away from the camera.
  36543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36544. */
  36545. useCustomAttenuation: boolean;
  36546. /**
  36547. * The sound track id this sound belongs to.
  36548. */
  36549. soundTrackId: number;
  36550. /**
  36551. * Is this sound currently played.
  36552. */
  36553. isPlaying: boolean;
  36554. /**
  36555. * Is this sound currently paused.
  36556. */
  36557. isPaused: boolean;
  36558. /**
  36559. * Does this sound enables spatial sound.
  36560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36561. */
  36562. spatialSound: boolean;
  36563. /**
  36564. * Define the reference distance the sound should be heard perfectly.
  36565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36566. */
  36567. refDistance: number;
  36568. /**
  36569. * Define the roll off factor of spatial sounds.
  36570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36571. */
  36572. rolloffFactor: number;
  36573. /**
  36574. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36576. */
  36577. maxDistance: number;
  36578. /**
  36579. * Define the distance attenuation model the sound will follow.
  36580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36581. */
  36582. distanceModel: string;
  36583. /**
  36584. * @hidden
  36585. * Back Compat
  36586. **/
  36587. onended: () => any;
  36588. /**
  36589. * Observable event when the current playing sound finishes.
  36590. */
  36591. onEndedObservable: Observable<Sound>;
  36592. private _panningModel;
  36593. private _playbackRate;
  36594. private _streaming;
  36595. private _startTime;
  36596. private _startOffset;
  36597. private _position;
  36598. /** @hidden */
  36599. _positionInEmitterSpace: boolean;
  36600. private _localDirection;
  36601. private _volume;
  36602. private _isReadyToPlay;
  36603. private _isDirectional;
  36604. private _readyToPlayCallback;
  36605. private _audioBuffer;
  36606. private _soundSource;
  36607. private _streamingSource;
  36608. private _soundPanner;
  36609. private _soundGain;
  36610. private _inputAudioNode;
  36611. private _outputAudioNode;
  36612. private _coneInnerAngle;
  36613. private _coneOuterAngle;
  36614. private _coneOuterGain;
  36615. private _scene;
  36616. private _connectedTransformNode;
  36617. private _customAttenuationFunction;
  36618. private _registerFunc;
  36619. private _isOutputConnected;
  36620. private _htmlAudioElement;
  36621. private _urlType;
  36622. /**
  36623. * Create a sound and attach it to a scene
  36624. * @param name Name of your sound
  36625. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36626. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36627. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36628. */
  36629. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  36630. /**
  36631. * Release the sound and its associated resources
  36632. */
  36633. dispose(): void;
  36634. /**
  36635. * Gets if the sounds is ready to be played or not.
  36636. * @returns true if ready, otherwise false
  36637. */
  36638. isReady(): boolean;
  36639. private _soundLoaded;
  36640. /**
  36641. * Sets the data of the sound from an audiobuffer
  36642. * @param audioBuffer The audioBuffer containing the data
  36643. */
  36644. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36645. /**
  36646. * Updates the current sounds options such as maxdistance, loop...
  36647. * @param options A JSON object containing values named as the object properties
  36648. */
  36649. updateOptions(options: any): void;
  36650. private _createSpatialParameters;
  36651. private _updateSpatialParameters;
  36652. /**
  36653. * Switch the panning model to HRTF:
  36654. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36656. */
  36657. switchPanningModelToHRTF(): void;
  36658. /**
  36659. * Switch the panning model to Equal Power:
  36660. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36662. */
  36663. switchPanningModelToEqualPower(): void;
  36664. private _switchPanningModel;
  36665. /**
  36666. * Connect this sound to a sound track audio node like gain...
  36667. * @param soundTrackAudioNode the sound track audio node to connect to
  36668. */
  36669. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36670. /**
  36671. * Transform this sound into a directional source
  36672. * @param coneInnerAngle Size of the inner cone in degree
  36673. * @param coneOuterAngle Size of the outer cone in degree
  36674. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36675. */
  36676. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36677. /**
  36678. * Gets or sets the inner angle for the directional cone.
  36679. */
  36680. /**
  36681. * Gets or sets the inner angle for the directional cone.
  36682. */
  36683. directionalConeInnerAngle: number;
  36684. /**
  36685. * Gets or sets the outer angle for the directional cone.
  36686. */
  36687. /**
  36688. * Gets or sets the outer angle for the directional cone.
  36689. */
  36690. directionalConeOuterAngle: number;
  36691. /**
  36692. * Sets the position of the emitter if spatial sound is enabled
  36693. * @param newPosition Defines the new posisiton
  36694. */
  36695. setPosition(newPosition: Vector3): void;
  36696. /**
  36697. * Sets the local direction of the emitter if spatial sound is enabled
  36698. * @param newLocalDirection Defines the new local direction
  36699. */
  36700. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36701. private _updateDirection;
  36702. /** @hidden */
  36703. updateDistanceFromListener(): void;
  36704. /**
  36705. * Sets a new custom attenuation function for the sound.
  36706. * @param callback Defines the function used for the attenuation
  36707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36708. */
  36709. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36710. /**
  36711. * Play the sound
  36712. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36713. * @param offset (optional) Start the sound setting it at a specific time
  36714. */
  36715. play(time?: number, offset?: number): void;
  36716. private _onended;
  36717. /**
  36718. * Stop the sound
  36719. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36720. */
  36721. stop(time?: number): void;
  36722. /**
  36723. * Put the sound in pause
  36724. */
  36725. pause(): void;
  36726. /**
  36727. * Sets a dedicated volume for this sounds
  36728. * @param newVolume Define the new volume of the sound
  36729. * @param time Define in how long the sound should be at this value
  36730. */
  36731. setVolume(newVolume: number, time?: number): void;
  36732. /**
  36733. * Set the sound play back rate
  36734. * @param newPlaybackRate Define the playback rate the sound should be played at
  36735. */
  36736. setPlaybackRate(newPlaybackRate: number): void;
  36737. /**
  36738. * Gets the volume of the sound.
  36739. * @returns the volume of the sound
  36740. */
  36741. getVolume(): number;
  36742. /**
  36743. * Attach the sound to a dedicated mesh
  36744. * @param transformNode The transform node to connect the sound with
  36745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36746. */
  36747. attachToMesh(transformNode: TransformNode): void;
  36748. /**
  36749. * Detach the sound from the previously attached mesh
  36750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36751. */
  36752. detachFromMesh(): void;
  36753. private _onRegisterAfterWorldMatrixUpdate;
  36754. /**
  36755. * Clone the current sound in the scene.
  36756. * @returns the new sound clone
  36757. */
  36758. clone(): Nullable<Sound>;
  36759. /**
  36760. * Gets the current underlying audio buffer containing the data
  36761. * @returns the audio buffer
  36762. */
  36763. getAudioBuffer(): Nullable<AudioBuffer>;
  36764. /**
  36765. * Serializes the Sound in a JSON representation
  36766. * @returns the JSON representation of the sound
  36767. */
  36768. serialize(): any;
  36769. /**
  36770. * Parse a JSON representation of a sound to innstantiate in a given scene
  36771. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36772. * @param scene Define the scene the new parsed sound should be created in
  36773. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36774. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36775. * @returns the newly parsed sound
  36776. */
  36777. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36778. }
  36779. }
  36780. declare module "babylonjs/Actions/directAudioActions" {
  36781. import { Action } from "babylonjs/Actions/action";
  36782. import { Condition } from "babylonjs/Actions/condition";
  36783. import { Sound } from "babylonjs/Audio/sound";
  36784. /**
  36785. * This defines an action helpful to play a defined sound on a triggered action.
  36786. */
  36787. export class PlaySoundAction extends Action {
  36788. private _sound;
  36789. /**
  36790. * Instantiate the action
  36791. * @param triggerOptions defines the trigger options
  36792. * @param sound defines the sound to play
  36793. * @param condition defines the trigger related conditions
  36794. */
  36795. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36796. /** @hidden */
  36797. _prepare(): void;
  36798. /**
  36799. * Execute the action and play the sound.
  36800. */
  36801. execute(): void;
  36802. /**
  36803. * Serializes the actions and its related information.
  36804. * @param parent defines the object to serialize in
  36805. * @returns the serialized object
  36806. */
  36807. serialize(parent: any): any;
  36808. }
  36809. /**
  36810. * This defines an action helpful to stop a defined sound on a triggered action.
  36811. */
  36812. export class StopSoundAction extends Action {
  36813. private _sound;
  36814. /**
  36815. * Instantiate the action
  36816. * @param triggerOptions defines the trigger options
  36817. * @param sound defines the sound to stop
  36818. * @param condition defines the trigger related conditions
  36819. */
  36820. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36821. /** @hidden */
  36822. _prepare(): void;
  36823. /**
  36824. * Execute the action and stop the sound.
  36825. */
  36826. execute(): void;
  36827. /**
  36828. * Serializes the actions and its related information.
  36829. * @param parent defines the object to serialize in
  36830. * @returns the serialized object
  36831. */
  36832. serialize(parent: any): any;
  36833. }
  36834. }
  36835. declare module "babylonjs/Actions/interpolateValueAction" {
  36836. import { Action } from "babylonjs/Actions/action";
  36837. import { Condition } from "babylonjs/Actions/condition";
  36838. import { Observable } from "babylonjs/Misc/observable";
  36839. /**
  36840. * This defines an action responsible to change the value of a property
  36841. * by interpolating between its current value and the newly set one once triggered.
  36842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36843. */
  36844. export class InterpolateValueAction extends Action {
  36845. /**
  36846. * Defines the path of the property where the value should be interpolated
  36847. */
  36848. propertyPath: string;
  36849. /**
  36850. * Defines the target value at the end of the interpolation.
  36851. */
  36852. value: any;
  36853. /**
  36854. * Defines the time it will take for the property to interpolate to the value.
  36855. */
  36856. duration: number;
  36857. /**
  36858. * Defines if the other scene animations should be stopped when the action has been triggered
  36859. */
  36860. stopOtherAnimations?: boolean;
  36861. /**
  36862. * Defines a callback raised once the interpolation animation has been done.
  36863. */
  36864. onInterpolationDone?: () => void;
  36865. /**
  36866. * Observable triggered once the interpolation animation has been done.
  36867. */
  36868. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36869. private _target;
  36870. private _effectiveTarget;
  36871. private _property;
  36872. /**
  36873. * Instantiate the action
  36874. * @param triggerOptions defines the trigger options
  36875. * @param target defines the object containing the value to interpolate
  36876. * @param propertyPath defines the path to the property in the target object
  36877. * @param value defines the target value at the end of the interpolation
  36878. * @param duration deines the time it will take for the property to interpolate to the value.
  36879. * @param condition defines the trigger related conditions
  36880. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36881. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36882. */
  36883. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36884. /** @hidden */
  36885. _prepare(): void;
  36886. /**
  36887. * Execute the action starts the value interpolation.
  36888. */
  36889. execute(): void;
  36890. /**
  36891. * Serializes the actions and its related information.
  36892. * @param parent defines the object to serialize in
  36893. * @returns the serialized object
  36894. */
  36895. serialize(parent: any): any;
  36896. }
  36897. }
  36898. declare module "babylonjs/Actions/index" {
  36899. export * from "babylonjs/Actions/action";
  36900. export * from "babylonjs/Actions/actionManager";
  36901. export * from "babylonjs/Actions/condition";
  36902. export * from "babylonjs/Actions/directActions";
  36903. export * from "babylonjs/Actions/directAudioActions";
  36904. export * from "babylonjs/Actions/interpolateValueAction";
  36905. }
  36906. declare module "babylonjs/Animations/index" {
  36907. export * from "babylonjs/Animations/animatable";
  36908. export * from "babylonjs/Animations/animation";
  36909. export * from "babylonjs/Animations/animationGroup";
  36910. export * from "babylonjs/Animations/animationPropertiesOverride";
  36911. export * from "babylonjs/Animations/easing";
  36912. export * from "babylonjs/Animations/runtimeAnimation";
  36913. }
  36914. declare module "babylonjs/Audio/weightedsound" {
  36915. import { Sound } from "babylonjs/Audio/sound";
  36916. /**
  36917. * Wraps one or more Sound objects and selects one with random weight for playback.
  36918. */
  36919. export class WeightedSound {
  36920. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36921. loop: boolean;
  36922. private _coneInnerAngle;
  36923. private _coneOuterAngle;
  36924. private _volume;
  36925. /** A Sound is currently playing. */
  36926. isPlaying: boolean;
  36927. /** A Sound is currently paused. */
  36928. isPaused: boolean;
  36929. private _sounds;
  36930. private _weights;
  36931. private _currentIndex?;
  36932. /**
  36933. * Creates a new WeightedSound from the list of sounds given.
  36934. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36935. * @param sounds Array of Sounds that will be selected from.
  36936. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36937. */
  36938. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36939. /**
  36940. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36941. */
  36942. /**
  36943. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36944. */
  36945. directionalConeInnerAngle: number;
  36946. /**
  36947. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36948. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36949. */
  36950. /**
  36951. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36952. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36953. */
  36954. directionalConeOuterAngle: number;
  36955. /**
  36956. * Playback volume.
  36957. */
  36958. /**
  36959. * Playback volume.
  36960. */
  36961. volume: number;
  36962. private _onended;
  36963. /**
  36964. * Suspend playback
  36965. */
  36966. pause(): void;
  36967. /**
  36968. * Stop playback
  36969. */
  36970. stop(): void;
  36971. /**
  36972. * Start playback.
  36973. * @param startOffset Position the clip head at a specific time in seconds.
  36974. */
  36975. play(startOffset?: number): void;
  36976. }
  36977. }
  36978. declare module "babylonjs/Audio/index" {
  36979. export * from "babylonjs/Audio/analyser";
  36980. export * from "babylonjs/Audio/audioEngine";
  36981. export * from "babylonjs/Audio/audioSceneComponent";
  36982. export * from "babylonjs/Audio/sound";
  36983. export * from "babylonjs/Audio/soundTrack";
  36984. export * from "babylonjs/Audio/weightedsound";
  36985. }
  36986. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36987. import { Behavior } from "babylonjs/Behaviors/behavior";
  36988. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36989. import { BackEase } from "babylonjs/Animations/easing";
  36990. /**
  36991. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36992. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36993. */
  36994. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36995. /**
  36996. * Gets the name of the behavior.
  36997. */
  36998. readonly name: string;
  36999. /**
  37000. * The easing function used by animations
  37001. */
  37002. static EasingFunction: BackEase;
  37003. /**
  37004. * The easing mode used by animations
  37005. */
  37006. static EasingMode: number;
  37007. /**
  37008. * The duration of the animation, in milliseconds
  37009. */
  37010. transitionDuration: number;
  37011. /**
  37012. * Length of the distance animated by the transition when lower radius is reached
  37013. */
  37014. lowerRadiusTransitionRange: number;
  37015. /**
  37016. * Length of the distance animated by the transition when upper radius is reached
  37017. */
  37018. upperRadiusTransitionRange: number;
  37019. private _autoTransitionRange;
  37020. /**
  37021. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37022. */
  37023. /**
  37024. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37025. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37026. */
  37027. autoTransitionRange: boolean;
  37028. private _attachedCamera;
  37029. private _onAfterCheckInputsObserver;
  37030. private _onMeshTargetChangedObserver;
  37031. /**
  37032. * Initializes the behavior.
  37033. */
  37034. init(): void;
  37035. /**
  37036. * Attaches the behavior to its arc rotate camera.
  37037. * @param camera Defines the camera to attach the behavior to
  37038. */
  37039. attach(camera: ArcRotateCamera): void;
  37040. /**
  37041. * Detaches the behavior from its current arc rotate camera.
  37042. */
  37043. detach(): void;
  37044. private _radiusIsAnimating;
  37045. private _radiusBounceTransition;
  37046. private _animatables;
  37047. private _cachedWheelPrecision;
  37048. /**
  37049. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37050. * @param radiusLimit The limit to check against.
  37051. * @return Bool to indicate if at limit.
  37052. */
  37053. private _isRadiusAtLimit;
  37054. /**
  37055. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37056. * @param radiusDelta The delta by which to animate to. Can be negative.
  37057. */
  37058. private _applyBoundRadiusAnimation;
  37059. /**
  37060. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37061. */
  37062. protected _clearAnimationLocks(): void;
  37063. /**
  37064. * Stops and removes all animations that have been applied to the camera
  37065. */
  37066. stopAllAnimations(): void;
  37067. }
  37068. }
  37069. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37070. import { Behavior } from "babylonjs/Behaviors/behavior";
  37071. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37072. import { ExponentialEase } from "babylonjs/Animations/easing";
  37073. import { Nullable } from "babylonjs/types";
  37074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37075. import { Vector3 } from "babylonjs/Maths/math";
  37076. /**
  37077. * 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.
  37078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37079. */
  37080. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37081. /**
  37082. * Gets the name of the behavior.
  37083. */
  37084. readonly name: string;
  37085. private _mode;
  37086. private _radiusScale;
  37087. private _positionScale;
  37088. private _defaultElevation;
  37089. private _elevationReturnTime;
  37090. private _elevationReturnWaitTime;
  37091. private _zoomStopsAnimation;
  37092. private _framingTime;
  37093. /**
  37094. * The easing function used by animations
  37095. */
  37096. static EasingFunction: ExponentialEase;
  37097. /**
  37098. * The easing mode used by animations
  37099. */
  37100. static EasingMode: number;
  37101. /**
  37102. * Sets the current mode used by the behavior
  37103. */
  37104. /**
  37105. * Gets current mode used by the behavior.
  37106. */
  37107. mode: number;
  37108. /**
  37109. * Sets the scale applied to the radius (1 by default)
  37110. */
  37111. /**
  37112. * Gets the scale applied to the radius
  37113. */
  37114. radiusScale: number;
  37115. /**
  37116. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37117. */
  37118. /**
  37119. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37120. */
  37121. positionScale: number;
  37122. /**
  37123. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37124. * behaviour is triggered, in radians.
  37125. */
  37126. /**
  37127. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37128. * behaviour is triggered, in radians.
  37129. */
  37130. defaultElevation: number;
  37131. /**
  37132. * Sets the time (in milliseconds) taken to return to the default beta position.
  37133. * Negative value indicates camera should not return to default.
  37134. */
  37135. /**
  37136. * Gets the time (in milliseconds) taken to return to the default beta position.
  37137. * Negative value indicates camera should not return to default.
  37138. */
  37139. elevationReturnTime: number;
  37140. /**
  37141. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37142. */
  37143. /**
  37144. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37145. */
  37146. elevationReturnWaitTime: number;
  37147. /**
  37148. * Sets the flag that indicates if user zooming should stop animation.
  37149. */
  37150. /**
  37151. * Gets the flag that indicates if user zooming should stop animation.
  37152. */
  37153. zoomStopsAnimation: boolean;
  37154. /**
  37155. * Sets the transition time when framing the mesh, in milliseconds
  37156. */
  37157. /**
  37158. * Gets the transition time when framing the mesh, in milliseconds
  37159. */
  37160. framingTime: number;
  37161. /**
  37162. * Define if the behavior should automatically change the configured
  37163. * camera limits and sensibilities.
  37164. */
  37165. autoCorrectCameraLimitsAndSensibility: boolean;
  37166. private _onPrePointerObservableObserver;
  37167. private _onAfterCheckInputsObserver;
  37168. private _onMeshTargetChangedObserver;
  37169. private _attachedCamera;
  37170. private _isPointerDown;
  37171. private _lastInteractionTime;
  37172. /**
  37173. * Initializes the behavior.
  37174. */
  37175. init(): void;
  37176. /**
  37177. * Attaches the behavior to its arc rotate camera.
  37178. * @param camera Defines the camera to attach the behavior to
  37179. */
  37180. attach(camera: ArcRotateCamera): void;
  37181. /**
  37182. * Detaches the behavior from its current arc rotate camera.
  37183. */
  37184. detach(): void;
  37185. private _animatables;
  37186. private _betaIsAnimating;
  37187. private _betaTransition;
  37188. private _radiusTransition;
  37189. private _vectorTransition;
  37190. /**
  37191. * Targets the given mesh and updates zoom level accordingly.
  37192. * @param mesh The mesh to target.
  37193. * @param radius Optional. If a cached radius position already exists, overrides default.
  37194. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37195. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37196. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37197. */
  37198. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37199. /**
  37200. * Targets the given mesh with its children and updates zoom level accordingly.
  37201. * @param mesh The mesh to target.
  37202. * @param radius Optional. If a cached radius position already exists, overrides default.
  37203. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37204. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37205. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37206. */
  37207. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37208. /**
  37209. * Targets the given meshes with their children and updates zoom level accordingly.
  37210. * @param meshes The mesh to target.
  37211. * @param radius Optional. If a cached radius position already exists, overrides default.
  37212. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37213. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37214. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37215. */
  37216. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37217. /**
  37218. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37219. * @param minimumWorld Determines the smaller position of the bounding box extend
  37220. * @param maximumWorld Determines the bigger position of the bounding box extend
  37221. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37222. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37223. */
  37224. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37225. /**
  37226. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37227. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37228. * frustum width.
  37229. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37230. * to fully enclose the mesh in the viewing frustum.
  37231. */
  37232. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37233. /**
  37234. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37235. * is automatically returned to its default position (expected to be above ground plane).
  37236. */
  37237. private _maintainCameraAboveGround;
  37238. /**
  37239. * Returns the frustum slope based on the canvas ratio and camera FOV
  37240. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37241. */
  37242. private _getFrustumSlope;
  37243. /**
  37244. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37245. */
  37246. private _clearAnimationLocks;
  37247. /**
  37248. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37249. */
  37250. private _applyUserInteraction;
  37251. /**
  37252. * Stops and removes all animations that have been applied to the camera
  37253. */
  37254. stopAllAnimations(): void;
  37255. /**
  37256. * Gets a value indicating if the user is moving the camera
  37257. */
  37258. readonly isUserIsMoving: boolean;
  37259. /**
  37260. * The camera can move all the way towards the mesh.
  37261. */
  37262. static IgnoreBoundsSizeMode: number;
  37263. /**
  37264. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37265. */
  37266. static FitFrustumSidesMode: number;
  37267. }
  37268. }
  37269. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37270. import { Nullable } from "babylonjs/types";
  37271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37273. /**
  37274. * Manage the pointers inputs to control an arc rotate camera.
  37275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37276. */
  37277. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  37278. /**
  37279. * Defines the camera the input is attached to.
  37280. */
  37281. camera: ArcRotateCamera;
  37282. /**
  37283. * Defines the buttons associated with the input to handle camera move.
  37284. */
  37285. buttons: number[];
  37286. /**
  37287. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37288. */
  37289. angularSensibilityX: number;
  37290. /**
  37291. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37292. */
  37293. angularSensibilityY: number;
  37294. /**
  37295. * Defines the pointer pinch precision or how fast is the camera zooming.
  37296. */
  37297. pinchPrecision: number;
  37298. /**
  37299. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  37300. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37301. */
  37302. pinchDeltaPercentage: number;
  37303. /**
  37304. * Defines the pointer panning sensibility or how fast is the camera moving.
  37305. */
  37306. panningSensibility: number;
  37307. /**
  37308. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37309. */
  37310. multiTouchPanning: boolean;
  37311. /**
  37312. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  37313. */
  37314. multiTouchPanAndZoom: boolean;
  37315. /**
  37316. * Revers pinch action direction.
  37317. */
  37318. pinchInwards: boolean;
  37319. private _isPanClick;
  37320. private _pointerInput;
  37321. private _observer;
  37322. private _onMouseMove;
  37323. private _onGestureStart;
  37324. private _onGesture;
  37325. private _MSGestureHandler;
  37326. private _onLostFocus;
  37327. private _onContextMenu;
  37328. /**
  37329. * Attach the input controls to a specific dom element to get the input from.
  37330. * @param element Defines the element the controls should be listened from
  37331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37332. */
  37333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37334. /**
  37335. * Detach the current controls from the specified dom element.
  37336. * @param element Defines the element to stop listening the inputs from
  37337. */
  37338. detachControl(element: Nullable<HTMLElement>): void;
  37339. /**
  37340. * Gets the class name of the current intput.
  37341. * @returns the class name
  37342. */
  37343. getClassName(): string;
  37344. /**
  37345. * Get the friendly name associated with the input class.
  37346. * @returns the input friendly name
  37347. */
  37348. getSimpleName(): string;
  37349. }
  37350. }
  37351. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37352. import { Nullable } from "babylonjs/types";
  37353. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37354. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37355. /**
  37356. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37358. */
  37359. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37360. /**
  37361. * Defines the camera the input is attached to.
  37362. */
  37363. camera: ArcRotateCamera;
  37364. /**
  37365. * Defines the list of key codes associated with the up action (increase alpha)
  37366. */
  37367. keysUp: number[];
  37368. /**
  37369. * Defines the list of key codes associated with the down action (decrease alpha)
  37370. */
  37371. keysDown: number[];
  37372. /**
  37373. * Defines the list of key codes associated with the left action (increase beta)
  37374. */
  37375. keysLeft: number[];
  37376. /**
  37377. * Defines the list of key codes associated with the right action (decrease beta)
  37378. */
  37379. keysRight: number[];
  37380. /**
  37381. * Defines the list of key codes associated with the reset action.
  37382. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37383. */
  37384. keysReset: number[];
  37385. /**
  37386. * Defines the panning sensibility of the inputs.
  37387. * (How fast is the camera paning)
  37388. */
  37389. panningSensibility: number;
  37390. /**
  37391. * Defines the zooming sensibility of the inputs.
  37392. * (How fast is the camera zooming)
  37393. */
  37394. zoomingSensibility: number;
  37395. /**
  37396. * Defines wether maintaining the alt key down switch the movement mode from
  37397. * orientation to zoom.
  37398. */
  37399. useAltToZoom: boolean;
  37400. /**
  37401. * Rotation speed of the camera
  37402. */
  37403. angularSpeed: number;
  37404. private _keys;
  37405. private _ctrlPressed;
  37406. private _altPressed;
  37407. private _onCanvasBlurObserver;
  37408. private _onKeyboardObserver;
  37409. private _engine;
  37410. private _scene;
  37411. /**
  37412. * Attach the input controls to a specific dom element to get the input from.
  37413. * @param element Defines the element the controls should be listened from
  37414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37415. */
  37416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37417. /**
  37418. * Detach the current controls from the specified dom element.
  37419. * @param element Defines the element to stop listening the inputs from
  37420. */
  37421. detachControl(element: Nullable<HTMLElement>): void;
  37422. /**
  37423. * Update the current camera state depending on the inputs that have been used this frame.
  37424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37425. */
  37426. checkInputs(): void;
  37427. /**
  37428. * Gets the class name of the current intput.
  37429. * @returns the class name
  37430. */
  37431. getClassName(): string;
  37432. /**
  37433. * Get the friendly name associated with the input class.
  37434. * @returns the input friendly name
  37435. */
  37436. getSimpleName(): string;
  37437. }
  37438. }
  37439. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37440. import { Nullable } from "babylonjs/types";
  37441. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37442. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37443. /**
  37444. * Manage the mouse wheel inputs to control an arc rotate camera.
  37445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37446. */
  37447. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37448. /**
  37449. * Defines the camera the input is attached to.
  37450. */
  37451. camera: ArcRotateCamera;
  37452. /**
  37453. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37454. */
  37455. wheelPrecision: number;
  37456. /**
  37457. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37458. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37459. */
  37460. wheelDeltaPercentage: number;
  37461. private _wheel;
  37462. private _observer;
  37463. /**
  37464. * Attach the input controls to a specific dom element to get the input from.
  37465. * @param element Defines the element the controls should be listened from
  37466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37467. */
  37468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37469. /**
  37470. * Detach the current controls from the specified dom element.
  37471. * @param element Defines the element to stop listening the inputs from
  37472. */
  37473. detachControl(element: Nullable<HTMLElement>): void;
  37474. /**
  37475. * Gets the class name of the current intput.
  37476. * @returns the class name
  37477. */
  37478. getClassName(): string;
  37479. /**
  37480. * Get the friendly name associated with the input class.
  37481. * @returns the input friendly name
  37482. */
  37483. getSimpleName(): string;
  37484. }
  37485. }
  37486. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37487. import { Nullable } from "babylonjs/types";
  37488. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37489. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37490. /**
  37491. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37493. */
  37494. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37495. /**
  37496. * Defines the camera the input is attached to.
  37497. */
  37498. camera: ArcRotateCamera;
  37499. /**
  37500. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37501. */
  37502. alphaCorrection: number;
  37503. /**
  37504. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37505. */
  37506. gammaCorrection: number;
  37507. private _alpha;
  37508. private _gamma;
  37509. private _dirty;
  37510. private _deviceOrientationHandler;
  37511. /**
  37512. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37513. */
  37514. constructor();
  37515. /**
  37516. * Attach the input controls to a specific dom element to get the input from.
  37517. * @param element Defines the element the controls should be listened from
  37518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37519. */
  37520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37521. /** @hidden */
  37522. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37523. /**
  37524. * Update the current camera state depending on the inputs that have been used this frame.
  37525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37526. */
  37527. checkInputs(): void;
  37528. /**
  37529. * Detach the current controls from the specified dom element.
  37530. * @param element Defines the element to stop listening the inputs from
  37531. */
  37532. detachControl(element: Nullable<HTMLElement>): void;
  37533. /**
  37534. * Gets the class name of the current intput.
  37535. * @returns the class name
  37536. */
  37537. getClassName(): string;
  37538. /**
  37539. * Get the friendly name associated with the input class.
  37540. * @returns the input friendly name
  37541. */
  37542. getSimpleName(): string;
  37543. }
  37544. }
  37545. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37546. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37547. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37548. /**
  37549. * Default Inputs manager for the ArcRotateCamera.
  37550. * It groups all the default supported inputs for ease of use.
  37551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37552. */
  37553. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37554. /**
  37555. * Instantiates a new ArcRotateCameraInputsManager.
  37556. * @param camera Defines the camera the inputs belong to
  37557. */
  37558. constructor(camera: ArcRotateCamera);
  37559. /**
  37560. * Add mouse wheel input support to the input manager.
  37561. * @returns the current input manager
  37562. */
  37563. addMouseWheel(): ArcRotateCameraInputsManager;
  37564. /**
  37565. * Add pointers input support to the input manager.
  37566. * @returns the current input manager
  37567. */
  37568. addPointers(): ArcRotateCameraInputsManager;
  37569. /**
  37570. * Add keyboard input support to the input manager.
  37571. * @returns the current input manager
  37572. */
  37573. addKeyboard(): ArcRotateCameraInputsManager;
  37574. /**
  37575. * Add orientation input support to the input manager.
  37576. * @returns the current input manager
  37577. */
  37578. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37579. }
  37580. }
  37581. declare module "babylonjs/Cameras/arcRotateCamera" {
  37582. import { Observable } from "babylonjs/Misc/observable";
  37583. import { Nullable } from "babylonjs/types";
  37584. import { Scene } from "babylonjs/scene";
  37585. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  37586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37587. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37588. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37589. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37590. import { Collider } from "babylonjs/Collisions/collider";
  37591. import { Camera } from "babylonjs/Cameras/camera";
  37592. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37593. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37594. /**
  37595. * This represents an orbital type of camera.
  37596. *
  37597. * 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.
  37598. * 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.
  37599. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37600. */
  37601. export class ArcRotateCamera extends TargetCamera {
  37602. /**
  37603. * Defines the rotation angle of the camera along the longitudinal axis.
  37604. */
  37605. alpha: number;
  37606. /**
  37607. * Defines the rotation angle of the camera along the latitudinal axis.
  37608. */
  37609. beta: number;
  37610. /**
  37611. * Defines the radius of the camera from it s target point.
  37612. */
  37613. radius: number;
  37614. protected _target: Vector3;
  37615. protected _targetHost: Nullable<AbstractMesh>;
  37616. /**
  37617. * Defines the target point of the camera.
  37618. * The camera looks towards it form the radius distance.
  37619. */
  37620. target: Vector3;
  37621. /**
  37622. * Current inertia value on the longitudinal axis.
  37623. * The bigger this number the longer it will take for the camera to stop.
  37624. */
  37625. inertialAlphaOffset: number;
  37626. /**
  37627. * Current inertia value on the latitudinal axis.
  37628. * The bigger this number the longer it will take for the camera to stop.
  37629. */
  37630. inertialBetaOffset: number;
  37631. /**
  37632. * Current inertia value on the radius axis.
  37633. * The bigger this number the longer it will take for the camera to stop.
  37634. */
  37635. inertialRadiusOffset: number;
  37636. /**
  37637. * Minimum allowed angle on the longitudinal axis.
  37638. * This can help limiting how the Camera is able to move in the scene.
  37639. */
  37640. lowerAlphaLimit: Nullable<number>;
  37641. /**
  37642. * Maximum allowed angle on the longitudinal axis.
  37643. * This can help limiting how the Camera is able to move in the scene.
  37644. */
  37645. upperAlphaLimit: Nullable<number>;
  37646. /**
  37647. * Minimum allowed angle on the latitudinal axis.
  37648. * This can help limiting how the Camera is able to move in the scene.
  37649. */
  37650. lowerBetaLimit: number;
  37651. /**
  37652. * Maximum allowed angle on the latitudinal axis.
  37653. * This can help limiting how the Camera is able to move in the scene.
  37654. */
  37655. upperBetaLimit: number;
  37656. /**
  37657. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37658. * This can help limiting how the Camera is able to move in the scene.
  37659. */
  37660. lowerRadiusLimit: Nullable<number>;
  37661. /**
  37662. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37663. * This can help limiting how the Camera is able to move in the scene.
  37664. */
  37665. upperRadiusLimit: Nullable<number>;
  37666. /**
  37667. * Defines the current inertia value used during panning of the camera along the X axis.
  37668. */
  37669. inertialPanningX: number;
  37670. /**
  37671. * Defines the current inertia value used during panning of the camera along the Y axis.
  37672. */
  37673. inertialPanningY: number;
  37674. /**
  37675. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37676. * Basically if your fingers moves away from more than this distance you will be considered
  37677. * in pinch mode.
  37678. */
  37679. pinchToPanMaxDistance: number;
  37680. /**
  37681. * Defines the maximum distance the camera can pan.
  37682. * This could help keeping the cammera always in your scene.
  37683. */
  37684. panningDistanceLimit: Nullable<number>;
  37685. /**
  37686. * Defines the target of the camera before paning.
  37687. */
  37688. panningOriginTarget: Vector3;
  37689. /**
  37690. * Defines the value of the inertia used during panning.
  37691. * 0 would mean stop inertia and one would mean no decelleration at all.
  37692. */
  37693. panningInertia: number;
  37694. /**
  37695. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37696. */
  37697. angularSensibilityX: number;
  37698. /**
  37699. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37700. */
  37701. angularSensibilityY: number;
  37702. /**
  37703. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37704. */
  37705. pinchPrecision: number;
  37706. /**
  37707. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37708. * It will be used instead of pinchDeltaPrecision if different from 0.
  37709. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37710. */
  37711. pinchDeltaPercentage: number;
  37712. /**
  37713. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37714. */
  37715. panningSensibility: number;
  37716. /**
  37717. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37718. */
  37719. keysUp: number[];
  37720. /**
  37721. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37722. */
  37723. keysDown: number[];
  37724. /**
  37725. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37726. */
  37727. keysLeft: number[];
  37728. /**
  37729. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37730. */
  37731. keysRight: number[];
  37732. /**
  37733. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37734. */
  37735. wheelPrecision: number;
  37736. /**
  37737. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37738. * It will be used instead of pinchDeltaPrecision if different from 0.
  37739. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37740. */
  37741. wheelDeltaPercentage: number;
  37742. /**
  37743. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37744. */
  37745. zoomOnFactor: number;
  37746. /**
  37747. * Defines a screen offset for the camera position.
  37748. */
  37749. targetScreenOffset: Vector2;
  37750. /**
  37751. * Allows the camera to be completely reversed.
  37752. * If false the camera can not arrive upside down.
  37753. */
  37754. allowUpsideDown: boolean;
  37755. /**
  37756. * Define if double tap/click is used to restore the previously saved state of the camera.
  37757. */
  37758. useInputToRestoreState: boolean;
  37759. /** @hidden */
  37760. _viewMatrix: Matrix;
  37761. /** @hidden */
  37762. _useCtrlForPanning: boolean;
  37763. /** @hidden */
  37764. _panningMouseButton: number;
  37765. /**
  37766. * Defines the inpute associated to the camera.
  37767. */
  37768. inputs: ArcRotateCameraInputsManager;
  37769. /** @hidden */
  37770. _reset: () => void;
  37771. /**
  37772. * Defines the allowed panning axis.
  37773. */
  37774. panningAxis: Vector3;
  37775. protected _localDirection: Vector3;
  37776. protected _transformedDirection: Vector3;
  37777. private _bouncingBehavior;
  37778. /**
  37779. * Gets the bouncing behavior of the camera if it has been enabled.
  37780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37781. */
  37782. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37783. /**
  37784. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37786. */
  37787. useBouncingBehavior: boolean;
  37788. private _framingBehavior;
  37789. /**
  37790. * Gets the framing behavior of the camera if it has been enabled.
  37791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37792. */
  37793. readonly framingBehavior: Nullable<FramingBehavior>;
  37794. /**
  37795. * Defines if the framing behavior of the camera is enabled on the camera.
  37796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37797. */
  37798. useFramingBehavior: boolean;
  37799. private _autoRotationBehavior;
  37800. /**
  37801. * Gets the auto rotation behavior of the camera if it has been enabled.
  37802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37803. */
  37804. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37805. /**
  37806. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37808. */
  37809. useAutoRotationBehavior: boolean;
  37810. /**
  37811. * Observable triggered when the mesh target has been changed on the camera.
  37812. */
  37813. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37814. /**
  37815. * Event raised when the camera is colliding with a mesh.
  37816. */
  37817. onCollide: (collidedMesh: AbstractMesh) => void;
  37818. /**
  37819. * Defines whether the camera should check collision with the objects oh the scene.
  37820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37821. */
  37822. checkCollisions: boolean;
  37823. /**
  37824. * Defines the collision radius of the camera.
  37825. * This simulates a sphere around the camera.
  37826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37827. */
  37828. collisionRadius: Vector3;
  37829. protected _collider: Collider;
  37830. protected _previousPosition: Vector3;
  37831. protected _collisionVelocity: Vector3;
  37832. protected _newPosition: Vector3;
  37833. protected _previousAlpha: number;
  37834. protected _previousBeta: number;
  37835. protected _previousRadius: number;
  37836. protected _collisionTriggered: boolean;
  37837. protected _targetBoundingCenter: Nullable<Vector3>;
  37838. private _computationVector;
  37839. /**
  37840. * Instantiates a new ArcRotateCamera in a given scene
  37841. * @param name Defines the name of the camera
  37842. * @param alpha Defines the camera rotation along the logitudinal axis
  37843. * @param beta Defines the camera rotation along the latitudinal axis
  37844. * @param radius Defines the camera distance from its target
  37845. * @param target Defines the camera target
  37846. * @param scene Defines the scene the camera belongs to
  37847. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37848. */
  37849. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37850. /** @hidden */
  37851. _initCache(): void;
  37852. /** @hidden */
  37853. _updateCache(ignoreParentClass?: boolean): void;
  37854. protected _getTargetPosition(): Vector3;
  37855. private _storedAlpha;
  37856. private _storedBeta;
  37857. private _storedRadius;
  37858. private _storedTarget;
  37859. /**
  37860. * Stores the current state of the camera (alpha, beta, radius and target)
  37861. * @returns the camera itself
  37862. */
  37863. storeState(): Camera;
  37864. /**
  37865. * @hidden
  37866. * Restored camera state. You must call storeState() first
  37867. */
  37868. _restoreStateValues(): boolean;
  37869. /** @hidden */
  37870. _isSynchronizedViewMatrix(): boolean;
  37871. /**
  37872. * Attached controls to the current camera.
  37873. * @param element Defines the element the controls should be listened from
  37874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37875. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37876. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37877. */
  37878. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37879. /**
  37880. * Detach the current controls from the camera.
  37881. * The camera will stop reacting to inputs.
  37882. * @param element Defines the element to stop listening the inputs from
  37883. */
  37884. detachControl(element: HTMLElement): void;
  37885. /** @hidden */
  37886. _checkInputs(): void;
  37887. protected _checkLimits(): void;
  37888. /**
  37889. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  37890. */
  37891. rebuildAnglesAndRadius(): void;
  37892. /**
  37893. * Use a position to define the current camera related information like aplha, beta and radius
  37894. * @param position Defines the position to set the camera at
  37895. */
  37896. setPosition(position: Vector3): void;
  37897. /**
  37898. * Defines the target the camera should look at.
  37899. * This will automatically adapt alpha beta and radius to fit within the new target.
  37900. * @param target Defines the new target as a Vector or a mesh
  37901. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37902. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37903. */
  37904. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37905. /** @hidden */
  37906. _getViewMatrix(): Matrix;
  37907. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37908. /**
  37909. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37910. * @param meshes Defines the mesh to zoom on
  37911. * @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)
  37912. */
  37913. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37914. /**
  37915. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37916. * The target will be changed but the radius
  37917. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37918. * @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)
  37919. */
  37920. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37921. min: Vector3;
  37922. max: Vector3;
  37923. distance: number;
  37924. }, doNotUpdateMaxZ?: boolean): void;
  37925. /**
  37926. * @override
  37927. * Override Camera.createRigCamera
  37928. */
  37929. createRigCamera(name: string, cameraIndex: number): Camera;
  37930. /**
  37931. * @hidden
  37932. * @override
  37933. * Override Camera._updateRigCameras
  37934. */
  37935. _updateRigCameras(): void;
  37936. /**
  37937. * Destroy the camera and release the current resources hold by it.
  37938. */
  37939. dispose(): void;
  37940. /**
  37941. * Gets the current object class name.
  37942. * @return the class name
  37943. */
  37944. getClassName(): string;
  37945. }
  37946. }
  37947. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37948. import { Behavior } from "babylonjs/Behaviors/behavior";
  37949. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37950. /**
  37951. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37952. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37953. */
  37954. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37955. /**
  37956. * Gets the name of the behavior.
  37957. */
  37958. readonly name: string;
  37959. private _zoomStopsAnimation;
  37960. private _idleRotationSpeed;
  37961. private _idleRotationWaitTime;
  37962. private _idleRotationSpinupTime;
  37963. /**
  37964. * Sets the flag that indicates if user zooming should stop animation.
  37965. */
  37966. /**
  37967. * Gets the flag that indicates if user zooming should stop animation.
  37968. */
  37969. zoomStopsAnimation: boolean;
  37970. /**
  37971. * Sets the default speed at which the camera rotates around the model.
  37972. */
  37973. /**
  37974. * Gets the default speed at which the camera rotates around the model.
  37975. */
  37976. idleRotationSpeed: number;
  37977. /**
  37978. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37979. */
  37980. /**
  37981. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37982. */
  37983. idleRotationWaitTime: number;
  37984. /**
  37985. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37986. */
  37987. /**
  37988. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37989. */
  37990. idleRotationSpinupTime: number;
  37991. /**
  37992. * Gets a value indicating if the camera is currently rotating because of this behavior
  37993. */
  37994. readonly rotationInProgress: boolean;
  37995. private _onPrePointerObservableObserver;
  37996. private _onAfterCheckInputsObserver;
  37997. private _attachedCamera;
  37998. private _isPointerDown;
  37999. private _lastFrameTime;
  38000. private _lastInteractionTime;
  38001. private _cameraRotationSpeed;
  38002. /**
  38003. * Initializes the behavior.
  38004. */
  38005. init(): void;
  38006. /**
  38007. * Attaches the behavior to its arc rotate camera.
  38008. * @param camera Defines the camera to attach the behavior to
  38009. */
  38010. attach(camera: ArcRotateCamera): void;
  38011. /**
  38012. * Detaches the behavior from its current arc rotate camera.
  38013. */
  38014. detach(): void;
  38015. /**
  38016. * Returns true if user is scrolling.
  38017. * @return true if user is scrolling.
  38018. */
  38019. private _userIsZooming;
  38020. private _lastFrameRadius;
  38021. private _shouldAnimationStopForInteraction;
  38022. /**
  38023. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38024. */
  38025. private _applyUserInteraction;
  38026. private _userIsMoving;
  38027. }
  38028. }
  38029. declare module "babylonjs/Behaviors/Cameras/index" {
  38030. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38031. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38032. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38033. }
  38034. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38035. import { Mesh } from "babylonjs/Meshes/mesh";
  38036. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38037. import { Behavior } from "babylonjs/Behaviors/behavior";
  38038. /**
  38039. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38040. */
  38041. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38042. private ui;
  38043. /**
  38044. * The name of the behavior
  38045. */
  38046. name: string;
  38047. /**
  38048. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38049. */
  38050. distanceAwayFromFace: number;
  38051. /**
  38052. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38053. */
  38054. distanceAwayFromBottomOfFace: number;
  38055. private _faceVectors;
  38056. private _target;
  38057. private _scene;
  38058. private _onRenderObserver;
  38059. private _tmpMatrix;
  38060. private _tmpVector;
  38061. /**
  38062. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38063. * @param ui The transform node that should be attched to the mesh
  38064. */
  38065. constructor(ui: TransformNode);
  38066. /**
  38067. * Initializes the behavior
  38068. */
  38069. init(): void;
  38070. private _closestFace;
  38071. private _zeroVector;
  38072. private _lookAtTmpMatrix;
  38073. private _lookAtToRef;
  38074. /**
  38075. * Attaches the AttachToBoxBehavior to the passed in mesh
  38076. * @param target The mesh that the specified node will be attached to
  38077. */
  38078. attach(target: Mesh): void;
  38079. /**
  38080. * Detaches the behavior from the mesh
  38081. */
  38082. detach(): void;
  38083. }
  38084. }
  38085. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38086. import { Behavior } from "babylonjs/Behaviors/behavior";
  38087. import { Mesh } from "babylonjs/Meshes/mesh";
  38088. /**
  38089. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38090. */
  38091. export class FadeInOutBehavior implements Behavior<Mesh> {
  38092. /**
  38093. * Time in milliseconds to delay before fading in (Default: 0)
  38094. */
  38095. delay: number;
  38096. /**
  38097. * Time in milliseconds for the mesh to fade in (Default: 300)
  38098. */
  38099. fadeInTime: number;
  38100. private _millisecondsPerFrame;
  38101. private _hovered;
  38102. private _hoverValue;
  38103. private _ownerNode;
  38104. /**
  38105. * Instatiates the FadeInOutBehavior
  38106. */
  38107. constructor();
  38108. /**
  38109. * The name of the behavior
  38110. */
  38111. readonly name: string;
  38112. /**
  38113. * Initializes the behavior
  38114. */
  38115. init(): void;
  38116. /**
  38117. * Attaches the fade behavior on the passed in mesh
  38118. * @param ownerNode The mesh that will be faded in/out once attached
  38119. */
  38120. attach(ownerNode: Mesh): void;
  38121. /**
  38122. * Detaches the behavior from the mesh
  38123. */
  38124. detach(): void;
  38125. /**
  38126. * Triggers the mesh to begin fading in or out
  38127. * @param value if the object should fade in or out (true to fade in)
  38128. */
  38129. fadeIn(value: boolean): void;
  38130. private _update;
  38131. private _setAllVisibility;
  38132. }
  38133. }
  38134. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  38135. import { IDisposable, Scene } from "babylonjs/scene";
  38136. import { Nullable } from "babylonjs/types";
  38137. import { Observable } from "babylonjs/Misc/observable";
  38138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38139. /**
  38140. * Renders a layer on top of an existing scene
  38141. */
  38142. export class UtilityLayerRenderer implements IDisposable {
  38143. /** the original scene that will be rendered on top of */
  38144. originalScene: Scene;
  38145. private _pointerCaptures;
  38146. private _lastPointerEvents;
  38147. private static _DefaultUtilityLayer;
  38148. private static _DefaultKeepDepthUtilityLayer;
  38149. /**
  38150. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  38151. */
  38152. pickUtilitySceneFirst: boolean;
  38153. /**
  38154. * 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)
  38155. */
  38156. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  38157. /**
  38158. * 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)
  38159. */
  38160. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  38161. /**
  38162. * The scene that is rendered on top of the original scene
  38163. */
  38164. utilityLayerScene: Scene;
  38165. /**
  38166. * If the utility layer should automatically be rendered on top of existing scene
  38167. */
  38168. shouldRender: boolean;
  38169. /**
  38170. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  38171. */
  38172. onlyCheckPointerDownEvents: boolean;
  38173. /**
  38174. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  38175. */
  38176. processAllEvents: boolean;
  38177. /**
  38178. * Observable raised when the pointer move from the utility layer scene to the main scene
  38179. */
  38180. onPointerOutObservable: Observable<number>;
  38181. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  38182. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  38183. private _afterRenderObserver;
  38184. private _sceneDisposeObserver;
  38185. private _originalPointerObserver;
  38186. /**
  38187. * Instantiates a UtilityLayerRenderer
  38188. * @param originalScene the original scene that will be rendered on top of
  38189. * @param handleEvents boolean indicating if the utility layer should handle events
  38190. */
  38191. constructor(
  38192. /** the original scene that will be rendered on top of */
  38193. originalScene: Scene, handleEvents?: boolean);
  38194. private _notifyObservers;
  38195. /**
  38196. * Renders the utility layers scene on top of the original scene
  38197. */
  38198. render(): void;
  38199. /**
  38200. * Disposes of the renderer
  38201. */
  38202. dispose(): void;
  38203. private _updateCamera;
  38204. }
  38205. }
  38206. declare module "babylonjs/Gizmos/gizmo" {
  38207. import { Nullable } from "babylonjs/types";
  38208. import { IDisposable } from "babylonjs/scene";
  38209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38210. import { Mesh } from "babylonjs/Meshes/mesh";
  38211. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  38212. /**
  38213. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38214. */
  38215. export class Gizmo implements IDisposable {
  38216. /** The utility layer the gizmo will be added to */
  38217. gizmoLayer: UtilityLayerRenderer;
  38218. /**
  38219. * The root mesh of the gizmo
  38220. */
  38221. protected _rootMesh: Mesh;
  38222. private _attachedMesh;
  38223. /**
  38224. * Ratio for the scale of the gizmo (Default: 1)
  38225. */
  38226. scaleRatio: number;
  38227. private _tmpMatrix;
  38228. /**
  38229. * If a custom mesh has been set (Default: false)
  38230. */
  38231. protected _customMeshSet: boolean;
  38232. /**
  38233. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38234. * * When set, interactions will be enabled
  38235. */
  38236. attachedMesh: Nullable<AbstractMesh>;
  38237. /**
  38238. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38239. * @param mesh The mesh to replace the default mesh of the gizmo
  38240. */
  38241. setCustomMesh(mesh: Mesh): void;
  38242. /**
  38243. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38244. */
  38245. updateGizmoRotationToMatchAttachedMesh: boolean;
  38246. /**
  38247. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38248. */
  38249. updateGizmoPositionToMatchAttachedMesh: boolean;
  38250. /**
  38251. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38252. */
  38253. protected _updateScale: boolean;
  38254. protected _interactionsEnabled: boolean;
  38255. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38256. private _beforeRenderObserver;
  38257. /**
  38258. * Creates a gizmo
  38259. * @param gizmoLayer The utility layer the gizmo will be added to
  38260. */
  38261. constructor(
  38262. /** The utility layer the gizmo will be added to */
  38263. gizmoLayer?: UtilityLayerRenderer);
  38264. private _tempVector;
  38265. /**
  38266. * @hidden
  38267. * Updates the gizmo to match the attached mesh's position/rotation
  38268. */
  38269. protected _update(): void;
  38270. /**
  38271. * Disposes of the gizmo
  38272. */
  38273. dispose(): void;
  38274. }
  38275. }
  38276. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  38277. import { Observable } from "babylonjs/Misc/observable";
  38278. import { Nullable } from "babylonjs/types";
  38279. import { Vector3, Color3 } from "babylonjs/Maths/math";
  38280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38281. import { Mesh } from "babylonjs/Meshes/mesh";
  38282. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  38283. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  38284. /**
  38285. * Bounding box gizmo
  38286. */
  38287. export class BoundingBoxGizmo extends Gizmo {
  38288. private _lineBoundingBox;
  38289. private _rotateSpheresParent;
  38290. private _scaleBoxesParent;
  38291. private _boundingDimensions;
  38292. private _renderObserver;
  38293. private _pointerObserver;
  38294. private _scaleDragSpeed;
  38295. private _tmpQuaternion;
  38296. private _tmpVector;
  38297. private _tmpRotationMatrix;
  38298. /**
  38299. * 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)
  38300. */
  38301. ignoreChildren: boolean;
  38302. /**
  38303. * 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)
  38304. */
  38305. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  38306. /**
  38307. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38308. */
  38309. rotationSphereSize: number;
  38310. /**
  38311. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38312. */
  38313. scaleBoxSize: number;
  38314. /**
  38315. * 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)
  38316. */
  38317. fixedDragMeshScreenSize: boolean;
  38318. /**
  38319. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38320. */
  38321. fixedDragMeshScreenSizeDistanceFactor: number;
  38322. /**
  38323. * Fired when a rotation sphere or scale box is dragged
  38324. */
  38325. onDragStartObservable: Observable<{}>;
  38326. /**
  38327. * Fired when a scale box is dragged
  38328. */
  38329. onScaleBoxDragObservable: Observable<{}>;
  38330. /**
  38331. * Fired when a scale box drag is ended
  38332. */
  38333. onScaleBoxDragEndObservable: Observable<{}>;
  38334. /**
  38335. * Fired when a rotation sphere is dragged
  38336. */
  38337. onRotationSphereDragObservable: Observable<{}>;
  38338. /**
  38339. * Fired when a rotation sphere drag is ended
  38340. */
  38341. onRotationSphereDragEndObservable: Observable<{}>;
  38342. /**
  38343. * 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)
  38344. */
  38345. scalePivot: Nullable<Vector3>;
  38346. private _anchorMesh;
  38347. private _existingMeshScale;
  38348. private static _PivotCached;
  38349. private static _OldPivotPoint;
  38350. private static _PivotTranslation;
  38351. private static _PivotTmpVector;
  38352. /** @hidden */
  38353. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38354. /** @hidden */
  38355. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38356. /**
  38357. * Creates an BoundingBoxGizmo
  38358. * @param gizmoLayer The utility layer the gizmo will be added to
  38359. * @param color The color of the gizmo
  38360. */
  38361. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  38362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38363. private _selectNode;
  38364. /**
  38365. * Updates the bounding box information for the Gizmo
  38366. */
  38367. updateBoundingBox(): void;
  38368. private _updateRotationSpheres;
  38369. private _updateScaleBoxes;
  38370. /**
  38371. * Enables rotation on the specified axis and disables rotation on the others
  38372. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38373. */
  38374. setEnabledRotationAxis(axis: string): void;
  38375. /**
  38376. * Disposes of the gizmo
  38377. */
  38378. dispose(): void;
  38379. /**
  38380. * 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)
  38381. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38382. * @returns the bounding box mesh with the passed in mesh as a child
  38383. */
  38384. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  38385. /**
  38386. * CustomMeshes are not supported by this gizmo
  38387. * @param mesh The mesh to replace the default mesh of the gizmo
  38388. */
  38389. setCustomMesh(mesh: Mesh): void;
  38390. }
  38391. }
  38392. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38393. import { Behavior } from "babylonjs/Behaviors/behavior";
  38394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38395. import { Observable } from "babylonjs/Misc/observable";
  38396. import { Vector3 } from "babylonjs/Maths/math";
  38397. import { Ray } from "babylonjs/Culling/ray";
  38398. /**
  38399. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38400. */
  38401. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38402. private static _AnyMouseID;
  38403. private _attachedNode;
  38404. private _dragPlane;
  38405. private _scene;
  38406. private _pointerObserver;
  38407. private _beforeRenderObserver;
  38408. private static _planeScene;
  38409. /**
  38410. * 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)
  38411. */
  38412. maxDragAngle: number;
  38413. /**
  38414. * @hidden
  38415. */
  38416. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38417. /**
  38418. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38419. */
  38420. currentDraggingPointerID: number;
  38421. /**
  38422. * The last position where the pointer hit the drag plane in world space
  38423. */
  38424. lastDragPosition: Vector3;
  38425. /**
  38426. * If the behavior is currently in a dragging state
  38427. */
  38428. dragging: boolean;
  38429. /**
  38430. * 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)
  38431. */
  38432. dragDeltaRatio: number;
  38433. /**
  38434. * If the drag plane orientation should be updated during the dragging (Default: true)
  38435. */
  38436. updateDragPlane: boolean;
  38437. private _debugMode;
  38438. private _moving;
  38439. /**
  38440. * Fires each time the attached mesh is dragged with the pointer
  38441. * * delta between last drag position and current drag position in world space
  38442. * * dragDistance along the drag axis
  38443. * * dragPlaneNormal normal of the current drag plane used during the drag
  38444. * * dragPlanePoint in world space where the drag intersects the drag plane
  38445. */
  38446. onDragObservable: Observable<{
  38447. delta: Vector3;
  38448. dragPlanePoint: Vector3;
  38449. dragPlaneNormal: Vector3;
  38450. dragDistance: number;
  38451. pointerId: number;
  38452. }>;
  38453. /**
  38454. * Fires each time a drag begins (eg. mouse down on mesh)
  38455. */
  38456. onDragStartObservable: Observable<{
  38457. dragPlanePoint: Vector3;
  38458. pointerId: number;
  38459. }>;
  38460. /**
  38461. * Fires each time a drag ends (eg. mouse release after drag)
  38462. */
  38463. onDragEndObservable: Observable<{
  38464. dragPlanePoint: Vector3;
  38465. pointerId: number;
  38466. }>;
  38467. /**
  38468. * If the attached mesh should be moved when dragged
  38469. */
  38470. moveAttached: boolean;
  38471. /**
  38472. * If the drag behavior will react to drag events (Default: true)
  38473. */
  38474. enabled: boolean;
  38475. /**
  38476. * If camera controls should be detached during the drag
  38477. */
  38478. detachCameraControls: boolean;
  38479. /**
  38480. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38481. */
  38482. useObjectOrienationForDragging: boolean;
  38483. private _options;
  38484. /**
  38485. * Creates a pointer drag behavior that can be attached to a mesh
  38486. * @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)
  38487. */
  38488. constructor(options?: {
  38489. dragAxis?: Vector3;
  38490. dragPlaneNormal?: Vector3;
  38491. });
  38492. /**
  38493. * The name of the behavior
  38494. */
  38495. readonly name: string;
  38496. /**
  38497. * Initializes the behavior
  38498. */
  38499. init(): void;
  38500. private _tmpVector;
  38501. private _alternatePickedPoint;
  38502. private _worldDragAxis;
  38503. private _targetPosition;
  38504. private _attachedElement;
  38505. /**
  38506. * Attaches the drag behavior the passed in mesh
  38507. * @param ownerNode The mesh that will be dragged around once attached
  38508. */
  38509. attach(ownerNode: AbstractMesh): void;
  38510. /**
  38511. * Force relase the drag action by code.
  38512. */
  38513. releaseDrag(): void;
  38514. private _startDragRay;
  38515. private _lastPointerRay;
  38516. /**
  38517. * Simulates the start of a pointer drag event on the behavior
  38518. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38519. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38520. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38521. */
  38522. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38523. private _startDrag;
  38524. private _dragDelta;
  38525. private _moveDrag;
  38526. private _pickWithRayOnDragPlane;
  38527. private _pointA;
  38528. private _pointB;
  38529. private _pointC;
  38530. private _lineA;
  38531. private _lineB;
  38532. private _localAxis;
  38533. private _lookAt;
  38534. private _updateDragPlanePosition;
  38535. /**
  38536. * Detaches the behavior from the mesh
  38537. */
  38538. detach(): void;
  38539. }
  38540. }
  38541. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38542. import { Mesh } from "babylonjs/Meshes/mesh";
  38543. import { Behavior } from "babylonjs/Behaviors/behavior";
  38544. /**
  38545. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38546. */
  38547. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38548. private _dragBehaviorA;
  38549. private _dragBehaviorB;
  38550. private _startDistance;
  38551. private _initialScale;
  38552. private _targetScale;
  38553. private _ownerNode;
  38554. private _sceneRenderObserver;
  38555. /**
  38556. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38557. */
  38558. constructor();
  38559. /**
  38560. * The name of the behavior
  38561. */
  38562. readonly name: string;
  38563. /**
  38564. * Initializes the behavior
  38565. */
  38566. init(): void;
  38567. private _getCurrentDistance;
  38568. /**
  38569. * Attaches the scale behavior the passed in mesh
  38570. * @param ownerNode The mesh that will be scaled around once attached
  38571. */
  38572. attach(ownerNode: Mesh): void;
  38573. /**
  38574. * Detaches the behavior from the mesh
  38575. */
  38576. detach(): void;
  38577. }
  38578. }
  38579. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38580. import { Behavior } from "babylonjs/Behaviors/behavior";
  38581. import { Mesh } from "babylonjs/Meshes/mesh";
  38582. import { Observable } from "babylonjs/Misc/observable";
  38583. /**
  38584. * 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
  38585. */
  38586. export class SixDofDragBehavior implements Behavior<Mesh> {
  38587. private static _virtualScene;
  38588. private _ownerNode;
  38589. private _sceneRenderObserver;
  38590. private _scene;
  38591. private _targetPosition;
  38592. private _virtualOriginMesh;
  38593. private _virtualDragMesh;
  38594. private _pointerObserver;
  38595. private _moving;
  38596. private _startingOrientation;
  38597. /**
  38598. * 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)
  38599. */
  38600. private zDragFactor;
  38601. /**
  38602. * If the behavior is currently in a dragging state
  38603. */
  38604. dragging: boolean;
  38605. /**
  38606. * 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)
  38607. */
  38608. dragDeltaRatio: number;
  38609. /**
  38610. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38611. */
  38612. currentDraggingPointerID: number;
  38613. /**
  38614. * If camera controls should be detached during the drag
  38615. */
  38616. detachCameraControls: boolean;
  38617. /**
  38618. * Fires each time a drag starts
  38619. */
  38620. onDragStartObservable: Observable<{}>;
  38621. /**
  38622. * Fires each time a drag ends (eg. mouse release after drag)
  38623. */
  38624. onDragEndObservable: Observable<{}>;
  38625. /**
  38626. * 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
  38627. */
  38628. constructor();
  38629. /**
  38630. * The name of the behavior
  38631. */
  38632. readonly name: string;
  38633. /**
  38634. * Initializes the behavior
  38635. */
  38636. init(): void;
  38637. /**
  38638. * Attaches the scale behavior the passed in mesh
  38639. * @param ownerNode The mesh that will be scaled around once attached
  38640. */
  38641. attach(ownerNode: Mesh): void;
  38642. /**
  38643. * Detaches the behavior from the mesh
  38644. */
  38645. detach(): void;
  38646. }
  38647. }
  38648. declare module "babylonjs/Behaviors/Meshes/index" {
  38649. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38650. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38651. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38652. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38653. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38654. }
  38655. declare module "babylonjs/Behaviors/index" {
  38656. export * from "babylonjs/Behaviors/behavior";
  38657. export * from "babylonjs/Behaviors/Cameras/index";
  38658. export * from "babylonjs/Behaviors/Meshes/index";
  38659. }
  38660. declare module "babylonjs/Bones/boneIKController" {
  38661. import { Bone } from "babylonjs/Bones/bone";
  38662. import { Vector3 } from "babylonjs/Maths/math";
  38663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38664. import { Nullable } from "babylonjs/types";
  38665. /**
  38666. * Class used to apply inverse kinematics to bones
  38667. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38668. */
  38669. export class BoneIKController {
  38670. private static _tmpVecs;
  38671. private static _tmpQuat;
  38672. private static _tmpMats;
  38673. /**
  38674. * Gets or sets the target mesh
  38675. */
  38676. targetMesh: AbstractMesh;
  38677. /** Gets or sets the mesh used as pole */
  38678. poleTargetMesh: AbstractMesh;
  38679. /**
  38680. * Gets or sets the bone used as pole
  38681. */
  38682. poleTargetBone: Nullable<Bone>;
  38683. /**
  38684. * Gets or sets the target position
  38685. */
  38686. targetPosition: Vector3;
  38687. /**
  38688. * Gets or sets the pole target position
  38689. */
  38690. poleTargetPosition: Vector3;
  38691. /**
  38692. * Gets or sets the pole target local offset
  38693. */
  38694. poleTargetLocalOffset: Vector3;
  38695. /**
  38696. * Gets or sets the pole angle
  38697. */
  38698. poleAngle: number;
  38699. /**
  38700. * Gets or sets the mesh associated with the controller
  38701. */
  38702. mesh: AbstractMesh;
  38703. /**
  38704. * 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)
  38705. */
  38706. slerpAmount: number;
  38707. private _bone1Quat;
  38708. private _bone1Mat;
  38709. private _bone2Ang;
  38710. private _bone1;
  38711. private _bone2;
  38712. private _bone1Length;
  38713. private _bone2Length;
  38714. private _maxAngle;
  38715. private _maxReach;
  38716. private _rightHandedSystem;
  38717. private _bendAxis;
  38718. private _slerping;
  38719. private _adjustRoll;
  38720. /**
  38721. * Gets or sets maximum allowed angle
  38722. */
  38723. maxAngle: number;
  38724. /**
  38725. * Creates a new BoneIKController
  38726. * @param mesh defines the mesh to control
  38727. * @param bone defines the bone to control
  38728. * @param options defines options to set up the controller
  38729. */
  38730. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38731. targetMesh?: AbstractMesh;
  38732. poleTargetMesh?: AbstractMesh;
  38733. poleTargetBone?: Bone;
  38734. poleTargetLocalOffset?: Vector3;
  38735. poleAngle?: number;
  38736. bendAxis?: Vector3;
  38737. maxAngle?: number;
  38738. slerpAmount?: number;
  38739. });
  38740. private _setMaxAngle;
  38741. /**
  38742. * Force the controller to update the bones
  38743. */
  38744. update(): void;
  38745. }
  38746. }
  38747. declare module "babylonjs/Bones/boneLookController" {
  38748. import { Vector3, Space } from "babylonjs/Maths/math";
  38749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38750. import { Bone } from "babylonjs/Bones/bone";
  38751. /**
  38752. * Class used to make a bone look toward a point in space
  38753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38754. */
  38755. export class BoneLookController {
  38756. private static _tmpVecs;
  38757. private static _tmpQuat;
  38758. private static _tmpMats;
  38759. /**
  38760. * The target Vector3 that the bone will look at
  38761. */
  38762. target: Vector3;
  38763. /**
  38764. * The mesh that the bone is attached to
  38765. */
  38766. mesh: AbstractMesh;
  38767. /**
  38768. * The bone that will be looking to the target
  38769. */
  38770. bone: Bone;
  38771. /**
  38772. * The up axis of the coordinate system that is used when the bone is rotated
  38773. */
  38774. upAxis: Vector3;
  38775. /**
  38776. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38777. */
  38778. upAxisSpace: Space;
  38779. /**
  38780. * Used to make an adjustment to the yaw of the bone
  38781. */
  38782. adjustYaw: number;
  38783. /**
  38784. * Used to make an adjustment to the pitch of the bone
  38785. */
  38786. adjustPitch: number;
  38787. /**
  38788. * Used to make an adjustment to the roll of the bone
  38789. */
  38790. adjustRoll: number;
  38791. /**
  38792. * 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)
  38793. */
  38794. slerpAmount: number;
  38795. private _minYaw;
  38796. private _maxYaw;
  38797. private _minPitch;
  38798. private _maxPitch;
  38799. private _minYawSin;
  38800. private _minYawCos;
  38801. private _maxYawSin;
  38802. private _maxYawCos;
  38803. private _midYawConstraint;
  38804. private _minPitchTan;
  38805. private _maxPitchTan;
  38806. private _boneQuat;
  38807. private _slerping;
  38808. private _transformYawPitch;
  38809. private _transformYawPitchInv;
  38810. private _firstFrameSkipped;
  38811. private _yawRange;
  38812. private _fowardAxis;
  38813. /**
  38814. * Gets or sets the minimum yaw angle that the bone can look to
  38815. */
  38816. minYaw: number;
  38817. /**
  38818. * Gets or sets the maximum yaw angle that the bone can look to
  38819. */
  38820. maxYaw: number;
  38821. /**
  38822. * Gets or sets the minimum pitch angle that the bone can look to
  38823. */
  38824. minPitch: number;
  38825. /**
  38826. * Gets or sets the maximum pitch angle that the bone can look to
  38827. */
  38828. maxPitch: number;
  38829. /**
  38830. * Create a BoneLookController
  38831. * @param mesh the mesh that the bone belongs to
  38832. * @param bone the bone that will be looking to the target
  38833. * @param target the target Vector3 to look at
  38834. * @param settings optional settings:
  38835. * * maxYaw: the maximum angle the bone will yaw to
  38836. * * minYaw: the minimum angle the bone will yaw to
  38837. * * maxPitch: the maximum angle the bone will pitch to
  38838. * * minPitch: the minimum angle the bone will yaw to
  38839. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38840. * * upAxis: the up axis of the coordinate system
  38841. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38842. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38843. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38844. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38845. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38846. * * adjustRoll: used to make an adjustment to the roll of the bone
  38847. **/
  38848. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38849. maxYaw?: number;
  38850. minYaw?: number;
  38851. maxPitch?: number;
  38852. minPitch?: number;
  38853. slerpAmount?: number;
  38854. upAxis?: Vector3;
  38855. upAxisSpace?: Space;
  38856. yawAxis?: Vector3;
  38857. pitchAxis?: Vector3;
  38858. adjustYaw?: number;
  38859. adjustPitch?: number;
  38860. adjustRoll?: number;
  38861. });
  38862. /**
  38863. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38864. */
  38865. update(): void;
  38866. private _getAngleDiff;
  38867. private _getAngleBetween;
  38868. private _isAngleBetween;
  38869. }
  38870. }
  38871. declare module "babylonjs/Bones/index" {
  38872. export * from "babylonjs/Bones/bone";
  38873. export * from "babylonjs/Bones/boneIKController";
  38874. export * from "babylonjs/Bones/boneLookController";
  38875. export * from "babylonjs/Bones/skeleton";
  38876. }
  38877. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38878. import { Nullable } from "babylonjs/types";
  38879. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38880. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38881. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38882. /**
  38883. * Manage the gamepad inputs to control an arc rotate camera.
  38884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38885. */
  38886. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38887. /**
  38888. * Defines the camera the input is attached to.
  38889. */
  38890. camera: ArcRotateCamera;
  38891. /**
  38892. * Defines the gamepad the input is gathering event from.
  38893. */
  38894. gamepad: Nullable<Gamepad>;
  38895. /**
  38896. * Defines the gamepad rotation sensiblity.
  38897. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38898. */
  38899. gamepadRotationSensibility: number;
  38900. /**
  38901. * Defines the gamepad move sensiblity.
  38902. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38903. */
  38904. gamepadMoveSensibility: number;
  38905. private _onGamepadConnectedObserver;
  38906. private _onGamepadDisconnectedObserver;
  38907. /**
  38908. * Attach the input controls to a specific dom element to get the input from.
  38909. * @param element Defines the element the controls should be listened from
  38910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38911. */
  38912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38913. /**
  38914. * Detach the current controls from the specified dom element.
  38915. * @param element Defines the element to stop listening the inputs from
  38916. */
  38917. detachControl(element: Nullable<HTMLElement>): void;
  38918. /**
  38919. * Update the current camera state depending on the inputs that have been used this frame.
  38920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38921. */
  38922. checkInputs(): void;
  38923. /**
  38924. * Gets the class name of the current intput.
  38925. * @returns the class name
  38926. */
  38927. getClassName(): string;
  38928. /**
  38929. * Get the friendly name associated with the input class.
  38930. * @returns the input friendly name
  38931. */
  38932. getSimpleName(): string;
  38933. }
  38934. }
  38935. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38936. import { Nullable } from "babylonjs/types";
  38937. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38938. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38939. /**
  38940. * Listen to mouse events to control the camera.
  38941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38942. */
  38943. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38944. /**
  38945. * Defines the camera the input is attached to.
  38946. */
  38947. camera: FlyCamera;
  38948. /**
  38949. * Defines if touch is enabled. (Default is true.)
  38950. */
  38951. touchEnabled: boolean;
  38952. /**
  38953. * Defines the buttons associated with the input to handle camera rotation.
  38954. */
  38955. buttons: number[];
  38956. /**
  38957. * Assign buttons for Yaw control.
  38958. */
  38959. buttonsYaw: number[];
  38960. /**
  38961. * Assign buttons for Pitch control.
  38962. */
  38963. buttonsPitch: number[];
  38964. /**
  38965. * Assign buttons for Roll control.
  38966. */
  38967. buttonsRoll: number[];
  38968. /**
  38969. * Detect if any button is being pressed while mouse is moved.
  38970. * -1 = Mouse locked.
  38971. * 0 = Left button.
  38972. * 1 = Middle Button.
  38973. * 2 = Right Button.
  38974. */
  38975. activeButton: number;
  38976. /**
  38977. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38978. * Higher values reduce its sensitivity.
  38979. */
  38980. angularSensibility: number;
  38981. private _mousemoveCallback;
  38982. private _observer;
  38983. private _rollObserver;
  38984. private previousPosition;
  38985. private noPreventDefault;
  38986. private element;
  38987. /**
  38988. * Listen to mouse events to control the camera.
  38989. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38991. */
  38992. constructor(touchEnabled?: boolean);
  38993. /**
  38994. * Attach the mouse control to the HTML DOM element.
  38995. * @param element Defines the element that listens to the input events.
  38996. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38997. */
  38998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38999. /**
  39000. * Detach the current controls from the specified dom element.
  39001. * @param element Defines the element to stop listening the inputs from
  39002. */
  39003. detachControl(element: Nullable<HTMLElement>): void;
  39004. /**
  39005. * Gets the class name of the current input.
  39006. * @returns the class name.
  39007. */
  39008. getClassName(): string;
  39009. /**
  39010. * Get the friendly name associated with the input class.
  39011. * @returns the input's friendly name.
  39012. */
  39013. getSimpleName(): string;
  39014. private _pointerInput;
  39015. private _onMouseMove;
  39016. /**
  39017. * Rotate camera by mouse offset.
  39018. */
  39019. private rotateCamera;
  39020. }
  39021. }
  39022. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39023. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39024. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39025. /**
  39026. * Default Inputs manager for the FlyCamera.
  39027. * It groups all the default supported inputs for ease of use.
  39028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39029. */
  39030. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39031. /**
  39032. * Instantiates a new FlyCameraInputsManager.
  39033. * @param camera Defines the camera the inputs belong to.
  39034. */
  39035. constructor(camera: FlyCamera);
  39036. /**
  39037. * Add keyboard input support to the input manager.
  39038. * @returns the new FlyCameraKeyboardMoveInput().
  39039. */
  39040. addKeyboard(): FlyCameraInputsManager;
  39041. /**
  39042. * Add mouse input support to the input manager.
  39043. * @param touchEnabled Enable touch screen support.
  39044. * @returns the new FlyCameraMouseInput().
  39045. */
  39046. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39047. }
  39048. }
  39049. declare module "babylonjs/Cameras/flyCamera" {
  39050. import { Scene } from "babylonjs/scene";
  39051. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  39052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39053. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39054. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39055. /**
  39056. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39057. * such as in a 3D Space Shooter or a Flight Simulator.
  39058. */
  39059. export class FlyCamera extends TargetCamera {
  39060. /**
  39061. * Define the collision ellipsoid of the camera.
  39062. * This is helpful for simulating a camera body, like a player's body.
  39063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39064. */
  39065. ellipsoid: Vector3;
  39066. /**
  39067. * Define an offset for the position of the ellipsoid around the camera.
  39068. * This can be helpful if the camera is attached away from the player's body center,
  39069. * such as at its head.
  39070. */
  39071. ellipsoidOffset: Vector3;
  39072. /**
  39073. * Enable or disable collisions of the camera with the rest of the scene objects.
  39074. */
  39075. checkCollisions: boolean;
  39076. /**
  39077. * Enable or disable gravity on the camera.
  39078. */
  39079. applyGravity: boolean;
  39080. /**
  39081. * Define the current direction the camera is moving to.
  39082. */
  39083. cameraDirection: Vector3;
  39084. /**
  39085. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39086. * This overrides and empties cameraRotation.
  39087. */
  39088. rotationQuaternion: Quaternion;
  39089. /**
  39090. * Track Roll to maintain the wanted Rolling when looking around.
  39091. */
  39092. _trackRoll: number;
  39093. /**
  39094. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39095. */
  39096. rollCorrect: number;
  39097. /**
  39098. * Mimic a banked turn, Rolling the camera when Yawing.
  39099. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39100. */
  39101. bankedTurn: boolean;
  39102. /**
  39103. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39104. */
  39105. bankedTurnLimit: number;
  39106. /**
  39107. * Value of 0 disables the banked Roll.
  39108. * Value of 1 is equal to the Yaw angle in radians.
  39109. */
  39110. bankedTurnMultiplier: number;
  39111. /**
  39112. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39113. */
  39114. inputs: FlyCameraInputsManager;
  39115. /**
  39116. * Gets the input sensibility for mouse input.
  39117. * Higher values reduce sensitivity.
  39118. */
  39119. /**
  39120. * Sets the input sensibility for a mouse input.
  39121. * Higher values reduce sensitivity.
  39122. */
  39123. angularSensibility: number;
  39124. /**
  39125. * Get the keys for camera movement forward.
  39126. */
  39127. /**
  39128. * Set the keys for camera movement forward.
  39129. */
  39130. keysForward: number[];
  39131. /**
  39132. * Get the keys for camera movement backward.
  39133. */
  39134. keysBackward: number[];
  39135. /**
  39136. * Get the keys for camera movement up.
  39137. */
  39138. /**
  39139. * Set the keys for camera movement up.
  39140. */
  39141. keysUp: number[];
  39142. /**
  39143. * Get the keys for camera movement down.
  39144. */
  39145. /**
  39146. * Set the keys for camera movement down.
  39147. */
  39148. keysDown: number[];
  39149. /**
  39150. * Get the keys for camera movement left.
  39151. */
  39152. /**
  39153. * Set the keys for camera movement left.
  39154. */
  39155. keysLeft: number[];
  39156. /**
  39157. * Set the keys for camera movement right.
  39158. */
  39159. /**
  39160. * Set the keys for camera movement right.
  39161. */
  39162. keysRight: number[];
  39163. /**
  39164. * Event raised when the camera collides with a mesh in the scene.
  39165. */
  39166. onCollide: (collidedMesh: AbstractMesh) => void;
  39167. private _collider;
  39168. private _needMoveForGravity;
  39169. private _oldPosition;
  39170. private _diffPosition;
  39171. private _newPosition;
  39172. /** @hidden */
  39173. _localDirection: Vector3;
  39174. /** @hidden */
  39175. _transformedDirection: Vector3;
  39176. /**
  39177. * Instantiates a FlyCamera.
  39178. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39179. * such as in a 3D Space Shooter or a Flight Simulator.
  39180. * @param name Define the name of the camera in the scene.
  39181. * @param position Define the starting position of the camera in the scene.
  39182. * @param scene Define the scene the camera belongs to.
  39183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39184. */
  39185. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39186. /**
  39187. * Attach a control to the HTML DOM element.
  39188. * @param element Defines the element that listens to the input events.
  39189. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39190. */
  39191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39192. /**
  39193. * Detach a control from the HTML DOM element.
  39194. * The camera will stop reacting to that input.
  39195. * @param element Defines the element that listens to the input events.
  39196. */
  39197. detachControl(element: HTMLElement): void;
  39198. private _collisionMask;
  39199. /**
  39200. * Get the mask that the camera ignores in collision events.
  39201. */
  39202. /**
  39203. * Set the mask that the camera ignores in collision events.
  39204. */
  39205. collisionMask: number;
  39206. /** @hidden */
  39207. _collideWithWorld(displacement: Vector3): void;
  39208. /** @hidden */
  39209. private _onCollisionPositionChange;
  39210. /** @hidden */
  39211. _checkInputs(): void;
  39212. /** @hidden */
  39213. _decideIfNeedsToMove(): boolean;
  39214. /** @hidden */
  39215. _updatePosition(): void;
  39216. /**
  39217. * Restore the Roll to its target value at the rate specified.
  39218. * @param rate - Higher means slower restoring.
  39219. * @hidden
  39220. */
  39221. restoreRoll(rate: number): void;
  39222. /**
  39223. * Destroy the camera and release the current resources held by it.
  39224. */
  39225. dispose(): void;
  39226. /**
  39227. * Get the current object class name.
  39228. * @returns the class name.
  39229. */
  39230. getClassName(): string;
  39231. }
  39232. }
  39233. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39234. import { Nullable } from "babylonjs/types";
  39235. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39236. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39237. /**
  39238. * Listen to keyboard events to control the camera.
  39239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39240. */
  39241. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39242. /**
  39243. * Defines the camera the input is attached to.
  39244. */
  39245. camera: FlyCamera;
  39246. /**
  39247. * The list of keyboard keys used to control the forward move of the camera.
  39248. */
  39249. keysForward: number[];
  39250. /**
  39251. * The list of keyboard keys used to control the backward move of the camera.
  39252. */
  39253. keysBackward: number[];
  39254. /**
  39255. * The list of keyboard keys used to control the forward move of the camera.
  39256. */
  39257. keysUp: number[];
  39258. /**
  39259. * The list of keyboard keys used to control the backward move of the camera.
  39260. */
  39261. keysDown: number[];
  39262. /**
  39263. * The list of keyboard keys used to control the right strafe move of the camera.
  39264. */
  39265. keysRight: number[];
  39266. /**
  39267. * The list of keyboard keys used to control the left strafe move of the camera.
  39268. */
  39269. keysLeft: number[];
  39270. private _keys;
  39271. private _onCanvasBlurObserver;
  39272. private _onKeyboardObserver;
  39273. private _engine;
  39274. private _scene;
  39275. /**
  39276. * Attach the input controls to a specific dom element to get the input from.
  39277. * @param element Defines the element the controls should be listened from
  39278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39279. */
  39280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39281. /**
  39282. * Detach the current controls from the specified dom element.
  39283. * @param element Defines the element to stop listening the inputs from
  39284. */
  39285. detachControl(element: Nullable<HTMLElement>): void;
  39286. /**
  39287. * Gets the class name of the current intput.
  39288. * @returns the class name
  39289. */
  39290. getClassName(): string;
  39291. /** @hidden */
  39292. _onLostFocus(e: FocusEvent): void;
  39293. /**
  39294. * Get the friendly name associated with the input class.
  39295. * @returns the input friendly name
  39296. */
  39297. getSimpleName(): string;
  39298. /**
  39299. * Update the current camera state depending on the inputs that have been used this frame.
  39300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39301. */
  39302. checkInputs(): void;
  39303. }
  39304. }
  39305. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39306. import { Nullable } from "babylonjs/types";
  39307. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39309. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39310. /**
  39311. * Manage the gamepad inputs to control a free camera.
  39312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39313. */
  39314. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39315. /**
  39316. * Define the camera the input is attached to.
  39317. */
  39318. camera: FreeCamera;
  39319. /**
  39320. * Define the Gamepad controlling the input
  39321. */
  39322. gamepad: Nullable<Gamepad>;
  39323. /**
  39324. * Defines the gamepad rotation sensiblity.
  39325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39326. */
  39327. gamepadAngularSensibility: number;
  39328. /**
  39329. * Defines the gamepad move sensiblity.
  39330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39331. */
  39332. gamepadMoveSensibility: number;
  39333. private _onGamepadConnectedObserver;
  39334. private _onGamepadDisconnectedObserver;
  39335. private _cameraTransform;
  39336. private _deltaTransform;
  39337. private _vector3;
  39338. private _vector2;
  39339. /**
  39340. * Attach the input controls to a specific dom element to get the input from.
  39341. * @param element Defines the element the controls should be listened from
  39342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39343. */
  39344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39345. /**
  39346. * Detach the current controls from the specified dom element.
  39347. * @param element Defines the element to stop listening the inputs from
  39348. */
  39349. detachControl(element: Nullable<HTMLElement>): void;
  39350. /**
  39351. * Update the current camera state depending on the inputs that have been used this frame.
  39352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39353. */
  39354. checkInputs(): void;
  39355. /**
  39356. * Gets the class name of the current intput.
  39357. * @returns the class name
  39358. */
  39359. getClassName(): string;
  39360. /**
  39361. * Get the friendly name associated with the input class.
  39362. * @returns the input friendly name
  39363. */
  39364. getSimpleName(): string;
  39365. }
  39366. }
  39367. declare module "babylonjs/Cameras/Inputs/index" {
  39368. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39369. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39370. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39371. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39372. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39373. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39374. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39375. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39376. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39377. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39378. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39379. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39380. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39381. }
  39382. declare module "babylonjs/Cameras/touchCamera" {
  39383. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39384. import { Scene } from "babylonjs/scene";
  39385. import { Vector3 } from "babylonjs/Maths/math";
  39386. /**
  39387. * This represents a FPS type of camera controlled by touch.
  39388. * This is like a universal camera minus the Gamepad controls.
  39389. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39390. */
  39391. export class TouchCamera extends FreeCamera {
  39392. /**
  39393. * Defines the touch sensibility for rotation.
  39394. * The higher the faster.
  39395. */
  39396. touchAngularSensibility: number;
  39397. /**
  39398. * Defines the touch sensibility for move.
  39399. * The higher the faster.
  39400. */
  39401. touchMoveSensibility: number;
  39402. /**
  39403. * Instantiates a new touch camera.
  39404. * This represents a FPS type of camera controlled by touch.
  39405. * This is like a universal camera minus the Gamepad controls.
  39406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39407. * @param name Define the name of the camera in the scene
  39408. * @param position Define the start position of the camera in the scene
  39409. * @param scene Define the scene the camera belongs to
  39410. */
  39411. constructor(name: string, position: Vector3, scene: Scene);
  39412. /**
  39413. * Gets the current object class name.
  39414. * @return the class name
  39415. */
  39416. getClassName(): string;
  39417. /** @hidden */
  39418. _setupInputs(): void;
  39419. }
  39420. }
  39421. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39422. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39423. import { Scene } from "babylonjs/scene";
  39424. import { Vector3, Axis } from "babylonjs/Maths/math";
  39425. /**
  39426. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39427. * being tilted forward or back and left or right.
  39428. */
  39429. export class DeviceOrientationCamera extends FreeCamera {
  39430. private _initialQuaternion;
  39431. private _quaternionCache;
  39432. /**
  39433. * Creates a new device orientation camera
  39434. * @param name The name of the camera
  39435. * @param position The start position camera
  39436. * @param scene The scene the camera belongs to
  39437. */
  39438. constructor(name: string, position: Vector3, scene: Scene);
  39439. /**
  39440. * Gets the current instance class name ("DeviceOrientationCamera").
  39441. * This helps avoiding instanceof at run time.
  39442. * @returns the class name
  39443. */
  39444. getClassName(): string;
  39445. /**
  39446. * @hidden
  39447. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39448. */
  39449. _checkInputs(): void;
  39450. /**
  39451. * Reset the camera to its default orientation on the specified axis only.
  39452. * @param axis The axis to reset
  39453. */
  39454. resetToCurrentRotation(axis?: Axis): void;
  39455. }
  39456. }
  39457. declare module "babylonjs/Cameras/followCamera" {
  39458. import { Nullable } from "babylonjs/types";
  39459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39460. import { Scene } from "babylonjs/scene";
  39461. import { Vector3 } from "babylonjs/Maths/math";
  39462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39463. /**
  39464. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39465. * an arc rotate version arcFollowCamera are available.
  39466. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39467. */
  39468. export class FollowCamera extends TargetCamera {
  39469. /**
  39470. * Distance the follow camera should follow an object at
  39471. */
  39472. radius: number;
  39473. /**
  39474. * Define a rotation offset between the camera and the object it follows
  39475. */
  39476. rotationOffset: number;
  39477. /**
  39478. * Define a height offset between the camera and the object it follows.
  39479. * It can help following an object from the top (like a car chaing a plane)
  39480. */
  39481. heightOffset: number;
  39482. /**
  39483. * Define how fast the camera can accelerate to follow it s target.
  39484. */
  39485. cameraAcceleration: number;
  39486. /**
  39487. * Define the speed limit of the camera following an object.
  39488. */
  39489. maxCameraSpeed: number;
  39490. /**
  39491. * Define the target of the camera.
  39492. */
  39493. lockedTarget: Nullable<AbstractMesh>;
  39494. /**
  39495. * Instantiates the follow camera.
  39496. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39497. * @param name Define the name of the camera in the scene
  39498. * @param position Define the position of the camera
  39499. * @param scene Define the scene the camera belong to
  39500. * @param lockedTarget Define the target of the camera
  39501. */
  39502. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39503. private _follow;
  39504. /** @hidden */
  39505. _checkInputs(): void;
  39506. /**
  39507. * Gets the camera class name.
  39508. * @returns the class name
  39509. */
  39510. getClassName(): string;
  39511. }
  39512. /**
  39513. * Arc Rotate version of the follow camera.
  39514. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39515. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39516. */
  39517. export class ArcFollowCamera extends TargetCamera {
  39518. /** The longitudinal angle of the camera */
  39519. alpha: number;
  39520. /** The latitudinal angle of the camera */
  39521. beta: number;
  39522. /** The radius of the camera from its target */
  39523. radius: number;
  39524. /** Define the camera target (the messh it should follow) */
  39525. target: Nullable<AbstractMesh>;
  39526. private _cartesianCoordinates;
  39527. /**
  39528. * Instantiates a new ArcFollowCamera
  39529. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39530. * @param name Define the name of the camera
  39531. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39532. * @param beta Define the rotation angle of the camera around the elevation axis
  39533. * @param radius Define the radius of the camera from its target point
  39534. * @param target Define the target of the camera
  39535. * @param scene Define the scene the camera belongs to
  39536. */
  39537. constructor(name: string,
  39538. /** The longitudinal angle of the camera */
  39539. alpha: number,
  39540. /** The latitudinal angle of the camera */
  39541. beta: number,
  39542. /** The radius of the camera from its target */
  39543. radius: number,
  39544. /** Define the camera target (the messh it should follow) */
  39545. target: Nullable<AbstractMesh>, scene: Scene);
  39546. private _follow;
  39547. /** @hidden */
  39548. _checkInputs(): void;
  39549. /**
  39550. * Returns the class name of the object.
  39551. * It is mostly used internally for serialization purposes.
  39552. */
  39553. getClassName(): string;
  39554. }
  39555. }
  39556. declare module "babylonjs/Cameras/universalCamera" {
  39557. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39558. import { Scene } from "babylonjs/scene";
  39559. import { Vector3 } from "babylonjs/Maths/math";
  39560. /**
  39561. * 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,
  39562. * which still works and will still be found in many Playgrounds.
  39563. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39564. */
  39565. export class UniversalCamera extends TouchCamera {
  39566. /**
  39567. * Defines the gamepad rotation sensiblity.
  39568. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39569. */
  39570. gamepadAngularSensibility: number;
  39571. /**
  39572. * Defines the gamepad move sensiblity.
  39573. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39574. */
  39575. gamepadMoveSensibility: number;
  39576. /**
  39577. * 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,
  39578. * which still works and will still be found in many Playgrounds.
  39579. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39580. * @param name Define the name of the camera in the scene
  39581. * @param position Define the start position of the camera in the scene
  39582. * @param scene Define the scene the camera belongs to
  39583. */
  39584. constructor(name: string, position: Vector3, scene: Scene);
  39585. /**
  39586. * Gets the current object class name.
  39587. * @return the class name
  39588. */
  39589. getClassName(): string;
  39590. }
  39591. }
  39592. declare module "babylonjs/Cameras/gamepadCamera" {
  39593. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39594. import { Scene } from "babylonjs/scene";
  39595. import { Vector3 } from "babylonjs/Maths/math";
  39596. /**
  39597. * This represents a FPS type of camera. This is only here for back compat purpose.
  39598. * Please use the UniversalCamera instead as both are identical.
  39599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39600. */
  39601. export class GamepadCamera extends UniversalCamera {
  39602. /**
  39603. * Instantiates a new Gamepad Camera
  39604. * This represents a FPS type of camera. This is only here for back compat purpose.
  39605. * Please use the UniversalCamera instead as both are identical.
  39606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39607. * @param name Define the name of the camera in the scene
  39608. * @param position Define the start position of the camera in the scene
  39609. * @param scene Define the scene the camera belongs to
  39610. */
  39611. constructor(name: string, position: Vector3, scene: Scene);
  39612. /**
  39613. * Gets the current object class name.
  39614. * @return the class name
  39615. */
  39616. getClassName(): string;
  39617. }
  39618. }
  39619. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39620. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39621. import { Scene } from "babylonjs/scene";
  39622. import { Vector3 } from "babylonjs/Maths/math";
  39623. /**
  39624. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39625. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39626. */
  39627. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39628. /**
  39629. * Creates a new AnaglyphArcRotateCamera
  39630. * @param name defines camera name
  39631. * @param alpha defines alpha angle (in radians)
  39632. * @param beta defines beta angle (in radians)
  39633. * @param radius defines radius
  39634. * @param target defines camera target
  39635. * @param interaxialDistance defines distance between each color axis
  39636. * @param scene defines the hosting scene
  39637. */
  39638. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39639. /**
  39640. * Gets camera class name
  39641. * @returns AnaglyphArcRotateCamera
  39642. */
  39643. getClassName(): string;
  39644. }
  39645. }
  39646. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39647. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39648. import { Scene } from "babylonjs/scene";
  39649. import { Vector3 } from "babylonjs/Maths/math";
  39650. /**
  39651. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39652. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39653. */
  39654. export class AnaglyphFreeCamera extends FreeCamera {
  39655. /**
  39656. * Creates a new AnaglyphFreeCamera
  39657. * @param name defines camera name
  39658. * @param position defines initial position
  39659. * @param interaxialDistance defines distance between each color axis
  39660. * @param scene defines the hosting scene
  39661. */
  39662. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39663. /**
  39664. * Gets camera class name
  39665. * @returns AnaglyphFreeCamera
  39666. */
  39667. getClassName(): string;
  39668. }
  39669. }
  39670. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39671. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39672. import { Scene } from "babylonjs/scene";
  39673. import { Vector3 } from "babylonjs/Maths/math";
  39674. /**
  39675. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39676. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39677. */
  39678. export class AnaglyphGamepadCamera extends GamepadCamera {
  39679. /**
  39680. * Creates a new AnaglyphGamepadCamera
  39681. * @param name defines camera name
  39682. * @param position defines initial position
  39683. * @param interaxialDistance defines distance between each color axis
  39684. * @param scene defines the hosting scene
  39685. */
  39686. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39687. /**
  39688. * Gets camera class name
  39689. * @returns AnaglyphGamepadCamera
  39690. */
  39691. getClassName(): string;
  39692. }
  39693. }
  39694. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39695. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39696. import { Scene } from "babylonjs/scene";
  39697. import { Vector3 } from "babylonjs/Maths/math";
  39698. /**
  39699. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39700. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39701. */
  39702. export class AnaglyphUniversalCamera extends UniversalCamera {
  39703. /**
  39704. * Creates a new AnaglyphUniversalCamera
  39705. * @param name defines camera name
  39706. * @param position defines initial position
  39707. * @param interaxialDistance defines distance between each color axis
  39708. * @param scene defines the hosting scene
  39709. */
  39710. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39711. /**
  39712. * Gets camera class name
  39713. * @returns AnaglyphUniversalCamera
  39714. */
  39715. getClassName(): string;
  39716. }
  39717. }
  39718. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39719. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39720. import { Scene } from "babylonjs/scene";
  39721. import { Vector3 } from "babylonjs/Maths/math";
  39722. /**
  39723. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39724. * @see http://doc.babylonjs.com/features/cameras
  39725. */
  39726. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39727. /**
  39728. * Creates a new StereoscopicArcRotateCamera
  39729. * @param name defines camera name
  39730. * @param alpha defines alpha angle (in radians)
  39731. * @param beta defines beta angle (in radians)
  39732. * @param radius defines radius
  39733. * @param target defines camera target
  39734. * @param interaxialDistance defines distance between each color axis
  39735. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39736. * @param scene defines the hosting scene
  39737. */
  39738. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39739. /**
  39740. * Gets camera class name
  39741. * @returns StereoscopicArcRotateCamera
  39742. */
  39743. getClassName(): string;
  39744. }
  39745. }
  39746. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39747. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39748. import { Scene } from "babylonjs/scene";
  39749. import { Vector3 } from "babylonjs/Maths/math";
  39750. /**
  39751. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39752. * @see http://doc.babylonjs.com/features/cameras
  39753. */
  39754. export class StereoscopicFreeCamera extends FreeCamera {
  39755. /**
  39756. * Creates a new StereoscopicFreeCamera
  39757. * @param name defines camera name
  39758. * @param position defines initial position
  39759. * @param interaxialDistance defines distance between each color axis
  39760. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39761. * @param scene defines the hosting scene
  39762. */
  39763. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39764. /**
  39765. * Gets camera class name
  39766. * @returns StereoscopicFreeCamera
  39767. */
  39768. getClassName(): string;
  39769. }
  39770. }
  39771. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39772. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39773. import { Scene } from "babylonjs/scene";
  39774. import { Vector3 } from "babylonjs/Maths/math";
  39775. /**
  39776. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39777. * @see http://doc.babylonjs.com/features/cameras
  39778. */
  39779. export class StereoscopicGamepadCamera extends GamepadCamera {
  39780. /**
  39781. * Creates a new StereoscopicGamepadCamera
  39782. * @param name defines camera name
  39783. * @param position defines initial position
  39784. * @param interaxialDistance defines distance between each color axis
  39785. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39786. * @param scene defines the hosting scene
  39787. */
  39788. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39789. /**
  39790. * Gets camera class name
  39791. * @returns StereoscopicGamepadCamera
  39792. */
  39793. getClassName(): string;
  39794. }
  39795. }
  39796. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39797. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39798. import { Scene } from "babylonjs/scene";
  39799. import { Vector3 } from "babylonjs/Maths/math";
  39800. /**
  39801. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39802. * @see http://doc.babylonjs.com/features/cameras
  39803. */
  39804. export class StereoscopicUniversalCamera extends UniversalCamera {
  39805. /**
  39806. * Creates a new StereoscopicUniversalCamera
  39807. * @param name defines camera name
  39808. * @param position defines initial position
  39809. * @param interaxialDistance defines distance between each color axis
  39810. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39811. * @param scene defines the hosting scene
  39812. */
  39813. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39814. /**
  39815. * Gets camera class name
  39816. * @returns StereoscopicUniversalCamera
  39817. */
  39818. getClassName(): string;
  39819. }
  39820. }
  39821. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39822. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39823. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39824. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39825. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39826. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39827. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39828. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39829. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39830. }
  39831. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39832. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39833. import { Scene } from "babylonjs/scene";
  39834. import { Vector3 } from "babylonjs/Maths/math";
  39835. /**
  39836. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39837. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39838. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39839. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39840. */
  39841. export class VirtualJoysticksCamera extends FreeCamera {
  39842. /**
  39843. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39844. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39845. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39846. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39847. * @param name Define the name of the camera in the scene
  39848. * @param position Define the start position of the camera in the scene
  39849. * @param scene Define the scene the camera belongs to
  39850. */
  39851. constructor(name: string, position: Vector3, scene: Scene);
  39852. /**
  39853. * Gets the current object class name.
  39854. * @return the class name
  39855. */
  39856. getClassName(): string;
  39857. }
  39858. }
  39859. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39861. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39862. import { Scene } from "babylonjs/scene";
  39863. import { Vector3 } from "babylonjs/Maths/math";
  39864. /**
  39865. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39866. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39867. */
  39868. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39869. /**
  39870. * Creates a new VRDeviceOrientationArcRotateCamera
  39871. * @param name defines camera name
  39872. * @param alpha defines the camera rotation along the logitudinal axis
  39873. * @param beta defines the camera rotation along the latitudinal axis
  39874. * @param radius defines the camera distance from its target
  39875. * @param target defines the camera target
  39876. * @param scene defines the scene the camera belongs to
  39877. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39878. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39879. */
  39880. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39881. /**
  39882. * Gets camera class name
  39883. * @returns VRDeviceOrientationArcRotateCamera
  39884. */
  39885. getClassName(): string;
  39886. }
  39887. }
  39888. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39889. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39890. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39891. import { Scene } from "babylonjs/scene";
  39892. import { Vector3 } from "babylonjs/Maths/math";
  39893. /**
  39894. * Camera used to simulate VR rendering (based on FreeCamera)
  39895. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39896. */
  39897. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39898. /**
  39899. * Creates a new VRDeviceOrientationFreeCamera
  39900. * @param name defines camera name
  39901. * @param position defines the start position of the camera
  39902. * @param scene defines the scene the camera belongs to
  39903. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39904. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39905. */
  39906. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39907. /**
  39908. * Gets camera class name
  39909. * @returns VRDeviceOrientationFreeCamera
  39910. */
  39911. getClassName(): string;
  39912. }
  39913. }
  39914. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39915. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39916. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39917. import { Scene } from "babylonjs/scene";
  39918. import { Vector3 } from "babylonjs/Maths/math";
  39919. /**
  39920. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39921. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39922. */
  39923. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39924. /**
  39925. * Creates a new VRDeviceOrientationGamepadCamera
  39926. * @param name defines camera name
  39927. * @param position defines the start position of the camera
  39928. * @param scene defines the scene the camera belongs to
  39929. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39930. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39931. */
  39932. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39933. /**
  39934. * Gets camera class name
  39935. * @returns VRDeviceOrientationGamepadCamera
  39936. */
  39937. getClassName(): string;
  39938. }
  39939. }
  39940. declare module "babylonjs/Gamepads/xboxGamepad" {
  39941. import { Observable } from "babylonjs/Misc/observable";
  39942. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39943. /**
  39944. * Defines supported buttons for XBox360 compatible gamepads
  39945. */
  39946. export enum Xbox360Button {
  39947. /** A */
  39948. A = 0,
  39949. /** B */
  39950. B = 1,
  39951. /** X */
  39952. X = 2,
  39953. /** Y */
  39954. Y = 3,
  39955. /** Start */
  39956. Start = 4,
  39957. /** Back */
  39958. Back = 5,
  39959. /** Left button */
  39960. LB = 6,
  39961. /** Right button */
  39962. RB = 7,
  39963. /** Left stick */
  39964. LeftStick = 8,
  39965. /** Right stick */
  39966. RightStick = 9
  39967. }
  39968. /** Defines values for XBox360 DPad */
  39969. export enum Xbox360Dpad {
  39970. /** Up */
  39971. Up = 0,
  39972. /** Down */
  39973. Down = 1,
  39974. /** Left */
  39975. Left = 2,
  39976. /** Right */
  39977. Right = 3
  39978. }
  39979. /**
  39980. * Defines a XBox360 gamepad
  39981. */
  39982. export class Xbox360Pad extends Gamepad {
  39983. private _leftTrigger;
  39984. private _rightTrigger;
  39985. private _onlefttriggerchanged;
  39986. private _onrighttriggerchanged;
  39987. private _onbuttondown;
  39988. private _onbuttonup;
  39989. private _ondpaddown;
  39990. private _ondpadup;
  39991. /** Observable raised when a button is pressed */
  39992. onButtonDownObservable: Observable<Xbox360Button>;
  39993. /** Observable raised when a button is released */
  39994. onButtonUpObservable: Observable<Xbox360Button>;
  39995. /** Observable raised when a pad is pressed */
  39996. onPadDownObservable: Observable<Xbox360Dpad>;
  39997. /** Observable raised when a pad is released */
  39998. onPadUpObservable: Observable<Xbox360Dpad>;
  39999. private _buttonA;
  40000. private _buttonB;
  40001. private _buttonX;
  40002. private _buttonY;
  40003. private _buttonBack;
  40004. private _buttonStart;
  40005. private _buttonLB;
  40006. private _buttonRB;
  40007. private _buttonLeftStick;
  40008. private _buttonRightStick;
  40009. private _dPadUp;
  40010. private _dPadDown;
  40011. private _dPadLeft;
  40012. private _dPadRight;
  40013. private _isXboxOnePad;
  40014. /**
  40015. * Creates a new XBox360 gamepad object
  40016. * @param id defines the id of this gamepad
  40017. * @param index defines its index
  40018. * @param gamepad defines the internal HTML gamepad object
  40019. * @param xboxOne defines if it is a XBox One gamepad
  40020. */
  40021. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40022. /**
  40023. * Defines the callback to call when left trigger is pressed
  40024. * @param callback defines the callback to use
  40025. */
  40026. onlefttriggerchanged(callback: (value: number) => void): void;
  40027. /**
  40028. * Defines the callback to call when right trigger is pressed
  40029. * @param callback defines the callback to use
  40030. */
  40031. onrighttriggerchanged(callback: (value: number) => void): void;
  40032. /**
  40033. * Gets the left trigger value
  40034. */
  40035. /**
  40036. * Sets the left trigger value
  40037. */
  40038. leftTrigger: number;
  40039. /**
  40040. * Gets the right trigger value
  40041. */
  40042. /**
  40043. * Sets the right trigger value
  40044. */
  40045. rightTrigger: number;
  40046. /**
  40047. * Defines the callback to call when a button is pressed
  40048. * @param callback defines the callback to use
  40049. */
  40050. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40051. /**
  40052. * Defines the callback to call when a button is released
  40053. * @param callback defines the callback to use
  40054. */
  40055. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40056. /**
  40057. * Defines the callback to call when a pad is pressed
  40058. * @param callback defines the callback to use
  40059. */
  40060. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40061. /**
  40062. * Defines the callback to call when a pad is released
  40063. * @param callback defines the callback to use
  40064. */
  40065. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40066. private _setButtonValue;
  40067. private _setDPadValue;
  40068. /**
  40069. * Gets the value of the `A` button
  40070. */
  40071. /**
  40072. * Sets the value of the `A` button
  40073. */
  40074. buttonA: number;
  40075. /**
  40076. * Gets the value of the `B` button
  40077. */
  40078. /**
  40079. * Sets the value of the `B` button
  40080. */
  40081. buttonB: number;
  40082. /**
  40083. * Gets the value of the `X` button
  40084. */
  40085. /**
  40086. * Sets the value of the `X` button
  40087. */
  40088. buttonX: number;
  40089. /**
  40090. * Gets the value of the `Y` button
  40091. */
  40092. /**
  40093. * Sets the value of the `Y` button
  40094. */
  40095. buttonY: number;
  40096. /**
  40097. * Gets the value of the `Start` button
  40098. */
  40099. /**
  40100. * Sets the value of the `Start` button
  40101. */
  40102. buttonStart: number;
  40103. /**
  40104. * Gets the value of the `Back` button
  40105. */
  40106. /**
  40107. * Sets the value of the `Back` button
  40108. */
  40109. buttonBack: number;
  40110. /**
  40111. * Gets the value of the `Left` button
  40112. */
  40113. /**
  40114. * Sets the value of the `Left` button
  40115. */
  40116. buttonLB: number;
  40117. /**
  40118. * Gets the value of the `Right` button
  40119. */
  40120. /**
  40121. * Sets the value of the `Right` button
  40122. */
  40123. buttonRB: number;
  40124. /**
  40125. * Gets the value of the Left joystick
  40126. */
  40127. /**
  40128. * Sets the value of the Left joystick
  40129. */
  40130. buttonLeftStick: number;
  40131. /**
  40132. * Gets the value of the Right joystick
  40133. */
  40134. /**
  40135. * Sets the value of the Right joystick
  40136. */
  40137. buttonRightStick: number;
  40138. /**
  40139. * Gets the value of D-pad up
  40140. */
  40141. /**
  40142. * Sets the value of D-pad up
  40143. */
  40144. dPadUp: number;
  40145. /**
  40146. * Gets the value of D-pad down
  40147. */
  40148. /**
  40149. * Sets the value of D-pad down
  40150. */
  40151. dPadDown: number;
  40152. /**
  40153. * Gets the value of D-pad left
  40154. */
  40155. /**
  40156. * Sets the value of D-pad left
  40157. */
  40158. dPadLeft: number;
  40159. /**
  40160. * Gets the value of D-pad right
  40161. */
  40162. /**
  40163. * Sets the value of D-pad right
  40164. */
  40165. dPadRight: number;
  40166. /**
  40167. * Force the gamepad to synchronize with device values
  40168. */
  40169. update(): void;
  40170. /**
  40171. * Disposes the gamepad
  40172. */
  40173. dispose(): void;
  40174. }
  40175. }
  40176. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40177. import { Scene } from "babylonjs/scene";
  40178. import { Texture } from "babylonjs/Materials/Textures/texture";
  40179. /**
  40180. * A class extending Texture allowing drawing on a texture
  40181. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40182. */
  40183. export class DynamicTexture extends Texture {
  40184. private _generateMipMaps;
  40185. private _canvas;
  40186. private _context;
  40187. private _engine;
  40188. /**
  40189. * Creates a DynamicTexture
  40190. * @param name defines the name of the texture
  40191. * @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
  40192. * @param scene defines the scene where you want the texture
  40193. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40194. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40195. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40196. */
  40197. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40198. /**
  40199. * Get the current class name of the texture useful for serialization or dynamic coding.
  40200. * @returns "DynamicTexture"
  40201. */
  40202. getClassName(): string;
  40203. /**
  40204. * Gets the current state of canRescale
  40205. */
  40206. readonly canRescale: boolean;
  40207. private _recreate;
  40208. /**
  40209. * Scales the texture
  40210. * @param ratio the scale factor to apply to both width and height
  40211. */
  40212. scale(ratio: number): void;
  40213. /**
  40214. * Resizes the texture
  40215. * @param width the new width
  40216. * @param height the new height
  40217. */
  40218. scaleTo(width: number, height: number): void;
  40219. /**
  40220. * Gets the context of the canvas used by the texture
  40221. * @returns the canvas context of the dynamic texture
  40222. */
  40223. getContext(): CanvasRenderingContext2D;
  40224. /**
  40225. * Clears the texture
  40226. */
  40227. clear(): void;
  40228. /**
  40229. * Updates the texture
  40230. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40231. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40232. */
  40233. update(invertY?: boolean, premulAlpha?: boolean): void;
  40234. /**
  40235. * Draws text onto the texture
  40236. * @param text defines the text to be drawn
  40237. * @param x defines the placement of the text from the left
  40238. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40239. * @param font defines the font to be used with font-style, font-size, font-name
  40240. * @param color defines the color used for the text
  40241. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40242. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40243. * @param update defines whether texture is immediately update (default is true)
  40244. */
  40245. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40246. /**
  40247. * Clones the texture
  40248. * @returns the clone of the texture.
  40249. */
  40250. clone(): DynamicTexture;
  40251. /**
  40252. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40253. * @returns a serialized dynamic texture object
  40254. */
  40255. serialize(): any;
  40256. /** @hidden */
  40257. _rebuild(): void;
  40258. }
  40259. }
  40260. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40261. import "Shaders/ShadersInclude/imageProcessingDeclaration";
  40262. import "Shaders/ShadersInclude/helperFunctions";
  40263. import "Shaders/ShadersInclude/imageProcessingFunctions";
  40264. export var imageProcessingPixelShader: {
  40265. name: string;
  40266. shader: string;
  40267. };
  40268. }
  40269. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40270. import { Nullable } from "babylonjs/types";
  40271. import { Color4 } from "babylonjs/Maths/math";
  40272. import { Camera } from "babylonjs/Cameras/camera";
  40273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40274. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40275. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40277. import { Engine } from "babylonjs/Engines/engine";
  40278. import "Shaders/imageProcessing.fragment";
  40279. import "Shaders/postprocess.vertex";
  40280. /**
  40281. * ImageProcessingPostProcess
  40282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40283. */
  40284. export class ImageProcessingPostProcess extends PostProcess {
  40285. /**
  40286. * Default configuration related to image processing available in the PBR Material.
  40287. */
  40288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40289. /**
  40290. * Gets the image processing configuration used either in this material.
  40291. */
  40292. /**
  40293. * Sets the Default image processing configuration used either in the this material.
  40294. *
  40295. * If sets to null, the scene one is in use.
  40296. */
  40297. imageProcessingConfiguration: ImageProcessingConfiguration;
  40298. /**
  40299. * Keep track of the image processing observer to allow dispose and replace.
  40300. */
  40301. private _imageProcessingObserver;
  40302. /**
  40303. * Attaches a new image processing configuration to the PBR Material.
  40304. * @param configuration
  40305. */
  40306. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40307. /**
  40308. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40309. */
  40310. /**
  40311. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40312. */
  40313. colorCurves: Nullable<ColorCurves>;
  40314. /**
  40315. * Gets wether the color curves effect is enabled.
  40316. */
  40317. /**
  40318. * Sets wether the color curves effect is enabled.
  40319. */
  40320. colorCurvesEnabled: boolean;
  40321. /**
  40322. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40323. */
  40324. /**
  40325. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40326. */
  40327. colorGradingTexture: Nullable<BaseTexture>;
  40328. /**
  40329. * Gets wether the color grading effect is enabled.
  40330. */
  40331. /**
  40332. * Gets wether the color grading effect is enabled.
  40333. */
  40334. colorGradingEnabled: boolean;
  40335. /**
  40336. * Gets exposure used in the effect.
  40337. */
  40338. /**
  40339. * Sets exposure used in the effect.
  40340. */
  40341. exposure: number;
  40342. /**
  40343. * Gets wether tonemapping is enabled or not.
  40344. */
  40345. /**
  40346. * Sets wether tonemapping is enabled or not
  40347. */
  40348. toneMappingEnabled: boolean;
  40349. /**
  40350. * Gets contrast used in the effect.
  40351. */
  40352. /**
  40353. * Sets contrast used in the effect.
  40354. */
  40355. contrast: number;
  40356. /**
  40357. * Gets Vignette stretch size.
  40358. */
  40359. /**
  40360. * Sets Vignette stretch size.
  40361. */
  40362. vignetteStretch: number;
  40363. /**
  40364. * Gets Vignette centre X Offset.
  40365. */
  40366. /**
  40367. * Sets Vignette centre X Offset.
  40368. */
  40369. vignetteCentreX: number;
  40370. /**
  40371. * Gets Vignette centre Y Offset.
  40372. */
  40373. /**
  40374. * Sets Vignette centre Y Offset.
  40375. */
  40376. vignetteCentreY: number;
  40377. /**
  40378. * Gets Vignette weight or intensity of the vignette effect.
  40379. */
  40380. /**
  40381. * Sets Vignette weight or intensity of the vignette effect.
  40382. */
  40383. vignetteWeight: number;
  40384. /**
  40385. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40386. * if vignetteEnabled is set to true.
  40387. */
  40388. /**
  40389. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40390. * if vignetteEnabled is set to true.
  40391. */
  40392. vignetteColor: Color4;
  40393. /**
  40394. * Gets Camera field of view used by the Vignette effect.
  40395. */
  40396. /**
  40397. * Sets Camera field of view used by the Vignette effect.
  40398. */
  40399. vignetteCameraFov: number;
  40400. /**
  40401. * Gets the vignette blend mode allowing different kind of effect.
  40402. */
  40403. /**
  40404. * Sets the vignette blend mode allowing different kind of effect.
  40405. */
  40406. vignetteBlendMode: number;
  40407. /**
  40408. * Gets wether the vignette effect is enabled.
  40409. */
  40410. /**
  40411. * Sets wether the vignette effect is enabled.
  40412. */
  40413. vignetteEnabled: boolean;
  40414. private _fromLinearSpace;
  40415. /**
  40416. * Gets wether the input of the processing is in Gamma or Linear Space.
  40417. */
  40418. /**
  40419. * Sets wether the input of the processing is in Gamma or Linear Space.
  40420. */
  40421. fromLinearSpace: boolean;
  40422. /**
  40423. * Defines cache preventing GC.
  40424. */
  40425. private _defines;
  40426. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40427. /**
  40428. * "ImageProcessingPostProcess"
  40429. * @returns "ImageProcessingPostProcess"
  40430. */
  40431. getClassName(): string;
  40432. protected _updateParameters(): void;
  40433. dispose(camera?: Camera): void;
  40434. }
  40435. }
  40436. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40437. import { Observable } from "babylonjs/Misc/observable";
  40438. import { Nullable } from "babylonjs/types";
  40439. import { Camera } from "babylonjs/Cameras/camera";
  40440. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40441. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40442. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40443. import { Scene } from "babylonjs/scene";
  40444. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40445. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40447. import { Mesh } from "babylonjs/Meshes/mesh";
  40448. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40449. /**
  40450. * Options to modify the vr teleportation behavior.
  40451. */
  40452. export interface VRTeleportationOptions {
  40453. /**
  40454. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40455. */
  40456. floorMeshName?: string;
  40457. /**
  40458. * A list of meshes to be used as the teleportation floor. (default: empty)
  40459. */
  40460. floorMeshes?: Mesh[];
  40461. }
  40462. /**
  40463. * Options to modify the vr experience helper's behavior.
  40464. */
  40465. export interface VRExperienceHelperOptions extends WebVROptions {
  40466. /**
  40467. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40468. */
  40469. createDeviceOrientationCamera?: boolean;
  40470. /**
  40471. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40472. */
  40473. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40474. /**
  40475. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40476. */
  40477. laserToggle?: boolean;
  40478. /**
  40479. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40480. */
  40481. floorMeshes?: Mesh[];
  40482. }
  40483. /**
  40484. * Helps to quickly add VR support to an existing scene.
  40485. * See http://doc.babylonjs.com/how_to/webvr_helper
  40486. */
  40487. export class VRExperienceHelper {
  40488. /** Options to modify the vr experience helper's behavior. */
  40489. webVROptions: VRExperienceHelperOptions;
  40490. private _scene;
  40491. private _position;
  40492. private _btnVR;
  40493. private _btnVRDisplayed;
  40494. private _webVRsupported;
  40495. private _webVRready;
  40496. private _webVRrequesting;
  40497. private _webVRpresenting;
  40498. private _hasEnteredVR;
  40499. private _fullscreenVRpresenting;
  40500. private _canvas;
  40501. private _webVRCamera;
  40502. private _vrDeviceOrientationCamera;
  40503. private _deviceOrientationCamera;
  40504. private _existingCamera;
  40505. private _onKeyDown;
  40506. private _onVrDisplayPresentChange;
  40507. private _onVRDisplayChanged;
  40508. private _onVRRequestPresentStart;
  40509. private _onVRRequestPresentComplete;
  40510. /**
  40511. * Observable raised when entering VR.
  40512. */
  40513. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40514. /**
  40515. * Observable raised when exiting VR.
  40516. */
  40517. onExitingVRObservable: Observable<VRExperienceHelper>;
  40518. /**
  40519. * Observable raised when controller mesh is loaded.
  40520. */
  40521. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40522. /** Return this.onEnteringVRObservable
  40523. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40524. */
  40525. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40526. /** Return this.onExitingVRObservable
  40527. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40528. */
  40529. readonly onExitingVR: Observable<VRExperienceHelper>;
  40530. /** Return this.onControllerMeshLoadedObservable
  40531. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40532. */
  40533. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40534. private _rayLength;
  40535. private _useCustomVRButton;
  40536. private _teleportationRequested;
  40537. private _teleportActive;
  40538. private _floorMeshName;
  40539. private _floorMeshesCollection;
  40540. private _rotationAllowed;
  40541. private _teleportBackwardsVector;
  40542. private _teleportationTarget;
  40543. private _isDefaultTeleportationTarget;
  40544. private _postProcessMove;
  40545. private _teleportationFillColor;
  40546. private _teleportationBorderColor;
  40547. private _rotationAngle;
  40548. private _haloCenter;
  40549. private _cameraGazer;
  40550. private _padSensibilityUp;
  40551. private _padSensibilityDown;
  40552. private _leftController;
  40553. private _rightController;
  40554. /**
  40555. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40556. */
  40557. onNewMeshSelected: Observable<AbstractMesh>;
  40558. /**
  40559. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40560. */
  40561. onNewMeshPicked: Observable<PickingInfo>;
  40562. private _circleEase;
  40563. /**
  40564. * Observable raised before camera teleportation
  40565. */
  40566. onBeforeCameraTeleport: Observable<Vector3>;
  40567. /**
  40568. * Observable raised after camera teleportation
  40569. */
  40570. onAfterCameraTeleport: Observable<Vector3>;
  40571. /**
  40572. * Observable raised when current selected mesh gets unselected
  40573. */
  40574. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40575. private _raySelectionPredicate;
  40576. /**
  40577. * To be optionaly changed by user to define custom ray selection
  40578. */
  40579. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40580. /**
  40581. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40582. */
  40583. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40584. /**
  40585. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40586. */
  40587. teleportationEnabled: boolean;
  40588. private _defaultHeight;
  40589. private _teleportationInitialized;
  40590. private _interactionsEnabled;
  40591. private _interactionsRequested;
  40592. private _displayGaze;
  40593. private _displayLaserPointer;
  40594. /**
  40595. * The mesh used to display where the user is going to teleport.
  40596. */
  40597. /**
  40598. * Sets the mesh to be used to display where the user is going to teleport.
  40599. */
  40600. teleportationTarget: Mesh;
  40601. /**
  40602. * 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
  40603. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40604. * See http://doc.babylonjs.com/resources/baking_transformations
  40605. */
  40606. gazeTrackerMesh: Mesh;
  40607. /**
  40608. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40609. */
  40610. updateGazeTrackerScale: boolean;
  40611. /**
  40612. * The gaze tracking mesh corresponding to the left controller
  40613. */
  40614. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40615. /**
  40616. * The gaze tracking mesh corresponding to the right controller
  40617. */
  40618. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40619. /**
  40620. * If the ray of the gaze should be displayed.
  40621. */
  40622. /**
  40623. * Sets if the ray of the gaze should be displayed.
  40624. */
  40625. displayGaze: boolean;
  40626. /**
  40627. * If the ray of the LaserPointer should be displayed.
  40628. */
  40629. /**
  40630. * Sets if the ray of the LaserPointer should be displayed.
  40631. */
  40632. displayLaserPointer: boolean;
  40633. /**
  40634. * The deviceOrientationCamera used as the camera when not in VR.
  40635. */
  40636. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40637. /**
  40638. * Based on the current WebVR support, returns the current VR camera used.
  40639. */
  40640. readonly currentVRCamera: Nullable<Camera>;
  40641. /**
  40642. * The webVRCamera which is used when in VR.
  40643. */
  40644. readonly webVRCamera: WebVRFreeCamera;
  40645. /**
  40646. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40647. */
  40648. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40649. private readonly _teleportationRequestInitiated;
  40650. /**
  40651. * Instantiates a VRExperienceHelper.
  40652. * Helps to quickly add VR support to an existing scene.
  40653. * @param scene The scene the VRExperienceHelper belongs to.
  40654. * @param webVROptions Options to modify the vr experience helper's behavior.
  40655. */
  40656. constructor(scene: Scene,
  40657. /** Options to modify the vr experience helper's behavior. */
  40658. webVROptions?: VRExperienceHelperOptions);
  40659. private _onDefaultMeshLoaded;
  40660. private _onResize;
  40661. private _onFullscreenChange;
  40662. /**
  40663. * Gets a value indicating if we are currently in VR mode.
  40664. */
  40665. readonly isInVRMode: boolean;
  40666. private onVrDisplayPresentChange;
  40667. private onVRDisplayChanged;
  40668. private moveButtonToBottomRight;
  40669. private displayVRButton;
  40670. private updateButtonVisibility;
  40671. private _cachedAngularSensibility;
  40672. /**
  40673. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40674. * Otherwise, will use the fullscreen API.
  40675. */
  40676. enterVR(): void;
  40677. /**
  40678. * Attempt to exit VR, or fullscreen.
  40679. */
  40680. exitVR(): void;
  40681. /**
  40682. * The position of the vr experience helper.
  40683. */
  40684. /**
  40685. * Sets the position of the vr experience helper.
  40686. */
  40687. position: Vector3;
  40688. /**
  40689. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40690. */
  40691. enableInteractions(): void;
  40692. private readonly _noControllerIsActive;
  40693. private beforeRender;
  40694. private _isTeleportationFloor;
  40695. /**
  40696. * Adds a floor mesh to be used for teleportation.
  40697. * @param floorMesh the mesh to be used for teleportation.
  40698. */
  40699. addFloorMesh(floorMesh: Mesh): void;
  40700. /**
  40701. * Removes a floor mesh from being used for teleportation.
  40702. * @param floorMesh the mesh to be removed.
  40703. */
  40704. removeFloorMesh(floorMesh: Mesh): void;
  40705. /**
  40706. * Enables interactions and teleportation using the VR controllers and gaze.
  40707. * @param vrTeleportationOptions options to modify teleportation behavior.
  40708. */
  40709. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40710. private _onNewGamepadConnected;
  40711. private _tryEnableInteractionOnController;
  40712. private _onNewGamepadDisconnected;
  40713. private _enableInteractionOnController;
  40714. private _checkTeleportWithRay;
  40715. private _checkRotate;
  40716. private _checkTeleportBackwards;
  40717. private _enableTeleportationOnController;
  40718. private _createTeleportationCircles;
  40719. private _displayTeleportationTarget;
  40720. private _hideTeleportationTarget;
  40721. private _rotateCamera;
  40722. private _moveTeleportationSelectorTo;
  40723. private _workingVector;
  40724. private _workingQuaternion;
  40725. private _workingMatrix;
  40726. /**
  40727. * Teleports the users feet to the desired location
  40728. * @param location The location where the user's feet should be placed
  40729. */
  40730. teleportCamera(location: Vector3): void;
  40731. private _convertNormalToDirectionOfRay;
  40732. private _castRayAndSelectObject;
  40733. private _notifySelectedMeshUnselected;
  40734. /**
  40735. * Sets the color of the laser ray from the vr controllers.
  40736. * @param color new color for the ray.
  40737. */
  40738. changeLaserColor(color: Color3): void;
  40739. /**
  40740. * Sets the color of the ray from the vr headsets gaze.
  40741. * @param color new color for the ray.
  40742. */
  40743. changeGazeColor(color: Color3): void;
  40744. /**
  40745. * Exits VR and disposes of the vr experience helper
  40746. */
  40747. dispose(): void;
  40748. /**
  40749. * Gets the name of the VRExperienceHelper class
  40750. * @returns "VRExperienceHelper"
  40751. */
  40752. getClassName(): string;
  40753. }
  40754. }
  40755. declare module "babylonjs/Cameras/VR/index" {
  40756. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40757. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40758. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40759. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40760. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40761. export * from "babylonjs/Cameras/VR/webVRCamera";
  40762. }
  40763. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40764. import { Observable } from "babylonjs/Misc/observable";
  40765. import { Nullable } from "babylonjs/types";
  40766. import { IDisposable, Scene } from "babylonjs/scene";
  40767. import { Vector3 } from "babylonjs/Maths/math";
  40768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40769. import { Ray } from "babylonjs/Culling/ray";
  40770. /**
  40771. * Manages an XRSession
  40772. * @see https://doc.babylonjs.com/how_to/webxr
  40773. */
  40774. export class WebXRSessionManager implements IDisposable {
  40775. private scene;
  40776. /**
  40777. * Fires every time a new xrFrame arrives which can be used to update the camera
  40778. */
  40779. onXRFrameObservable: Observable<any>;
  40780. /**
  40781. * Fires when the xr session is ended either by the device or manually done
  40782. */
  40783. onXRSessionEnded: Observable<any>;
  40784. /** @hidden */
  40785. _xrSession: XRSession;
  40786. /** @hidden */
  40787. _frameOfReference: XRFrameOfReference;
  40788. /** @hidden */
  40789. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40790. /** @hidden */
  40791. _currentXRFrame: Nullable<XRFrame>;
  40792. private _xrNavigator;
  40793. private _xrDevice;
  40794. private _tmpMatrix;
  40795. /**
  40796. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40797. * @param scene The scene which the session should be created for
  40798. */
  40799. constructor(scene: Scene);
  40800. /**
  40801. * Initializes the manager
  40802. * After initialization enterXR can be called to start an XR session
  40803. * @returns Promise which resolves after it is initialized
  40804. */
  40805. initializeAsync(): Promise<void>;
  40806. /**
  40807. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40808. * @param sessionCreationOptions xr options to create the session with
  40809. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40810. * @returns Promise which resolves after it enters XR
  40811. */
  40812. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40813. /**
  40814. * Stops the xrSession and restores the renderloop
  40815. * @returns Promise which resolves after it exits XR
  40816. */
  40817. exitXRAsync(): Promise<void>;
  40818. /**
  40819. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40820. * @param ray ray to cast into the environment
  40821. * @returns Promise which resolves with a collision point in the environment if it exists
  40822. */
  40823. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40824. /**
  40825. * Checks if a session would be supported for the creation options specified
  40826. * @param options creation options to check if they are supported
  40827. * @returns true if supported
  40828. */
  40829. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40830. /**
  40831. * @hidden
  40832. * Converts the render layer of xrSession to a render target
  40833. * @param session session to create render target for
  40834. * @param scene scene the new render target should be created for
  40835. */
  40836. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40837. /**
  40838. * Disposes of the session manager
  40839. */
  40840. dispose(): void;
  40841. }
  40842. }
  40843. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40844. import { Scene } from "babylonjs/scene";
  40845. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40846. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40847. /**
  40848. * WebXR Camera which holds the views for the xrSession
  40849. * @see https://doc.babylonjs.com/how_to/webxr
  40850. */
  40851. export class WebXRCamera extends FreeCamera {
  40852. private static _TmpMatrix;
  40853. /**
  40854. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40855. * @param name the name of the camera
  40856. * @param scene the scene to add the camera to
  40857. */
  40858. constructor(name: string, scene: Scene);
  40859. private _updateNumberOfRigCameras;
  40860. /** @hidden */
  40861. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40862. /**
  40863. * Updates the cameras position from the current pose information of the XR session
  40864. * @param xrSessionManager the session containing pose information
  40865. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40866. */
  40867. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40868. }
  40869. }
  40870. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40871. import { Nullable } from "babylonjs/types";
  40872. import { Observable } from "babylonjs/Misc/observable";
  40873. import { IDisposable, Scene } from "babylonjs/scene";
  40874. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40876. import { Ray } from "babylonjs/Culling/ray";
  40877. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40878. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40879. /**
  40880. * States of the webXR experience
  40881. */
  40882. export enum WebXRState {
  40883. /**
  40884. * Transitioning to being in XR mode
  40885. */
  40886. ENTERING_XR = 0,
  40887. /**
  40888. * Transitioning to non XR mode
  40889. */
  40890. EXITING_XR = 1,
  40891. /**
  40892. * In XR mode and presenting
  40893. */
  40894. IN_XR = 2,
  40895. /**
  40896. * Not entered XR mode
  40897. */
  40898. NOT_IN_XR = 3
  40899. }
  40900. /**
  40901. * Helper class used to enable XR
  40902. * @see https://doc.babylonjs.com/how_to/webxr
  40903. */
  40904. export class WebXRExperienceHelper implements IDisposable {
  40905. private scene;
  40906. /**
  40907. * 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
  40908. */
  40909. container: AbstractMesh;
  40910. /**
  40911. * Camera used to render xr content
  40912. */
  40913. camera: WebXRCamera;
  40914. /**
  40915. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40916. */
  40917. state: WebXRState;
  40918. private _setState;
  40919. private static _TmpVector;
  40920. /**
  40921. * Fires when the state of the experience helper has changed
  40922. */
  40923. onStateChangedObservable: Observable<WebXRState>;
  40924. /** @hidden */
  40925. _sessionManager: WebXRSessionManager;
  40926. private _nonVRCamera;
  40927. private _originalSceneAutoClear;
  40928. private _supported;
  40929. /**
  40930. * Creates the experience helper
  40931. * @param scene the scene to attach the experience helper to
  40932. * @returns a promise for the experience helper
  40933. */
  40934. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40935. /**
  40936. * Creates a WebXRExperienceHelper
  40937. * @param scene The scene the helper should be created in
  40938. */
  40939. private constructor();
  40940. /**
  40941. * Exits XR mode and returns the scene to its original state
  40942. * @returns promise that resolves after xr mode has exited
  40943. */
  40944. exitXRAsync(): Promise<void>;
  40945. /**
  40946. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40947. * @param sessionCreationOptions options for the XR session
  40948. * @param frameOfReference frame of reference of the XR session
  40949. * @returns promise that resolves after xr mode has entered
  40950. */
  40951. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40952. /**
  40953. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40954. * @param ray ray to cast into the environment
  40955. * @returns Promise which resolves with a collision point in the environment if it exists
  40956. */
  40957. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40958. /**
  40959. * Updates the global position of the camera by moving the camera's container
  40960. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40961. * @param position The desired global position of the camera
  40962. */
  40963. setPositionOfCameraUsingContainer(position: Vector3): void;
  40964. /**
  40965. * Rotates the xr camera by rotating the camera's container around the camera's position
  40966. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40967. * @param rotation the desired quaternion rotation to apply to the camera
  40968. */
  40969. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40970. /**
  40971. * Checks if the creation options are supported by the xr session
  40972. * @param options creation options
  40973. * @returns true if supported
  40974. */
  40975. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40976. /**
  40977. * Disposes of the experience helper
  40978. */
  40979. dispose(): void;
  40980. }
  40981. }
  40982. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40983. import { Nullable } from "babylonjs/types";
  40984. import { Observable } from "babylonjs/Misc/observable";
  40985. import { IDisposable, Scene } from "babylonjs/scene";
  40986. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40987. /**
  40988. * Button which can be used to enter a different mode of XR
  40989. */
  40990. export class WebXREnterExitUIButton {
  40991. /** button element */
  40992. element: HTMLElement;
  40993. /** XR initialization options for the button */
  40994. initializationOptions: XRSessionCreationOptions;
  40995. /**
  40996. * Creates a WebXREnterExitUIButton
  40997. * @param element button element
  40998. * @param initializationOptions XR initialization options for the button
  40999. */
  41000. constructor(
  41001. /** button element */
  41002. element: HTMLElement,
  41003. /** XR initialization options for the button */
  41004. initializationOptions: XRSessionCreationOptions);
  41005. /**
  41006. * Overwritable function which can be used to update the button's visuals when the state changes
  41007. * @param activeButton the current active button in the UI
  41008. */
  41009. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41010. }
  41011. /**
  41012. * Options to create the webXR UI
  41013. */
  41014. export class WebXREnterExitUIOptions {
  41015. /**
  41016. * Context to enter xr with
  41017. */
  41018. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41019. /**
  41020. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41021. */
  41022. customButtons?: Array<WebXREnterExitUIButton>;
  41023. }
  41024. /**
  41025. * UI to allow the user to enter/exit XR mode
  41026. */
  41027. export class WebXREnterExitUI implements IDisposable {
  41028. private scene;
  41029. private _overlay;
  41030. private _buttons;
  41031. private _activeButton;
  41032. /**
  41033. * Fired every time the active button is changed.
  41034. *
  41035. * When xr is entered via a button that launches xr that button will be the callback parameter
  41036. *
  41037. * When exiting xr the callback parameter will be null)
  41038. */
  41039. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41040. /**
  41041. * Creates UI to allow the user to enter/exit XR mode
  41042. * @param scene the scene to add the ui to
  41043. * @param helper the xr experience helper to enter/exit xr with
  41044. * @param options options to configure the UI
  41045. * @returns the created ui
  41046. */
  41047. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41048. private constructor();
  41049. private _updateButtons;
  41050. /**
  41051. * Disposes of the object
  41052. */
  41053. dispose(): void;
  41054. }
  41055. }
  41056. declare module "babylonjs/Cameras/XR/webXRInput" {
  41057. import { IDisposable, Scene } from "babylonjs/scene";
  41058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41059. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41060. /**
  41061. * Represents an XR input
  41062. */
  41063. export class WebXRController {
  41064. /**
  41065. * 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
  41066. */
  41067. grip?: AbstractMesh;
  41068. /**
  41069. * Pointer which can be used to select objects or attach a visible laser to
  41070. */
  41071. pointer: AbstractMesh;
  41072. /**
  41073. * Creates the controller
  41074. * @see https://doc.babylonjs.com/how_to/webxr
  41075. * @param scene the scene which the controller should be associated to
  41076. */
  41077. constructor(scene: Scene);
  41078. /**
  41079. * Disposes of the object
  41080. */
  41081. dispose(): void;
  41082. }
  41083. /**
  41084. * XR input used to track XR inputs such as controllers/rays
  41085. */
  41086. export class WebXRInput implements IDisposable {
  41087. private helper;
  41088. /**
  41089. * XR controllers being tracked
  41090. */
  41091. controllers: Array<WebXRController>;
  41092. private _tmpMatrix;
  41093. private _frameObserver;
  41094. /**
  41095. * Initializes the WebXRInput
  41096. * @param helper experience helper which the input should be created for
  41097. */
  41098. constructor(helper: WebXRExperienceHelper);
  41099. /**
  41100. * Disposes of the object
  41101. */
  41102. dispose(): void;
  41103. }
  41104. }
  41105. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41106. import { Nullable } from "babylonjs/types";
  41107. import { IDisposable } from "babylonjs/scene";
  41108. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41109. /**
  41110. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41111. */
  41112. export class WebXRManagedOutputCanvas implements IDisposable {
  41113. private _canvas;
  41114. /**
  41115. * xrpresent context of the canvas which can be used to display/mirror xr content
  41116. */
  41117. canvasContext: Nullable<WebGLRenderingContext>;
  41118. /**
  41119. * Initializes the canvas to be added/removed upon entering/exiting xr
  41120. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41121. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41122. */
  41123. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41124. /**
  41125. * Disposes of the object
  41126. */
  41127. dispose(): void;
  41128. private _setManagedOutputCanvas;
  41129. private _addCanvas;
  41130. private _removeCanvas;
  41131. }
  41132. }
  41133. declare module "babylonjs/Cameras/XR/index" {
  41134. export * from "babylonjs/Cameras/XR/webXRCamera";
  41135. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41136. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41137. export * from "babylonjs/Cameras/XR/webXRInput";
  41138. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41139. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41140. }
  41141. declare module "babylonjs/Cameras/index" {
  41142. export * from "babylonjs/Cameras/Inputs/index";
  41143. export * from "babylonjs/Cameras/cameraInputsManager";
  41144. export * from "babylonjs/Cameras/camera";
  41145. export * from "babylonjs/Cameras/targetCamera";
  41146. export * from "babylonjs/Cameras/freeCamera";
  41147. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41148. export * from "babylonjs/Cameras/touchCamera";
  41149. export * from "babylonjs/Cameras/arcRotateCamera";
  41150. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41151. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41152. export * from "babylonjs/Cameras/flyCamera";
  41153. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41154. export * from "babylonjs/Cameras/followCamera";
  41155. export * from "babylonjs/Cameras/gamepadCamera";
  41156. export * from "babylonjs/Cameras/Stereoscopic/index";
  41157. export * from "babylonjs/Cameras/universalCamera";
  41158. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41159. export * from "babylonjs/Cameras/VR/index";
  41160. export * from "babylonjs/Cameras/XR/index";
  41161. }
  41162. declare module "babylonjs/Collisions/index" {
  41163. export * from "babylonjs/Collisions/collider";
  41164. export * from "babylonjs/Collisions/collisionCoordinator";
  41165. export * from "babylonjs/Collisions/pickingInfo";
  41166. }
  41167. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41168. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41169. import { Vector3, Plane } from "babylonjs/Maths/math";
  41170. import { Ray } from "babylonjs/Culling/ray";
  41171. /**
  41172. * Class used to store a cell in an octree
  41173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41174. */
  41175. export class OctreeBlock<T> {
  41176. /**
  41177. * Gets the content of the current block
  41178. */
  41179. entries: T[];
  41180. /**
  41181. * Gets the list of block children
  41182. */
  41183. blocks: Array<OctreeBlock<T>>;
  41184. private _depth;
  41185. private _maxDepth;
  41186. private _capacity;
  41187. private _minPoint;
  41188. private _maxPoint;
  41189. private _boundingVectors;
  41190. private _creationFunc;
  41191. /**
  41192. * Creates a new block
  41193. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41194. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41195. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41196. * @param depth defines the current depth of this block in the octree
  41197. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41198. * @param creationFunc defines a callback to call when an element is added to the block
  41199. */
  41200. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41201. /**
  41202. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41203. */
  41204. readonly capacity: number;
  41205. /**
  41206. * Gets the minimum vector (in world space) of the block's bounding box
  41207. */
  41208. readonly minPoint: Vector3;
  41209. /**
  41210. * Gets the maximum vector (in world space) of the block's bounding box
  41211. */
  41212. readonly maxPoint: Vector3;
  41213. /**
  41214. * Add a new element to this block
  41215. * @param entry defines the element to add
  41216. */
  41217. addEntry(entry: T): void;
  41218. /**
  41219. * Add an array of elements to this block
  41220. * @param entries defines the array of elements to add
  41221. */
  41222. addEntries(entries: T[]): void;
  41223. /**
  41224. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41225. * @param frustumPlanes defines the frustum planes to test
  41226. * @param selection defines the array to store current content if selection is positive
  41227. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41228. */
  41229. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41230. /**
  41231. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41232. * @param sphereCenter defines the bounding sphere center
  41233. * @param sphereRadius defines the bounding sphere radius
  41234. * @param selection defines the array to store current content if selection is positive
  41235. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41236. */
  41237. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41238. /**
  41239. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41240. * @param ray defines the ray to test with
  41241. * @param selection defines the array to store current content if selection is positive
  41242. */
  41243. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41244. /**
  41245. * Subdivide the content into child blocks (this block will then be empty)
  41246. */
  41247. createInnerBlocks(): void;
  41248. }
  41249. }
  41250. declare module "babylonjs/Culling/Octrees/octree" {
  41251. import { SmartArray } from "babylonjs/Misc/smartArray";
  41252. import { Vector3, Plane } from "babylonjs/Maths/math";
  41253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41255. import { Ray } from "babylonjs/Culling/ray";
  41256. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41257. /**
  41258. * Contains an array of blocks representing the octree
  41259. */
  41260. export interface IOctreeContainer<T> {
  41261. /**
  41262. * Blocks within the octree
  41263. */
  41264. blocks: Array<OctreeBlock<T>>;
  41265. }
  41266. /**
  41267. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41268. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41269. */
  41270. export class Octree<T> {
  41271. /** 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.) */
  41272. maxDepth: number;
  41273. /**
  41274. * Blocks within the octree containing objects
  41275. */
  41276. blocks: Array<OctreeBlock<T>>;
  41277. /**
  41278. * Content stored in the octree
  41279. */
  41280. dynamicContent: T[];
  41281. private _maxBlockCapacity;
  41282. private _selectionContent;
  41283. private _creationFunc;
  41284. /**
  41285. * Creates a octree
  41286. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41287. * @param creationFunc function to be used to instatiate the octree
  41288. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41289. * @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.)
  41290. */
  41291. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41292. /** 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.) */
  41293. maxDepth?: number);
  41294. /**
  41295. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41296. * @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);
  41297. * @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);
  41298. * @param entries meshes to be added to the octree blocks
  41299. */
  41300. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41301. /**
  41302. * Adds a mesh to the octree
  41303. * @param entry Mesh to add to the octree
  41304. */
  41305. addMesh(entry: T): void;
  41306. /**
  41307. * Selects an array of meshes within the frustum
  41308. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41309. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41310. * @returns array of meshes within the frustum
  41311. */
  41312. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41313. /**
  41314. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41315. * @param sphereCenter defines the bounding sphere center
  41316. * @param sphereRadius defines the bounding sphere radius
  41317. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41318. * @returns an array of objects that intersect the sphere
  41319. */
  41320. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41321. /**
  41322. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41323. * @param ray defines the ray to test with
  41324. * @returns array of intersected objects
  41325. */
  41326. intersectsRay(ray: Ray): SmartArray<T>;
  41327. /**
  41328. * @hidden
  41329. */
  41330. 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;
  41331. /**
  41332. * Adds a mesh into the octree block if it intersects the block
  41333. */
  41334. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41335. /**
  41336. * Adds a submesh into the octree block if it intersects the block
  41337. */
  41338. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41339. }
  41340. }
  41341. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41342. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41343. import { Scene } from "babylonjs/scene";
  41344. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41346. import { Collider } from "babylonjs/Collisions/collider";
  41347. import { Ray } from "babylonjs/Culling/ray";
  41348. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41349. module "babylonjs/scene" {
  41350. interface Scene {
  41351. /**
  41352. * @hidden
  41353. * Backing Filed
  41354. */
  41355. _selectionOctree: Octree<AbstractMesh>;
  41356. /**
  41357. * Gets the octree used to boost mesh selection (picking)
  41358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41359. */
  41360. selectionOctree: Octree<AbstractMesh>;
  41361. /**
  41362. * Creates or updates the octree used to boost selection (picking)
  41363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41364. * @param maxCapacity defines the maximum capacity per leaf
  41365. * @param maxDepth defines the maximum depth of the octree
  41366. * @returns an octree of AbstractMesh
  41367. */
  41368. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41369. }
  41370. }
  41371. module "babylonjs/Meshes/abstractMesh" {
  41372. interface AbstractMesh {
  41373. /**
  41374. * @hidden
  41375. * Backing Field
  41376. */
  41377. _submeshesOctree: Octree<SubMesh>;
  41378. /**
  41379. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41380. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41381. * @param maxCapacity defines the maximum size of each block (64 by default)
  41382. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41383. * @returns the new octree
  41384. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41386. */
  41387. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41388. }
  41389. }
  41390. /**
  41391. * Defines the octree scene component responsible to manage any octrees
  41392. * in a given scene.
  41393. */
  41394. export class OctreeSceneComponent {
  41395. /**
  41396. * The component name helpfull to identify the component in the list of scene components.
  41397. */
  41398. readonly name: string;
  41399. /**
  41400. * The scene the component belongs to.
  41401. */
  41402. scene: Scene;
  41403. /**
  41404. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41405. */
  41406. readonly checksIsEnabled: boolean;
  41407. /**
  41408. * Creates a new instance of the component for the given scene
  41409. * @param scene Defines the scene to register the component in
  41410. */
  41411. constructor(scene: Scene);
  41412. /**
  41413. * Registers the component in a given scene
  41414. */
  41415. register(): void;
  41416. /**
  41417. * Return the list of active meshes
  41418. * @returns the list of active meshes
  41419. */
  41420. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41421. /**
  41422. * Return the list of active sub meshes
  41423. * @param mesh The mesh to get the candidates sub meshes from
  41424. * @returns the list of active sub meshes
  41425. */
  41426. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41427. private _tempRay;
  41428. /**
  41429. * Return the list of sub meshes intersecting with a given local ray
  41430. * @param mesh defines the mesh to find the submesh for
  41431. * @param localRay defines the ray in local space
  41432. * @returns the list of intersecting sub meshes
  41433. */
  41434. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41435. /**
  41436. * Return the list of sub meshes colliding with a collider
  41437. * @param mesh defines the mesh to find the submesh for
  41438. * @param collider defines the collider to evaluate the collision against
  41439. * @returns the list of colliding sub meshes
  41440. */
  41441. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41442. /**
  41443. * Rebuilds the elements related to this component in case of
  41444. * context lost for instance.
  41445. */
  41446. rebuild(): void;
  41447. /**
  41448. * Disposes the component and the associated ressources.
  41449. */
  41450. dispose(): void;
  41451. }
  41452. }
  41453. declare module "babylonjs/Culling/Octrees/index" {
  41454. export * from "babylonjs/Culling/Octrees/octree";
  41455. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41456. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41457. }
  41458. declare module "babylonjs/Culling/index" {
  41459. export * from "babylonjs/Culling/boundingBox";
  41460. export * from "babylonjs/Culling/boundingInfo";
  41461. export * from "babylonjs/Culling/boundingSphere";
  41462. export * from "babylonjs/Culling/Octrees/index";
  41463. export * from "babylonjs/Culling/ray";
  41464. }
  41465. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41466. import { Observable } from "babylonjs/Misc/observable";
  41467. import { Nullable } from "babylonjs/types";
  41468. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41470. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41471. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41472. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41473. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41474. import { Scene } from "babylonjs/scene";
  41475. /**
  41476. * Single axis drag gizmo
  41477. */
  41478. export class AxisDragGizmo extends Gizmo {
  41479. /**
  41480. * Drag behavior responsible for the gizmos dragging interactions
  41481. */
  41482. dragBehavior: PointerDragBehavior;
  41483. private _pointerObserver;
  41484. /**
  41485. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41486. */
  41487. snapDistance: number;
  41488. /**
  41489. * Event that fires each time the gizmo snaps to a new location.
  41490. * * snapDistance is the the change in distance
  41491. */
  41492. onSnapObservable: Observable<{
  41493. snapDistance: number;
  41494. }>;
  41495. /** @hidden */
  41496. static _CreateArrow(scene: Scene, material: StandardMaterial): AbstractMesh;
  41497. /**
  41498. * Creates an AxisDragGizmo
  41499. * @param gizmoLayer The utility layer the gizmo will be added to
  41500. * @param dragAxis The axis which the gizmo will be able to drag on
  41501. * @param color The color of the gizmo
  41502. */
  41503. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41504. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41505. /**
  41506. * Disposes of the gizmo
  41507. */
  41508. dispose(): void;
  41509. }
  41510. }
  41511. declare module "babylonjs/Debug/axesViewer" {
  41512. import { Vector3 } from "babylonjs/Maths/math";
  41513. import { Nullable } from "babylonjs/types";
  41514. import { Scene } from "babylonjs/scene";
  41515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41516. /**
  41517. * The Axes viewer will show 3 axes in a specific point in space
  41518. */
  41519. export class AxesViewer {
  41520. private _xmesh;
  41521. private _ymesh;
  41522. private _zmesh;
  41523. /**
  41524. * Gets the hosting scene
  41525. */
  41526. scene: Nullable<Scene>;
  41527. /**
  41528. * Gets or sets a number used to scale line length
  41529. */
  41530. scaleLines: number;
  41531. /** Gets the mesh used to render x-axis */
  41532. readonly xAxisMesh: Nullable<AbstractMesh>;
  41533. /** Gets the mesh used to render x-axis */
  41534. readonly yAxisMesh: Nullable<AbstractMesh>;
  41535. /** Gets the mesh used to render x-axis */
  41536. readonly zAxisMesh: Nullable<AbstractMesh>;
  41537. private static _recursiveChangeRenderingGroupId;
  41538. /**
  41539. * Creates a new AxesViewer
  41540. * @param scene defines the hosting scene
  41541. * @param scaleLines defines a number used to scale line length (1 by default)
  41542. */
  41543. constructor(scene: Scene, scaleLines?: number);
  41544. /**
  41545. * Force the viewer to update
  41546. * @param position defines the position of the viewer
  41547. * @param xaxis defines the x axis of the viewer
  41548. * @param yaxis defines the y axis of the viewer
  41549. * @param zaxis defines the z axis of the viewer
  41550. */
  41551. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41552. /** Releases resources */
  41553. dispose(): void;
  41554. }
  41555. }
  41556. declare module "babylonjs/Debug/boneAxesViewer" {
  41557. import { Nullable } from "babylonjs/types";
  41558. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41559. import { Vector3 } from "babylonjs/Maths/math";
  41560. import { Mesh } from "babylonjs/Meshes/mesh";
  41561. import { Bone } from "babylonjs/Bones/bone";
  41562. import { Scene } from "babylonjs/scene";
  41563. /**
  41564. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41565. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41566. */
  41567. export class BoneAxesViewer extends AxesViewer {
  41568. /**
  41569. * Gets or sets the target mesh where to display the axes viewer
  41570. */
  41571. mesh: Nullable<Mesh>;
  41572. /**
  41573. * Gets or sets the target bone where to display the axes viewer
  41574. */
  41575. bone: Nullable<Bone>;
  41576. /** Gets current position */
  41577. pos: Vector3;
  41578. /** Gets direction of X axis */
  41579. xaxis: Vector3;
  41580. /** Gets direction of Y axis */
  41581. yaxis: Vector3;
  41582. /** Gets direction of Z axis */
  41583. zaxis: Vector3;
  41584. /**
  41585. * Creates a new BoneAxesViewer
  41586. * @param scene defines the hosting scene
  41587. * @param bone defines the target bone
  41588. * @param mesh defines the target mesh
  41589. * @param scaleLines defines a scaling factor for line length (1 by default)
  41590. */
  41591. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41592. /**
  41593. * Force the viewer to update
  41594. */
  41595. update(): void;
  41596. /** Releases resources */
  41597. dispose(): void;
  41598. }
  41599. }
  41600. declare module "babylonjs/Debug/debugLayer" {
  41601. import { Observable } from "babylonjs/Misc/observable";
  41602. import { Scene } from "babylonjs/scene";
  41603. /**
  41604. * Interface used to define scene explorer extensibility option
  41605. */
  41606. export interface IExplorerExtensibilityOption {
  41607. /**
  41608. * Define the option label
  41609. */
  41610. label: string;
  41611. /**
  41612. * Defines the action to execute on click
  41613. */
  41614. action: (entity: any) => void;
  41615. }
  41616. /**
  41617. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41618. */
  41619. export interface IExplorerExtensibilityGroup {
  41620. /**
  41621. * Defines a predicate to test if a given type mut be extended
  41622. */
  41623. predicate: (entity: any) => boolean;
  41624. /**
  41625. * Gets the list of options added to a type
  41626. */
  41627. entries: IExplorerExtensibilityOption[];
  41628. }
  41629. /**
  41630. * Interface used to define the options to use to create the Inspector
  41631. */
  41632. export interface IInspectorOptions {
  41633. /**
  41634. * Display in overlay mode (default: false)
  41635. */
  41636. overlay?: boolean;
  41637. /**
  41638. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41639. */
  41640. globalRoot?: HTMLElement;
  41641. /**
  41642. * Display the Scene explorer
  41643. */
  41644. showExplorer?: boolean;
  41645. /**
  41646. * Display the property inspector
  41647. */
  41648. showInspector?: boolean;
  41649. /**
  41650. * Display in embed mode (both panes on the right)
  41651. */
  41652. embedMode?: boolean;
  41653. /**
  41654. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41655. */
  41656. handleResize?: boolean;
  41657. /**
  41658. * Allow the panes to popup (default: true)
  41659. */
  41660. enablePopup?: boolean;
  41661. /**
  41662. * Optional list of extensibility entries
  41663. */
  41664. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41665. }
  41666. module "babylonjs/scene" {
  41667. interface Scene {
  41668. /**
  41669. * @hidden
  41670. * Backing field
  41671. */
  41672. _debugLayer: DebugLayer;
  41673. /**
  41674. * Gets the debug layer (aka Inspector) associated with the scene
  41675. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41676. */
  41677. debugLayer: DebugLayer;
  41678. }
  41679. }
  41680. /**
  41681. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41682. * what is happening in your scene
  41683. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41684. */
  41685. export class DebugLayer {
  41686. /**
  41687. * Define the url to get the inspector script from.
  41688. * By default it uses the babylonjs CDN.
  41689. * @ignoreNaming
  41690. */
  41691. static InspectorURL: string;
  41692. private _scene;
  41693. private BJSINSPECTOR;
  41694. /**
  41695. * Observable triggered when a property is changed through the inspector.
  41696. */
  41697. onPropertyChangedObservable: Observable<{
  41698. object: any;
  41699. property: string;
  41700. value: any;
  41701. initialValue: any;
  41702. }>;
  41703. /**
  41704. * Instantiates a new debug layer.
  41705. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41706. * what is happening in your scene
  41707. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41708. * @param scene Defines the scene to inspect
  41709. */
  41710. constructor(scene: Scene);
  41711. /** Creates the inspector window. */
  41712. private _createInspector;
  41713. /**
  41714. * Get if the inspector is visible or not.
  41715. * @returns true if visible otherwise, false
  41716. */
  41717. isVisible(): boolean;
  41718. /**
  41719. * Hide the inspector and close its window.
  41720. */
  41721. hide(): void;
  41722. /**
  41723. * Launch the debugLayer.
  41724. * @param config Define the configuration of the inspector
  41725. */
  41726. show(config?: IInspectorOptions): void;
  41727. }
  41728. }
  41729. declare module "babylonjs/Debug/physicsViewer" {
  41730. import { Nullable } from "babylonjs/types";
  41731. import { Scene } from "babylonjs/scene";
  41732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41733. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41734. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41735. /**
  41736. * Used to show the physics impostor around the specific mesh
  41737. */
  41738. export class PhysicsViewer {
  41739. /** @hidden */
  41740. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41741. /** @hidden */
  41742. protected _meshes: Array<Nullable<AbstractMesh>>;
  41743. /** @hidden */
  41744. protected _scene: Nullable<Scene>;
  41745. /** @hidden */
  41746. protected _numMeshes: number;
  41747. /** @hidden */
  41748. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41749. private _renderFunction;
  41750. private _utilityLayer;
  41751. private _debugBoxMesh;
  41752. private _debugSphereMesh;
  41753. private _debugMaterial;
  41754. /**
  41755. * Creates a new PhysicsViewer
  41756. * @param scene defines the hosting scene
  41757. */
  41758. constructor(scene: Scene);
  41759. /** @hidden */
  41760. protected _updateDebugMeshes(): void;
  41761. /**
  41762. * Renders a specified physic impostor
  41763. * @param impostor defines the impostor to render
  41764. * @returns the new debug mesh used to render the impostor
  41765. */
  41766. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41767. /**
  41768. * Hides a specified physic impostor
  41769. * @param impostor defines the impostor to hide
  41770. */
  41771. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41772. private _getDebugMaterial;
  41773. private _getDebugBoxMesh;
  41774. private _getDebugSphereMesh;
  41775. private _getDebugMesh;
  41776. /** Releases all resources */
  41777. dispose(): void;
  41778. }
  41779. }
  41780. declare module "babylonjs/Debug/rayHelper" {
  41781. import { Nullable } from "babylonjs/types";
  41782. import { Ray } from "babylonjs/Culling/ray";
  41783. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41784. import { Scene } from "babylonjs/scene";
  41785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41786. /**
  41787. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41788. * in order to better appreciate the issue one might have.
  41789. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41790. */
  41791. export class RayHelper {
  41792. /**
  41793. * Defines the ray we are currently tryin to visualize.
  41794. */
  41795. ray: Nullable<Ray>;
  41796. private _renderPoints;
  41797. private _renderLine;
  41798. private _renderFunction;
  41799. private _scene;
  41800. private _updateToMeshFunction;
  41801. private _attachedToMesh;
  41802. private _meshSpaceDirection;
  41803. private _meshSpaceOrigin;
  41804. /**
  41805. * Helper function to create a colored helper in a scene in one line.
  41806. * @param ray Defines the ray we are currently tryin to visualize
  41807. * @param scene Defines the scene the ray is used in
  41808. * @param color Defines the color we want to see the ray in
  41809. * @returns The newly created ray helper.
  41810. */
  41811. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41812. /**
  41813. * Instantiate a new ray helper.
  41814. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41815. * in order to better appreciate the issue one might have.
  41816. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41817. * @param ray Defines the ray we are currently tryin to visualize
  41818. */
  41819. constructor(ray: Ray);
  41820. /**
  41821. * Shows the ray we are willing to debug.
  41822. * @param scene Defines the scene the ray needs to be rendered in
  41823. * @param color Defines the color the ray needs to be rendered in
  41824. */
  41825. show(scene: Scene, color?: Color3): void;
  41826. /**
  41827. * Hides the ray we are debugging.
  41828. */
  41829. hide(): void;
  41830. private _render;
  41831. /**
  41832. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41833. * @param mesh Defines the mesh we want the helper attached to
  41834. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41835. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41836. * @param length Defines the length of the ray
  41837. */
  41838. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41839. /**
  41840. * Detach the ray helper from the mesh it has previously been attached to.
  41841. */
  41842. detachFromMesh(): void;
  41843. private _updateToMesh;
  41844. /**
  41845. * Dispose the helper and release its associated resources.
  41846. */
  41847. dispose(): void;
  41848. }
  41849. }
  41850. declare module "babylonjs/Debug/skeletonViewer" {
  41851. import { Color3 } from "babylonjs/Maths/math";
  41852. import { Scene } from "babylonjs/scene";
  41853. import { Nullable } from "babylonjs/types";
  41854. import { Skeleton } from "babylonjs/Bones/skeleton";
  41855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41856. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41857. /**
  41858. * Class used to render a debug view of a given skeleton
  41859. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41860. */
  41861. export class SkeletonViewer {
  41862. /** defines the skeleton to render */
  41863. skeleton: Skeleton;
  41864. /** defines the mesh attached to the skeleton */
  41865. mesh: AbstractMesh;
  41866. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41867. autoUpdateBonesMatrices: boolean;
  41868. /** defines the rendering group id to use with the viewer */
  41869. renderingGroupId: number;
  41870. /** Gets or sets the color used to render the skeleton */
  41871. color: Color3;
  41872. private _scene;
  41873. private _debugLines;
  41874. private _debugMesh;
  41875. private _isEnabled;
  41876. private _renderFunction;
  41877. private _utilityLayer;
  41878. /**
  41879. * Returns the mesh used to render the bones
  41880. */
  41881. readonly debugMesh: Nullable<LinesMesh>;
  41882. /**
  41883. * Creates a new SkeletonViewer
  41884. * @param skeleton defines the skeleton to render
  41885. * @param mesh defines the mesh attached to the skeleton
  41886. * @param scene defines the hosting scene
  41887. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41888. * @param renderingGroupId defines the rendering group id to use with the viewer
  41889. */
  41890. constructor(
  41891. /** defines the skeleton to render */
  41892. skeleton: Skeleton,
  41893. /** defines the mesh attached to the skeleton */
  41894. mesh: AbstractMesh, scene: Scene,
  41895. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41896. autoUpdateBonesMatrices?: boolean,
  41897. /** defines the rendering group id to use with the viewer */
  41898. renderingGroupId?: number);
  41899. /** Gets or sets a boolean indicating if the viewer is enabled */
  41900. isEnabled: boolean;
  41901. private _getBonePosition;
  41902. private _getLinesForBonesWithLength;
  41903. private _getLinesForBonesNoLength;
  41904. /** Update the viewer to sync with current skeleton state */
  41905. update(): void;
  41906. /** Release associated resources */
  41907. dispose(): void;
  41908. }
  41909. }
  41910. declare module "babylonjs/Debug/index" {
  41911. export * from "babylonjs/Debug/axesViewer";
  41912. export * from "babylonjs/Debug/boneAxesViewer";
  41913. export * from "babylonjs/Debug/debugLayer";
  41914. export * from "babylonjs/Debug/physicsViewer";
  41915. export * from "babylonjs/Debug/rayHelper";
  41916. export * from "babylonjs/Debug/skeletonViewer";
  41917. }
  41918. declare module "babylonjs/Engines/nullEngine" {
  41919. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41920. import { Scene } from "babylonjs/scene";
  41921. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41922. import { Engine, RenderTargetCreationOptions } from "babylonjs/Engines/engine";
  41923. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41925. import { Effect } from "babylonjs/Materials/effect";
  41926. /**
  41927. * Options to create the null engine
  41928. */
  41929. export class NullEngineOptions {
  41930. /**
  41931. * Render width (Default: 512)
  41932. */
  41933. renderWidth: number;
  41934. /**
  41935. * Render height (Default: 256)
  41936. */
  41937. renderHeight: number;
  41938. /**
  41939. * Texture size (Default: 512)
  41940. */
  41941. textureSize: number;
  41942. /**
  41943. * If delta time between frames should be constant
  41944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41945. */
  41946. deterministicLockstep: boolean;
  41947. /**
  41948. * Maximum about of steps between frames (Default: 4)
  41949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41950. */
  41951. lockstepMaxSteps: number;
  41952. }
  41953. /**
  41954. * The null engine class provides support for headless version of babylon.js.
  41955. * This can be used in server side scenario or for testing purposes
  41956. */
  41957. export class NullEngine extends Engine {
  41958. private _options;
  41959. /**
  41960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41961. */
  41962. isDeterministicLockStep(): boolean;
  41963. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41964. getLockstepMaxSteps(): number;
  41965. /**
  41966. * Sets hardware scaling, used to save performance if needed
  41967. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41968. */
  41969. getHardwareScalingLevel(): number;
  41970. constructor(options?: NullEngineOptions);
  41971. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41972. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41973. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41974. getRenderWidth(useScreen?: boolean): number;
  41975. getRenderHeight(useScreen?: boolean): number;
  41976. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41977. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41978. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41979. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41980. bindSamplers(effect: Effect): void;
  41981. enableEffect(effect: Effect): void;
  41982. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41983. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41984. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41985. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41986. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41987. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41988. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41989. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41990. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41991. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41992. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41993. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41994. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41995. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41996. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41997. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41998. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41999. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42000. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42001. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42002. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42003. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42004. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42005. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42006. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42007. bindBuffers(vertexBuffers: {
  42008. [key: string]: VertexBuffer;
  42009. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42010. wipeCaches(bruteForce?: boolean): void;
  42011. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42012. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42013. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42014. /** @hidden */
  42015. _createTexture(): WebGLTexture;
  42016. /** @hidden */
  42017. _releaseTexture(texture: InternalTexture): void;
  42018. 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;
  42019. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42020. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42021. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42022. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42023. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42024. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42025. areAllEffectsReady(): boolean;
  42026. /**
  42027. * @hidden
  42028. * Get the current error code of the webGL context
  42029. * @returns the error code
  42030. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42031. */
  42032. getError(): number;
  42033. /** @hidden */
  42034. _getUnpackAlignement(): number;
  42035. /** @hidden */
  42036. _unpackFlipY(value: boolean): void;
  42037. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42038. /**
  42039. * Updates a dynamic vertex buffer.
  42040. * @param vertexBuffer the vertex buffer to update
  42041. * @param data the data used to update the vertex buffer
  42042. * @param byteOffset the byte offset of the data (optional)
  42043. * @param byteLength the byte length of the data (optional)
  42044. */
  42045. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42046. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42047. /** @hidden */
  42048. _bindTexture(channel: number, texture: InternalTexture): void;
  42049. /** @hidden */
  42050. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42051. releaseEffects(): void;
  42052. displayLoadingUI(): void;
  42053. hideLoadingUI(): void;
  42054. /** @hidden */
  42055. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42056. /** @hidden */
  42057. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42058. /** @hidden */
  42059. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42060. /** @hidden */
  42061. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42062. }
  42063. }
  42064. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42065. import { Nullable, int } from "babylonjs/types";
  42066. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42067. /** @hidden */
  42068. export var _forceOcclusionQueryToBundle: boolean;
  42069. /** @hidden */
  42070. class _OcclusionDataStorage {
  42071. /** @hidden */
  42072. occlusionInternalRetryCounter: number;
  42073. /** @hidden */
  42074. isOcclusionQueryInProgress: boolean;
  42075. /** @hidden */
  42076. isOccluded: boolean;
  42077. /** @hidden */
  42078. occlusionRetryCount: number;
  42079. /** @hidden */
  42080. occlusionType: number;
  42081. /** @hidden */
  42082. occlusionQueryAlgorithmType: number;
  42083. }
  42084. module "babylonjs/Engines/engine" {
  42085. interface Engine {
  42086. /**
  42087. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42088. * @return the new query
  42089. */
  42090. createQuery(): WebGLQuery;
  42091. /**
  42092. * Delete and release a webGL query
  42093. * @param query defines the query to delete
  42094. * @return the current engine
  42095. */
  42096. deleteQuery(query: WebGLQuery): Engine;
  42097. /**
  42098. * Check if a given query has resolved and got its value
  42099. * @param query defines the query to check
  42100. * @returns true if the query got its value
  42101. */
  42102. isQueryResultAvailable(query: WebGLQuery): boolean;
  42103. /**
  42104. * Gets the value of a given query
  42105. * @param query defines the query to check
  42106. * @returns the value of the query
  42107. */
  42108. getQueryResult(query: WebGLQuery): number;
  42109. /**
  42110. * Initiates an occlusion query
  42111. * @param algorithmType defines the algorithm to use
  42112. * @param query defines the query to use
  42113. * @returns the current engine
  42114. * @see http://doc.babylonjs.com/features/occlusionquery
  42115. */
  42116. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42117. /**
  42118. * Ends an occlusion query
  42119. * @see http://doc.babylonjs.com/features/occlusionquery
  42120. * @param algorithmType defines the algorithm to use
  42121. * @returns the current engine
  42122. */
  42123. endOcclusionQuery(algorithmType: number): Engine;
  42124. /**
  42125. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42126. * Please note that only one query can be issued at a time
  42127. * @returns a time token used to track the time span
  42128. */
  42129. startTimeQuery(): Nullable<_TimeToken>;
  42130. /**
  42131. * Ends a time query
  42132. * @param token defines the token used to measure the time span
  42133. * @returns the time spent (in ns)
  42134. */
  42135. endTimeQuery(token: _TimeToken): int;
  42136. /** @hidden */
  42137. _currentNonTimestampToken: Nullable<_TimeToken>;
  42138. /** @hidden */
  42139. _createTimeQuery(): WebGLQuery;
  42140. /** @hidden */
  42141. _deleteTimeQuery(query: WebGLQuery): void;
  42142. /** @hidden */
  42143. _getGlAlgorithmType(algorithmType: number): number;
  42144. /** @hidden */
  42145. _getTimeQueryResult(query: WebGLQuery): any;
  42146. /** @hidden */
  42147. _getTimeQueryAvailability(query: WebGLQuery): any;
  42148. }
  42149. }
  42150. module "babylonjs/Meshes/abstractMesh" {
  42151. interface AbstractMesh {
  42152. /**
  42153. * Backing filed
  42154. * @hidden
  42155. */
  42156. __occlusionDataStorage: _OcclusionDataStorage;
  42157. /**
  42158. * Access property
  42159. * @hidden
  42160. */
  42161. _occlusionDataStorage: _OcclusionDataStorage;
  42162. /**
  42163. * 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.
  42164. * The default value is -1 which means don't break the query and wait till the result
  42165. * @see http://doc.babylonjs.com/features/occlusionquery
  42166. */
  42167. occlusionRetryCount: number;
  42168. /**
  42169. * 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:
  42170. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42171. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42172. * * 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.
  42173. * @see http://doc.babylonjs.com/features/occlusionquery
  42174. */
  42175. occlusionType: number;
  42176. /**
  42177. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42178. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42179. * * 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.
  42180. * @see http://doc.babylonjs.com/features/occlusionquery
  42181. */
  42182. occlusionQueryAlgorithmType: number;
  42183. /**
  42184. * 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
  42185. * @see http://doc.babylonjs.com/features/occlusionquery
  42186. */
  42187. isOccluded: boolean;
  42188. /**
  42189. * Flag to check the progress status of the query
  42190. * @see http://doc.babylonjs.com/features/occlusionquery
  42191. */
  42192. isOcclusionQueryInProgress: boolean;
  42193. }
  42194. }
  42195. }
  42196. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42197. import { Nullable } from "babylonjs/types";
  42198. /** @hidden */
  42199. export var _forceTransformFeedbackToBundle: boolean;
  42200. module "babylonjs/Engines/engine" {
  42201. interface Engine {
  42202. /**
  42203. * Creates a webGL transform feedback object
  42204. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42205. * @returns the webGL transform feedback object
  42206. */
  42207. createTransformFeedback(): WebGLTransformFeedback;
  42208. /**
  42209. * Delete a webGL transform feedback object
  42210. * @param value defines the webGL transform feedback object to delete
  42211. */
  42212. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42213. /**
  42214. * Bind a webGL transform feedback object to the webgl context
  42215. * @param value defines the webGL transform feedback object to bind
  42216. */
  42217. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42218. /**
  42219. * Begins a transform feedback operation
  42220. * @param usePoints defines if points or triangles must be used
  42221. */
  42222. beginTransformFeedback(usePoints: boolean): void;
  42223. /**
  42224. * Ends a transform feedback operation
  42225. */
  42226. endTransformFeedback(): void;
  42227. /**
  42228. * Specify the varyings to use with transform feedback
  42229. * @param program defines the associated webGL program
  42230. * @param value defines the list of strings representing the varying names
  42231. */
  42232. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42233. /**
  42234. * Bind a webGL buffer for a transform feedback operation
  42235. * @param value defines the webGL buffer to bind
  42236. */
  42237. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42238. }
  42239. }
  42240. }
  42241. declare module "babylonjs/Engines/Extensions/index" {
  42242. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42243. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42244. }
  42245. declare module "babylonjs/Engines/index" {
  42246. export * from "babylonjs/Engines/constants";
  42247. export * from "babylonjs/Engines/engine";
  42248. export * from "babylonjs/Engines/nullEngine";
  42249. export * from "babylonjs/Engines/Extensions/index";
  42250. }
  42251. declare module "babylonjs/Events/clipboardEvents" {
  42252. /**
  42253. * Gather the list of clipboard event types as constants.
  42254. */
  42255. export class ClipboardEventTypes {
  42256. /**
  42257. * The clipboard event is fired when a copy command is active (pressed).
  42258. */
  42259. static readonly COPY: number;
  42260. /**
  42261. * The clipboard event is fired when a cut command is active (pressed).
  42262. */
  42263. static readonly CUT: number;
  42264. /**
  42265. * The clipboard event is fired when a paste command is active (pressed).
  42266. */
  42267. static readonly PASTE: number;
  42268. }
  42269. /**
  42270. * This class is used to store clipboard related info for the onClipboardObservable event.
  42271. */
  42272. export class ClipboardInfo {
  42273. /**
  42274. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42275. */
  42276. type: number;
  42277. /**
  42278. * Defines the related dom event
  42279. */
  42280. event: ClipboardEvent;
  42281. /**
  42282. *Creates an instance of ClipboardInfo.
  42283. * @param {number} type
  42284. * @param {ClipboardEvent} event
  42285. */
  42286. constructor(
  42287. /**
  42288. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42289. */
  42290. type: number,
  42291. /**
  42292. * Defines the related dom event
  42293. */
  42294. event: ClipboardEvent);
  42295. /**
  42296. * Get the clipboard event's type from the keycode.
  42297. * @param keyCode Defines the keyCode for the current keyboard event.
  42298. * @return {number}
  42299. */
  42300. static GetTypeFromCharacter(keyCode: number): number;
  42301. }
  42302. }
  42303. declare module "babylonjs/Events/index" {
  42304. export * from "babylonjs/Events/keyboardEvents";
  42305. export * from "babylonjs/Events/pointerEvents";
  42306. export * from "babylonjs/Events/clipboardEvents";
  42307. }
  42308. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42309. import { Scene } from "babylonjs/scene";
  42310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42311. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42312. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42313. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42314. /**
  42315. * Google Daydream controller
  42316. */
  42317. export class DaydreamController extends WebVRController {
  42318. /**
  42319. * Base Url for the controller model.
  42320. */
  42321. static MODEL_BASE_URL: string;
  42322. /**
  42323. * File name for the controller model.
  42324. */
  42325. static MODEL_FILENAME: string;
  42326. /**
  42327. * Gamepad Id prefix used to identify Daydream Controller.
  42328. */
  42329. static readonly GAMEPAD_ID_PREFIX: string;
  42330. /**
  42331. * Creates a new DaydreamController from a gamepad
  42332. * @param vrGamepad the gamepad that the controller should be created from
  42333. */
  42334. constructor(vrGamepad: any);
  42335. /**
  42336. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42337. * @param scene scene in which to add meshes
  42338. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42339. */
  42340. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42341. /**
  42342. * Called once for each button that changed state since the last frame
  42343. * @param buttonIdx Which button index changed
  42344. * @param state New state of the button
  42345. * @param changes Which properties on the state changed since last frame
  42346. */
  42347. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42348. }
  42349. }
  42350. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42351. import { Scene } from "babylonjs/scene";
  42352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42353. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42354. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42355. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42356. /**
  42357. * Gear VR Controller
  42358. */
  42359. export class GearVRController extends WebVRController {
  42360. /**
  42361. * Base Url for the controller model.
  42362. */
  42363. static MODEL_BASE_URL: string;
  42364. /**
  42365. * File name for the controller model.
  42366. */
  42367. static MODEL_FILENAME: string;
  42368. /**
  42369. * Gamepad Id prefix used to identify this controller.
  42370. */
  42371. static readonly GAMEPAD_ID_PREFIX: string;
  42372. private readonly _buttonIndexToObservableNameMap;
  42373. /**
  42374. * Creates a new GearVRController from a gamepad
  42375. * @param vrGamepad the gamepad that the controller should be created from
  42376. */
  42377. constructor(vrGamepad: any);
  42378. /**
  42379. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42380. * @param scene scene in which to add meshes
  42381. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42382. */
  42383. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42384. /**
  42385. * Called once for each button that changed state since the last frame
  42386. * @param buttonIdx Which button index changed
  42387. * @param state New state of the button
  42388. * @param changes Which properties on the state changed since last frame
  42389. */
  42390. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42391. }
  42392. }
  42393. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42394. import { Scene } from "babylonjs/scene";
  42395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42396. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42397. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42398. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42399. /**
  42400. * Generic Controller
  42401. */
  42402. export class GenericController extends WebVRController {
  42403. /**
  42404. * Base Url for the controller model.
  42405. */
  42406. static readonly MODEL_BASE_URL: string;
  42407. /**
  42408. * File name for the controller model.
  42409. */
  42410. static readonly MODEL_FILENAME: string;
  42411. /**
  42412. * Creates a new GenericController from a gamepad
  42413. * @param vrGamepad the gamepad that the controller should be created from
  42414. */
  42415. constructor(vrGamepad: any);
  42416. /**
  42417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42418. * @param scene scene in which to add meshes
  42419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42420. */
  42421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42422. /**
  42423. * Called once for each button that changed state since the last frame
  42424. * @param buttonIdx Which button index changed
  42425. * @param state New state of the button
  42426. * @param changes Which properties on the state changed since last frame
  42427. */
  42428. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42429. }
  42430. }
  42431. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42432. import { Observable } from "babylonjs/Misc/observable";
  42433. import { Scene } from "babylonjs/scene";
  42434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42435. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42436. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42437. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42438. /**
  42439. * Oculus Touch Controller
  42440. */
  42441. export class OculusTouchController extends WebVRController {
  42442. /**
  42443. * Base Url for the controller model.
  42444. */
  42445. static MODEL_BASE_URL: string;
  42446. /**
  42447. * File name for the left controller model.
  42448. */
  42449. static MODEL_LEFT_FILENAME: string;
  42450. /**
  42451. * File name for the right controller model.
  42452. */
  42453. static MODEL_RIGHT_FILENAME: string;
  42454. /**
  42455. * Fired when the secondary trigger on this controller is modified
  42456. */
  42457. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42458. /**
  42459. * Fired when the thumb rest on this controller is modified
  42460. */
  42461. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42462. /**
  42463. * Creates a new OculusTouchController from a gamepad
  42464. * @param vrGamepad the gamepad that the controller should be created from
  42465. */
  42466. constructor(vrGamepad: any);
  42467. /**
  42468. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42469. * @param scene scene in which to add meshes
  42470. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42471. */
  42472. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42473. /**
  42474. * Fired when the A button on this controller is modified
  42475. */
  42476. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42477. /**
  42478. * Fired when the B button on this controller is modified
  42479. */
  42480. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42481. /**
  42482. * Fired when the X button on this controller is modified
  42483. */
  42484. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42485. /**
  42486. * Fired when the Y button on this controller is modified
  42487. */
  42488. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42489. /**
  42490. * Called once for each button that changed state since the last frame
  42491. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42492. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42493. * 2) secondary trigger (same)
  42494. * 3) A (right) X (left), touch, pressed = value
  42495. * 4) B / Y
  42496. * 5) thumb rest
  42497. * @param buttonIdx Which button index changed
  42498. * @param state New state of the button
  42499. * @param changes Which properties on the state changed since last frame
  42500. */
  42501. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42502. }
  42503. }
  42504. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42505. import { Scene } from "babylonjs/scene";
  42506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42507. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42508. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42509. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42510. /**
  42511. * Vive Controller
  42512. */
  42513. export class ViveController extends WebVRController {
  42514. /**
  42515. * Base Url for the controller model.
  42516. */
  42517. static MODEL_BASE_URL: string;
  42518. /**
  42519. * File name for the controller model.
  42520. */
  42521. static MODEL_FILENAME: string;
  42522. /**
  42523. * Creates a new ViveController from a gamepad
  42524. * @param vrGamepad the gamepad that the controller should be created from
  42525. */
  42526. constructor(vrGamepad: any);
  42527. /**
  42528. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42529. * @param scene scene in which to add meshes
  42530. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42531. */
  42532. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42533. /**
  42534. * Fired when the left button on this controller is modified
  42535. */
  42536. readonly onLeftButtonStateChangedObservable: import("babylonjs/Misc/observable").Observable<ExtendedGamepadButton>;
  42537. /**
  42538. * Fired when the right button on this controller is modified
  42539. */
  42540. readonly onRightButtonStateChangedObservable: import("babylonjs/Misc/observable").Observable<ExtendedGamepadButton>;
  42541. /**
  42542. * Fired when the menu button on this controller is modified
  42543. */
  42544. readonly onMenuButtonStateChangedObservable: import("babylonjs/Misc/observable").Observable<ExtendedGamepadButton>;
  42545. /**
  42546. * Called once for each button that changed state since the last frame
  42547. * Vive mapping:
  42548. * 0: touchpad
  42549. * 1: trigger
  42550. * 2: left AND right buttons
  42551. * 3: menu button
  42552. * @param buttonIdx Which button index changed
  42553. * @param state New state of the button
  42554. * @param changes Which properties on the state changed since last frame
  42555. */
  42556. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42557. }
  42558. }
  42559. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42560. import { Observable } from "babylonjs/Misc/observable";
  42561. import { Scene } from "babylonjs/scene";
  42562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42563. import { Ray } from "babylonjs/Culling/ray";
  42564. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42565. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42566. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42567. /**
  42568. * Defines the WindowsMotionController object that the state of the windows motion controller
  42569. */
  42570. export class WindowsMotionController extends WebVRController {
  42571. /**
  42572. * The base url used to load the left and right controller models
  42573. */
  42574. static MODEL_BASE_URL: string;
  42575. /**
  42576. * The name of the left controller model file
  42577. */
  42578. static MODEL_LEFT_FILENAME: string;
  42579. /**
  42580. * The name of the right controller model file
  42581. */
  42582. static MODEL_RIGHT_FILENAME: string;
  42583. /**
  42584. * The controller name prefix for this controller type
  42585. */
  42586. static readonly GAMEPAD_ID_PREFIX: string;
  42587. /**
  42588. * The controller id pattern for this controller type
  42589. */
  42590. private static readonly GAMEPAD_ID_PATTERN;
  42591. private _loadedMeshInfo;
  42592. private readonly _mapping;
  42593. /**
  42594. * Fired when the trackpad on this controller is clicked
  42595. */
  42596. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42597. /**
  42598. * Fired when the trackpad on this controller is modified
  42599. */
  42600. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42601. /**
  42602. * The current x and y values of this controller's trackpad
  42603. */
  42604. trackpad: StickValues;
  42605. /**
  42606. * Creates a new WindowsMotionController from a gamepad
  42607. * @param vrGamepad the gamepad that the controller should be created from
  42608. */
  42609. constructor(vrGamepad: any);
  42610. /**
  42611. * Fired when the trigger on this controller is modified
  42612. */
  42613. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42614. /**
  42615. * Fired when the menu button on this controller is modified
  42616. */
  42617. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42618. /**
  42619. * Fired when the grip button on this controller is modified
  42620. */
  42621. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42622. /**
  42623. * Fired when the thumbstick button on this controller is modified
  42624. */
  42625. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42626. /**
  42627. * Fired when the touchpad button on this controller is modified
  42628. */
  42629. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42630. /**
  42631. * Fired when the touchpad values on this controller are modified
  42632. */
  42633. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42634. private _updateTrackpad;
  42635. /**
  42636. * Called once per frame by the engine.
  42637. */
  42638. update(): void;
  42639. /**
  42640. * Called once for each button that changed state since the last frame
  42641. * @param buttonIdx Which button index changed
  42642. * @param state New state of the button
  42643. * @param changes Which properties on the state changed since last frame
  42644. */
  42645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42646. /**
  42647. * Moves the buttons on the controller mesh based on their current state
  42648. * @param buttonName the name of the button to move
  42649. * @param buttonValue the value of the button which determines the buttons new position
  42650. */
  42651. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42652. /**
  42653. * Moves the axis on the controller mesh based on its current state
  42654. * @param axis the index of the axis
  42655. * @param axisValue the value of the axis which determines the meshes new position
  42656. * @hidden
  42657. */
  42658. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42659. /**
  42660. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42661. * @param scene scene in which to add meshes
  42662. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42663. */
  42664. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42665. /**
  42666. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42667. * can be transformed by button presses and axes values, based on this._mapping.
  42668. *
  42669. * @param scene scene in which the meshes exist
  42670. * @param meshes list of meshes that make up the controller model to process
  42671. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42672. */
  42673. private processModel;
  42674. private createMeshInfo;
  42675. /**
  42676. * Gets the ray of the controller in the direction the controller is pointing
  42677. * @param length the length the resulting ray should be
  42678. * @returns a ray in the direction the controller is pointing
  42679. */
  42680. getForwardRay(length?: number): Ray;
  42681. /**
  42682. * Disposes of the controller
  42683. */
  42684. dispose(): void;
  42685. }
  42686. }
  42687. declare module "babylonjs/Gamepads/Controllers/index" {
  42688. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42689. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42690. export * from "babylonjs/Gamepads/Controllers/genericController";
  42691. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42692. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42693. export * from "babylonjs/Gamepads/Controllers/viveController";
  42694. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42695. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42696. }
  42697. declare module "babylonjs/Gamepads/gamepadManager" {
  42698. import { Observable } from "babylonjs/Misc/observable";
  42699. import { Nullable } from "babylonjs/types";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42702. /**
  42703. * Manager for handling gamepads
  42704. */
  42705. export class GamepadManager {
  42706. private _scene?;
  42707. private _babylonGamepads;
  42708. private _oneGamepadConnected;
  42709. /** @hidden */
  42710. _isMonitoring: boolean;
  42711. private _gamepadEventSupported;
  42712. private _gamepadSupport;
  42713. /**
  42714. * observable to be triggered when the gamepad controller has been connected
  42715. */
  42716. onGamepadConnectedObservable: Observable<Gamepad>;
  42717. /**
  42718. * observable to be triggered when the gamepad controller has been disconnected
  42719. */
  42720. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42721. private _onGamepadConnectedEvent;
  42722. private _onGamepadDisconnectedEvent;
  42723. /**
  42724. * Initializes the gamepad manager
  42725. * @param _scene BabylonJS scene
  42726. */
  42727. constructor(_scene?: Scene | undefined);
  42728. /**
  42729. * The gamepads in the game pad manager
  42730. */
  42731. readonly gamepads: Gamepad[];
  42732. /**
  42733. * Get the gamepad controllers based on type
  42734. * @param type The type of gamepad controller
  42735. * @returns Nullable gamepad
  42736. */
  42737. getGamepadByType(type?: number): Nullable<Gamepad>;
  42738. /**
  42739. * Disposes the gamepad manager
  42740. */
  42741. dispose(): void;
  42742. private _addNewGamepad;
  42743. private _startMonitoringGamepads;
  42744. private _stopMonitoringGamepads;
  42745. /** @hidden */
  42746. _checkGamepadsStatus(): void;
  42747. private _updateGamepadObjects;
  42748. }
  42749. }
  42750. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42751. import { Nullable } from "babylonjs/types";
  42752. import { Scene } from "babylonjs/scene";
  42753. import { ISceneComponent } from "babylonjs/sceneComponent";
  42754. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42755. module "babylonjs/scene" {
  42756. interface Scene {
  42757. /** @hidden */
  42758. _gamepadManager: Nullable<GamepadManager>;
  42759. /**
  42760. * Gets the gamepad manager associated with the scene
  42761. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42762. */
  42763. gamepadManager: GamepadManager;
  42764. }
  42765. }
  42766. module "babylonjs/Cameras/freeCameraInputsManager" {
  42767. /**
  42768. * Interface representing a free camera inputs manager
  42769. */
  42770. interface FreeCameraInputsManager {
  42771. /**
  42772. * Adds gamepad input support to the FreeCameraInputsManager.
  42773. * @returns the FreeCameraInputsManager
  42774. */
  42775. addGamepad(): FreeCameraInputsManager;
  42776. }
  42777. }
  42778. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42779. /**
  42780. * Interface representing an arc rotate camera inputs manager
  42781. */
  42782. interface ArcRotateCameraInputsManager {
  42783. /**
  42784. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42785. * @returns the camera inputs manager
  42786. */
  42787. addGamepad(): ArcRotateCameraInputsManager;
  42788. }
  42789. }
  42790. /**
  42791. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42792. */
  42793. export class GamepadSystemSceneComponent implements ISceneComponent {
  42794. /**
  42795. * The component name helpfull to identify the component in the list of scene components.
  42796. */
  42797. readonly name: string;
  42798. /**
  42799. * The scene the component belongs to.
  42800. */
  42801. scene: Scene;
  42802. /**
  42803. * Creates a new instance of the component for the given scene
  42804. * @param scene Defines the scene to register the component in
  42805. */
  42806. constructor(scene: Scene);
  42807. /**
  42808. * Registers the component in a given scene
  42809. */
  42810. register(): void;
  42811. /**
  42812. * Rebuilds the elements related to this component in case of
  42813. * context lost for instance.
  42814. */
  42815. rebuild(): void;
  42816. /**
  42817. * Disposes the component and the associated ressources
  42818. */
  42819. dispose(): void;
  42820. private _beforeCameraUpdate;
  42821. }
  42822. }
  42823. declare module "babylonjs/Gamepads/index" {
  42824. export * from "babylonjs/Gamepads/Controllers/index";
  42825. export * from "babylonjs/Gamepads/gamepad";
  42826. export * from "babylonjs/Gamepads/gamepadManager";
  42827. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42828. export * from "babylonjs/Gamepads/xboxGamepad";
  42829. }
  42830. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42831. import { Observable } from "babylonjs/Misc/observable";
  42832. import { Nullable } from "babylonjs/types";
  42833. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42835. import { Mesh } from "babylonjs/Meshes/mesh";
  42836. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42837. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42838. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42839. /**
  42840. * Single axis scale gizmo
  42841. */
  42842. export class AxisScaleGizmo extends Gizmo {
  42843. private _coloredMaterial;
  42844. /**
  42845. * Drag behavior responsible for the gizmos dragging interactions
  42846. */
  42847. dragBehavior: PointerDragBehavior;
  42848. private _pointerObserver;
  42849. /**
  42850. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42851. */
  42852. snapDistance: number;
  42853. /**
  42854. * Event that fires each time the gizmo snaps to a new location.
  42855. * * snapDistance is the the change in distance
  42856. */
  42857. onSnapObservable: Observable<{
  42858. snapDistance: number;
  42859. }>;
  42860. /**
  42861. * If the scaling operation should be done on all axis (default: false)
  42862. */
  42863. uniformScaling: boolean;
  42864. /**
  42865. * Creates an AxisScaleGizmo
  42866. * @param gizmoLayer The utility layer the gizmo will be added to
  42867. * @param dragAxis The axis which the gizmo will be able to scale on
  42868. * @param color The color of the gizmo
  42869. */
  42870. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42871. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42872. /**
  42873. * Disposes of the gizmo
  42874. */
  42875. dispose(): void;
  42876. /**
  42877. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42878. * @param mesh The mesh to replace the default mesh of the gizmo
  42879. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42880. */
  42881. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42882. }
  42883. }
  42884. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42885. import { Observable } from "babylonjs/Misc/observable";
  42886. import { Nullable } from "babylonjs/types";
  42887. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42889. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42890. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42891. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42892. /**
  42893. * Single plane rotation gizmo
  42894. */
  42895. export class PlaneRotationGizmo extends Gizmo {
  42896. /**
  42897. * Drag behavior responsible for the gizmos dragging interactions
  42898. */
  42899. dragBehavior: PointerDragBehavior;
  42900. private _pointerObserver;
  42901. /**
  42902. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42903. */
  42904. snapDistance: number;
  42905. /**
  42906. * Event that fires each time the gizmo snaps to a new location.
  42907. * * snapDistance is the the change in distance
  42908. */
  42909. onSnapObservable: Observable<{
  42910. snapDistance: number;
  42911. }>;
  42912. /**
  42913. * Creates a PlaneRotationGizmo
  42914. * @param gizmoLayer The utility layer the gizmo will be added to
  42915. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42916. * @param color The color of the gizmo
  42917. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42918. */
  42919. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42920. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42921. /**
  42922. * Disposes of the gizmo
  42923. */
  42924. dispose(): void;
  42925. }
  42926. }
  42927. declare module "babylonjs/Gizmos/rotationGizmo" {
  42928. import { Observable } from "babylonjs/Misc/observable";
  42929. import { Nullable } from "babylonjs/types";
  42930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42931. import { Mesh } from "babylonjs/Meshes/mesh";
  42932. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42933. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42935. /**
  42936. * Gizmo that enables rotating a mesh along 3 axis
  42937. */
  42938. export class RotationGizmo extends Gizmo {
  42939. /**
  42940. * Internal gizmo used for interactions on the x axis
  42941. */
  42942. xGizmo: PlaneRotationGizmo;
  42943. /**
  42944. * Internal gizmo used for interactions on the y axis
  42945. */
  42946. yGizmo: PlaneRotationGizmo;
  42947. /**
  42948. * Internal gizmo used for interactions on the z axis
  42949. */
  42950. zGizmo: PlaneRotationGizmo;
  42951. /** Fires an event when any of it's sub gizmos are dragged */
  42952. onDragStartObservable: Observable<{}>;
  42953. /** Fires an event when any of it's sub gizmos are released from dragging */
  42954. onDragEndObservable: Observable<{}>;
  42955. attachedMesh: Nullable<AbstractMesh>;
  42956. /**
  42957. * Creates a RotationGizmo
  42958. * @param gizmoLayer The utility layer the gizmo will be added to
  42959. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42960. */
  42961. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42962. updateGizmoRotationToMatchAttachedMesh: boolean;
  42963. /**
  42964. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42965. */
  42966. snapDistance: number;
  42967. /**
  42968. * Ratio for the scale of the gizmo (Default: 1)
  42969. */
  42970. scaleRatio: number;
  42971. /**
  42972. * Disposes of the gizmo
  42973. */
  42974. dispose(): void;
  42975. /**
  42976. * CustomMeshes are not supported by this gizmo
  42977. * @param mesh The mesh to replace the default mesh of the gizmo
  42978. */
  42979. setCustomMesh(mesh: Mesh): void;
  42980. }
  42981. }
  42982. declare module "babylonjs/Gizmos/positionGizmo" {
  42983. import { Observable } from "babylonjs/Misc/observable";
  42984. import { Nullable } from "babylonjs/types";
  42985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42986. import { Mesh } from "babylonjs/Meshes/mesh";
  42987. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42988. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42989. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42990. /**
  42991. * Gizmo that enables dragging a mesh along 3 axis
  42992. */
  42993. export class PositionGizmo extends Gizmo {
  42994. /**
  42995. * Internal gizmo used for interactions on the x axis
  42996. */
  42997. xGizmo: AxisDragGizmo;
  42998. /**
  42999. * Internal gizmo used for interactions on the y axis
  43000. */
  43001. yGizmo: AxisDragGizmo;
  43002. /**
  43003. * Internal gizmo used for interactions on the z axis
  43004. */
  43005. zGizmo: AxisDragGizmo;
  43006. /** Fires an event when any of it's sub gizmos are dragged */
  43007. onDragStartObservable: Observable<{}>;
  43008. /** Fires an event when any of it's sub gizmos are released from dragging */
  43009. onDragEndObservable: Observable<{}>;
  43010. attachedMesh: Nullable<AbstractMesh>;
  43011. /**
  43012. * Creates a PositionGizmo
  43013. * @param gizmoLayer The utility layer the gizmo will be added to
  43014. */
  43015. constructor(gizmoLayer?: UtilityLayerRenderer);
  43016. updateGizmoRotationToMatchAttachedMesh: boolean;
  43017. /**
  43018. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43019. */
  43020. snapDistance: number;
  43021. /**
  43022. * Ratio for the scale of the gizmo (Default: 1)
  43023. */
  43024. scaleRatio: number;
  43025. /**
  43026. * Disposes of the gizmo
  43027. */
  43028. dispose(): void;
  43029. /**
  43030. * CustomMeshes are not supported by this gizmo
  43031. * @param mesh The mesh to replace the default mesh of the gizmo
  43032. */
  43033. setCustomMesh(mesh: Mesh): void;
  43034. }
  43035. }
  43036. declare module "babylonjs/Gizmos/scaleGizmo" {
  43037. import { Observable } from "babylonjs/Misc/observable";
  43038. import { Nullable } from "babylonjs/types";
  43039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43040. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43041. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43042. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43043. /**
  43044. * Gizmo that enables scaling a mesh along 3 axis
  43045. */
  43046. export class ScaleGizmo extends Gizmo {
  43047. /**
  43048. * Internal gizmo used for interactions on the x axis
  43049. */
  43050. xGizmo: AxisScaleGizmo;
  43051. /**
  43052. * Internal gizmo used for interactions on the y axis
  43053. */
  43054. yGizmo: AxisScaleGizmo;
  43055. /**
  43056. * Internal gizmo used for interactions on the z axis
  43057. */
  43058. zGizmo: AxisScaleGizmo;
  43059. /**
  43060. * Internal gizmo used to scale all axis equally
  43061. */
  43062. uniformScaleGizmo: AxisScaleGizmo;
  43063. /** Fires an event when any of it's sub gizmos are dragged */
  43064. onDragStartObservable: Observable<{}>;
  43065. /** Fires an event when any of it's sub gizmos are released from dragging */
  43066. onDragEndObservable: Observable<{}>;
  43067. attachedMesh: Nullable<AbstractMesh>;
  43068. /**
  43069. * Creates a ScaleGizmo
  43070. * @param gizmoLayer The utility layer the gizmo will be added to
  43071. */
  43072. constructor(gizmoLayer?: UtilityLayerRenderer);
  43073. updateGizmoRotationToMatchAttachedMesh: boolean;
  43074. /**
  43075. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43076. */
  43077. snapDistance: number;
  43078. /**
  43079. * Ratio for the scale of the gizmo (Default: 1)
  43080. */
  43081. scaleRatio: number;
  43082. /**
  43083. * Disposes of the gizmo
  43084. */
  43085. dispose(): void;
  43086. }
  43087. }
  43088. declare module "babylonjs/Gizmos/gizmoManager" {
  43089. import { Observable } from "babylonjs/Misc/observable";
  43090. import { Nullable } from "babylonjs/types";
  43091. import { Scene, IDisposable } from "babylonjs/scene";
  43092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43093. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43094. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43095. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43096. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43097. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43098. /**
  43099. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43100. */
  43101. export class GizmoManager implements IDisposable {
  43102. private scene;
  43103. /**
  43104. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43105. */
  43106. gizmos: {
  43107. positionGizmo: Nullable<PositionGizmo>;
  43108. rotationGizmo: Nullable<RotationGizmo>;
  43109. scaleGizmo: Nullable<ScaleGizmo>;
  43110. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43111. };
  43112. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43113. clearGizmoOnEmptyPointerEvent: boolean;
  43114. /** Fires an event when the manager is attached to a mesh */
  43115. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43116. private _gizmosEnabled;
  43117. private _pointerObserver;
  43118. private _attachedMesh;
  43119. private _boundingBoxColor;
  43120. private _defaultUtilityLayer;
  43121. private _defaultKeepDepthUtilityLayer;
  43122. /**
  43123. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43124. */
  43125. boundingBoxDragBehavior: SixDofDragBehavior;
  43126. /**
  43127. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43128. */
  43129. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43130. /**
  43131. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43132. */
  43133. usePointerToAttachGizmos: boolean;
  43134. /**
  43135. * Instatiates a gizmo manager
  43136. * @param scene the scene to overlay the gizmos on top of
  43137. */
  43138. constructor(scene: Scene);
  43139. /**
  43140. * Attaches a set of gizmos to the specified mesh
  43141. * @param mesh The mesh the gizmo's should be attached to
  43142. */
  43143. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43144. /**
  43145. * If the position gizmo is enabled
  43146. */
  43147. positionGizmoEnabled: boolean;
  43148. /**
  43149. * If the rotation gizmo is enabled
  43150. */
  43151. rotationGizmoEnabled: boolean;
  43152. /**
  43153. * If the scale gizmo is enabled
  43154. */
  43155. scaleGizmoEnabled: boolean;
  43156. /**
  43157. * If the boundingBox gizmo is enabled
  43158. */
  43159. boundingBoxGizmoEnabled: boolean;
  43160. /**
  43161. * Disposes of the gizmo manager
  43162. */
  43163. dispose(): void;
  43164. }
  43165. }
  43166. declare module "babylonjs/Gizmos/index" {
  43167. export * from "babylonjs/Gizmos/axisDragGizmo";
  43168. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43169. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43170. export * from "babylonjs/Gizmos/gizmo";
  43171. export * from "babylonjs/Gizmos/gizmoManager";
  43172. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43173. export * from "babylonjs/Gizmos/positionGizmo";
  43174. export * from "babylonjs/Gizmos/rotationGizmo";
  43175. export * from "babylonjs/Gizmos/scaleGizmo";
  43176. }
  43177. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43178. export var backgroundFragmentDeclaration: {
  43179. name: string;
  43180. shader: string;
  43181. };
  43182. }
  43183. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43184. export var backgroundUboDeclaration: {
  43185. name: string;
  43186. shader: string;
  43187. };
  43188. }
  43189. declare module "babylonjs/Shaders/background.fragment" {
  43190. import "Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43191. import "Shaders/ShadersInclude/backgroundUboDeclaration";
  43192. import "Shaders/ShadersInclude/reflectionFunction";
  43193. import "Shaders/ShadersInclude/imageProcessingDeclaration";
  43194. import "Shaders/ShadersInclude/lightFragmentDeclaration";
  43195. import "Shaders/ShadersInclude/lightUboDeclaration";
  43196. import "Shaders/ShadersInclude/helperFunctions";
  43197. import "Shaders/ShadersInclude/lightsFragmentFunctions";
  43198. import "Shaders/ShadersInclude/shadowsFragmentFunctions";
  43199. import "Shaders/ShadersInclude/imageProcessingFunctions";
  43200. import "Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43201. import "Shaders/ShadersInclude/fogFragmentDeclaration";
  43202. import "Shaders/ShadersInclude/clipPlaneFragment";
  43203. import "Shaders/ShadersInclude/lightFragment";
  43204. import "Shaders/ShadersInclude/fogFragment";
  43205. export var backgroundPixelShader: {
  43206. name: string;
  43207. shader: string;
  43208. };
  43209. }
  43210. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43211. export var backgroundVertexDeclaration: {
  43212. name: string;
  43213. shader: string;
  43214. };
  43215. }
  43216. declare module "babylonjs/Shaders/background.vertex" {
  43217. import "Shaders/ShadersInclude/backgroundVertexDeclaration";
  43218. import "Shaders/ShadersInclude/backgroundUboDeclaration";
  43219. import "Shaders/ShadersInclude/helperFunctions";
  43220. import "Shaders/ShadersInclude/bonesDeclaration";
  43221. import "Shaders/ShadersInclude/instancesDeclaration";
  43222. import "Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43223. import "Shaders/ShadersInclude/fogVertexDeclaration";
  43224. import "Shaders/ShadersInclude/lightFragmentDeclaration";
  43225. import "Shaders/ShadersInclude/lightUboDeclaration";
  43226. import "Shaders/ShadersInclude/instancesVertex";
  43227. import "Shaders/ShadersInclude/bonesVertex";
  43228. import "Shaders/ShadersInclude/clipPlaneVertex";
  43229. import "Shaders/ShadersInclude/fogVertex";
  43230. import "Shaders/ShadersInclude/shadowsVertex";
  43231. export var backgroundVertexShader: {
  43232. name: string;
  43233. shader: string;
  43234. };
  43235. }
  43236. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43237. import { Nullable, int, float } from "babylonjs/types";
  43238. import { Scene } from "babylonjs/scene";
  43239. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43242. import { Mesh } from "babylonjs/Meshes/mesh";
  43243. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43244. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43245. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43247. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43248. import "Shaders/background.fragment";
  43249. import "Shaders/background.vertex";
  43250. /**
  43251. * Background material used to create an efficient environement around your scene.
  43252. */
  43253. export class BackgroundMaterial extends PushMaterial {
  43254. /**
  43255. * Standard reflectance value at parallel view angle.
  43256. */
  43257. static StandardReflectance0: number;
  43258. /**
  43259. * Standard reflectance value at grazing angle.
  43260. */
  43261. static StandardReflectance90: number;
  43262. protected _primaryColor: Color3;
  43263. /**
  43264. * Key light Color (multiply against the environement texture)
  43265. */
  43266. primaryColor: Color3;
  43267. protected __perceptualColor: Nullable<Color3>;
  43268. /**
  43269. * Experimental Internal Use Only.
  43270. *
  43271. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43272. * This acts as a helper to set the primary color to a more "human friendly" value.
  43273. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43274. * output color as close as possible from the chosen value.
  43275. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43276. * part of lighting setup.)
  43277. */
  43278. _perceptualColor: Nullable<Color3>;
  43279. protected _primaryColorShadowLevel: float;
  43280. /**
  43281. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43282. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43283. */
  43284. primaryColorShadowLevel: float;
  43285. protected _primaryColorHighlightLevel: float;
  43286. /**
  43287. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43288. * The primary color is used at the level chosen to define what the white area would look.
  43289. */
  43290. primaryColorHighlightLevel: float;
  43291. protected _reflectionTexture: Nullable<BaseTexture>;
  43292. /**
  43293. * Reflection Texture used in the material.
  43294. * Should be author in a specific way for the best result (refer to the documentation).
  43295. */
  43296. reflectionTexture: Nullable<BaseTexture>;
  43297. protected _reflectionBlur: float;
  43298. /**
  43299. * Reflection Texture level of blur.
  43300. *
  43301. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43302. * texture twice.
  43303. */
  43304. reflectionBlur: float;
  43305. protected _diffuseTexture: Nullable<BaseTexture>;
  43306. /**
  43307. * Diffuse Texture used in the material.
  43308. * Should be author in a specific way for the best result (refer to the documentation).
  43309. */
  43310. diffuseTexture: Nullable<BaseTexture>;
  43311. protected _shadowLights: Nullable<IShadowLight[]>;
  43312. /**
  43313. * Specify the list of lights casting shadow on the material.
  43314. * All scene shadow lights will be included if null.
  43315. */
  43316. shadowLights: Nullable<IShadowLight[]>;
  43317. protected _shadowLevel: float;
  43318. /**
  43319. * Helps adjusting the shadow to a softer level if required.
  43320. * 0 means black shadows and 1 means no shadows.
  43321. */
  43322. shadowLevel: float;
  43323. protected _sceneCenter: Vector3;
  43324. /**
  43325. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43326. * It is usually zero but might be interesting to modify according to your setup.
  43327. */
  43328. sceneCenter: Vector3;
  43329. protected _opacityFresnel: boolean;
  43330. /**
  43331. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43332. * This helps ensuring a nice transition when the camera goes under the ground.
  43333. */
  43334. opacityFresnel: boolean;
  43335. protected _reflectionFresnel: boolean;
  43336. /**
  43337. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43338. * This helps adding a mirror texture on the ground.
  43339. */
  43340. reflectionFresnel: boolean;
  43341. protected _reflectionFalloffDistance: number;
  43342. /**
  43343. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43344. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43345. */
  43346. reflectionFalloffDistance: number;
  43347. protected _reflectionAmount: number;
  43348. /**
  43349. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43350. */
  43351. reflectionAmount: number;
  43352. protected _reflectionReflectance0: number;
  43353. /**
  43354. * This specifies the weight of the reflection at grazing angle.
  43355. */
  43356. reflectionReflectance0: number;
  43357. protected _reflectionReflectance90: number;
  43358. /**
  43359. * This specifies the weight of the reflection at a perpendicular point of view.
  43360. */
  43361. reflectionReflectance90: number;
  43362. /**
  43363. * Sets the reflection reflectance fresnel values according to the default standard
  43364. * empirically know to work well :-)
  43365. */
  43366. reflectionStandardFresnelWeight: number;
  43367. protected _useRGBColor: boolean;
  43368. /**
  43369. * Helps to directly use the maps channels instead of their level.
  43370. */
  43371. useRGBColor: boolean;
  43372. protected _enableNoise: boolean;
  43373. /**
  43374. * This helps reducing the banding effect that could occur on the background.
  43375. */
  43376. enableNoise: boolean;
  43377. /**
  43378. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43379. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43380. * Recommended to be keep at 1.0 except for special cases.
  43381. */
  43382. fovMultiplier: number;
  43383. private _fovMultiplier;
  43384. /**
  43385. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43386. */
  43387. useEquirectangularFOV: boolean;
  43388. private _maxSimultaneousLights;
  43389. /**
  43390. * Number of Simultaneous lights allowed on the material.
  43391. */
  43392. maxSimultaneousLights: int;
  43393. /**
  43394. * Default configuration related to image processing available in the Background Material.
  43395. */
  43396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43397. /**
  43398. * Keep track of the image processing observer to allow dispose and replace.
  43399. */
  43400. private _imageProcessingObserver;
  43401. /**
  43402. * Attaches a new image processing configuration to the PBR Material.
  43403. * @param configuration (if null the scene configuration will be use)
  43404. */
  43405. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43406. /**
  43407. * Gets the image processing configuration used either in this material.
  43408. */
  43409. /**
  43410. * Sets the Default image processing configuration used either in the this material.
  43411. *
  43412. * If sets to null, the scene one is in use.
  43413. */
  43414. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43415. /**
  43416. * Gets wether the color curves effect is enabled.
  43417. */
  43418. /**
  43419. * Sets wether the color curves effect is enabled.
  43420. */
  43421. cameraColorCurvesEnabled: boolean;
  43422. /**
  43423. * Gets wether the color grading effect is enabled.
  43424. */
  43425. /**
  43426. * Gets wether the color grading effect is enabled.
  43427. */
  43428. cameraColorGradingEnabled: boolean;
  43429. /**
  43430. * Gets wether tonemapping is enabled or not.
  43431. */
  43432. /**
  43433. * Sets wether tonemapping is enabled or not
  43434. */
  43435. cameraToneMappingEnabled: boolean;
  43436. /**
  43437. * The camera exposure used on this material.
  43438. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43439. * This corresponds to a photographic exposure.
  43440. */
  43441. /**
  43442. * The camera exposure used on this material.
  43443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43444. * This corresponds to a photographic exposure.
  43445. */
  43446. cameraExposure: float;
  43447. /**
  43448. * Gets The camera contrast used on this material.
  43449. */
  43450. /**
  43451. * Sets The camera contrast used on this material.
  43452. */
  43453. cameraContrast: float;
  43454. /**
  43455. * Gets the Color Grading 2D Lookup Texture.
  43456. */
  43457. /**
  43458. * Sets the Color Grading 2D Lookup Texture.
  43459. */
  43460. cameraColorGradingTexture: Nullable<BaseTexture>;
  43461. /**
  43462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43464. * 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;
  43465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43466. */
  43467. /**
  43468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43470. * 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;
  43471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43472. */
  43473. cameraColorCurves: Nullable<ColorCurves>;
  43474. /**
  43475. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43476. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43477. */
  43478. switchToBGR: boolean;
  43479. private _renderTargets;
  43480. private _reflectionControls;
  43481. private _white;
  43482. private _primaryShadowColor;
  43483. private _primaryHighlightColor;
  43484. /**
  43485. * Instantiates a Background Material in the given scene
  43486. * @param name The friendly name of the material
  43487. * @param scene The scene to add the material to
  43488. */
  43489. constructor(name: string, scene: Scene);
  43490. /**
  43491. * Gets a boolean indicating that current material needs to register RTT
  43492. */
  43493. readonly hasRenderTargetTextures: boolean;
  43494. /**
  43495. * The entire material has been created in order to prevent overdraw.
  43496. * @returns false
  43497. */
  43498. needAlphaTesting(): boolean;
  43499. /**
  43500. * The entire material has been created in order to prevent overdraw.
  43501. * @returns true if blending is enable
  43502. */
  43503. needAlphaBlending(): boolean;
  43504. /**
  43505. * Checks wether the material is ready to be rendered for a given mesh.
  43506. * @param mesh The mesh to render
  43507. * @param subMesh The submesh to check against
  43508. * @param useInstances Specify wether or not the material is used with instances
  43509. * @returns true if all the dependencies are ready (Textures, Effects...)
  43510. */
  43511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43512. /**
  43513. * Compute the primary color according to the chosen perceptual color.
  43514. */
  43515. private _computePrimaryColorFromPerceptualColor;
  43516. /**
  43517. * Compute the highlights and shadow colors according to their chosen levels.
  43518. */
  43519. private _computePrimaryColors;
  43520. /**
  43521. * Build the uniform buffer used in the material.
  43522. */
  43523. buildUniformLayout(): void;
  43524. /**
  43525. * Unbind the material.
  43526. */
  43527. unbind(): void;
  43528. /**
  43529. * Bind only the world matrix to the material.
  43530. * @param world The world matrix to bind.
  43531. */
  43532. bindOnlyWorldMatrix(world: Matrix): void;
  43533. /**
  43534. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43535. * @param world The world matrix to bind.
  43536. * @param subMesh The submesh to bind for.
  43537. */
  43538. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43539. /**
  43540. * Dispose the material.
  43541. * @param forceDisposeEffect Force disposal of the associated effect.
  43542. * @param forceDisposeTextures Force disposal of the associated textures.
  43543. */
  43544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43545. /**
  43546. * Clones the material.
  43547. * @param name The cloned name.
  43548. * @returns The cloned material.
  43549. */
  43550. clone(name: string): BackgroundMaterial;
  43551. /**
  43552. * Serializes the current material to its JSON representation.
  43553. * @returns The JSON representation.
  43554. */
  43555. serialize(): any;
  43556. /**
  43557. * Gets the class name of the material
  43558. * @returns "BackgroundMaterial"
  43559. */
  43560. getClassName(): string;
  43561. /**
  43562. * Parse a JSON input to create back a background material.
  43563. * @param source The JSON data to parse
  43564. * @param scene The scene to create the parsed material in
  43565. * @param rootUrl The root url of the assets the material depends upon
  43566. * @returns the instantiated BackgroundMaterial.
  43567. */
  43568. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43569. }
  43570. }
  43571. declare module "babylonjs/Helpers/environmentHelper" {
  43572. import { Observable } from "babylonjs/Misc/observable";
  43573. import { Nullable } from "babylonjs/types";
  43574. import { Scene } from "babylonjs/scene";
  43575. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43577. import { Mesh } from "babylonjs/Meshes/mesh";
  43578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43579. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43580. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43581. /**
  43582. * Represents the different options available during the creation of
  43583. * a Environment helper.
  43584. *
  43585. * This can control the default ground, skybox and image processing setup of your scene.
  43586. */
  43587. export interface IEnvironmentHelperOptions {
  43588. /**
  43589. * Specifies wether or not to create a ground.
  43590. * True by default.
  43591. */
  43592. createGround: boolean;
  43593. /**
  43594. * Specifies the ground size.
  43595. * 15 by default.
  43596. */
  43597. groundSize: number;
  43598. /**
  43599. * The texture used on the ground for the main color.
  43600. * Comes from the BabylonJS CDN by default.
  43601. *
  43602. * Remarks: Can be either a texture or a url.
  43603. */
  43604. groundTexture: string | BaseTexture;
  43605. /**
  43606. * The color mixed in the ground texture by default.
  43607. * BabylonJS clearColor by default.
  43608. */
  43609. groundColor: Color3;
  43610. /**
  43611. * Specifies the ground opacity.
  43612. * 1 by default.
  43613. */
  43614. groundOpacity: number;
  43615. /**
  43616. * Enables the ground to receive shadows.
  43617. * True by default.
  43618. */
  43619. enableGroundShadow: boolean;
  43620. /**
  43621. * Helps preventing the shadow to be fully black on the ground.
  43622. * 0.5 by default.
  43623. */
  43624. groundShadowLevel: number;
  43625. /**
  43626. * Creates a mirror texture attach to the ground.
  43627. * false by default.
  43628. */
  43629. enableGroundMirror: boolean;
  43630. /**
  43631. * Specifies the ground mirror size ratio.
  43632. * 0.3 by default as the default kernel is 64.
  43633. */
  43634. groundMirrorSizeRatio: number;
  43635. /**
  43636. * Specifies the ground mirror blur kernel size.
  43637. * 64 by default.
  43638. */
  43639. groundMirrorBlurKernel: number;
  43640. /**
  43641. * Specifies the ground mirror visibility amount.
  43642. * 1 by default
  43643. */
  43644. groundMirrorAmount: number;
  43645. /**
  43646. * Specifies the ground mirror reflectance weight.
  43647. * This uses the standard weight of the background material to setup the fresnel effect
  43648. * of the mirror.
  43649. * 1 by default.
  43650. */
  43651. groundMirrorFresnelWeight: number;
  43652. /**
  43653. * Specifies the ground mirror Falloff distance.
  43654. * This can helps reducing the size of the reflection.
  43655. * 0 by Default.
  43656. */
  43657. groundMirrorFallOffDistance: number;
  43658. /**
  43659. * Specifies the ground mirror texture type.
  43660. * Unsigned Int by Default.
  43661. */
  43662. groundMirrorTextureType: number;
  43663. /**
  43664. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43665. * the shown objects.
  43666. */
  43667. groundYBias: number;
  43668. /**
  43669. * Specifies wether or not to create a skybox.
  43670. * True by default.
  43671. */
  43672. createSkybox: boolean;
  43673. /**
  43674. * Specifies the skybox size.
  43675. * 20 by default.
  43676. */
  43677. skyboxSize: number;
  43678. /**
  43679. * The texture used on the skybox for the main color.
  43680. * Comes from the BabylonJS CDN by default.
  43681. *
  43682. * Remarks: Can be either a texture or a url.
  43683. */
  43684. skyboxTexture: string | BaseTexture;
  43685. /**
  43686. * The color mixed in the skybox texture by default.
  43687. * BabylonJS clearColor by default.
  43688. */
  43689. skyboxColor: Color3;
  43690. /**
  43691. * The background rotation around the Y axis of the scene.
  43692. * This helps aligning the key lights of your scene with the background.
  43693. * 0 by default.
  43694. */
  43695. backgroundYRotation: number;
  43696. /**
  43697. * Compute automatically the size of the elements to best fit with the scene.
  43698. */
  43699. sizeAuto: boolean;
  43700. /**
  43701. * Default position of the rootMesh if autoSize is not true.
  43702. */
  43703. rootPosition: Vector3;
  43704. /**
  43705. * Sets up the image processing in the scene.
  43706. * true by default.
  43707. */
  43708. setupImageProcessing: boolean;
  43709. /**
  43710. * The texture used as your environment texture in the scene.
  43711. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43712. *
  43713. * Remarks: Can be either a texture or a url.
  43714. */
  43715. environmentTexture: string | BaseTexture;
  43716. /**
  43717. * The value of the exposure to apply to the scene.
  43718. * 0.6 by default if setupImageProcessing is true.
  43719. */
  43720. cameraExposure: number;
  43721. /**
  43722. * The value of the contrast to apply to the scene.
  43723. * 1.6 by default if setupImageProcessing is true.
  43724. */
  43725. cameraContrast: number;
  43726. /**
  43727. * Specifies wether or not tonemapping should be enabled in the scene.
  43728. * true by default if setupImageProcessing is true.
  43729. */
  43730. toneMappingEnabled: boolean;
  43731. }
  43732. /**
  43733. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43734. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43735. * It also helps with the default setup of your imageProcessing configuration.
  43736. */
  43737. export class EnvironmentHelper {
  43738. /**
  43739. * Default ground texture URL.
  43740. */
  43741. private static _groundTextureCDNUrl;
  43742. /**
  43743. * Default skybox texture URL.
  43744. */
  43745. private static _skyboxTextureCDNUrl;
  43746. /**
  43747. * Default environment texture URL.
  43748. */
  43749. private static _environmentTextureCDNUrl;
  43750. /**
  43751. * Creates the default options for the helper.
  43752. */
  43753. private static _getDefaultOptions;
  43754. private _rootMesh;
  43755. /**
  43756. * Gets the root mesh created by the helper.
  43757. */
  43758. readonly rootMesh: Mesh;
  43759. private _skybox;
  43760. /**
  43761. * Gets the skybox created by the helper.
  43762. */
  43763. readonly skybox: Nullable<Mesh>;
  43764. private _skyboxTexture;
  43765. /**
  43766. * Gets the skybox texture created by the helper.
  43767. */
  43768. readonly skyboxTexture: Nullable<BaseTexture>;
  43769. private _skyboxMaterial;
  43770. /**
  43771. * Gets the skybox material created by the helper.
  43772. */
  43773. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43774. private _ground;
  43775. /**
  43776. * Gets the ground mesh created by the helper.
  43777. */
  43778. readonly ground: Nullable<Mesh>;
  43779. private _groundTexture;
  43780. /**
  43781. * Gets the ground texture created by the helper.
  43782. */
  43783. readonly groundTexture: Nullable<BaseTexture>;
  43784. private _groundMirror;
  43785. /**
  43786. * Gets the ground mirror created by the helper.
  43787. */
  43788. readonly groundMirror: Nullable<MirrorTexture>;
  43789. /**
  43790. * Gets the ground mirror render list to helps pushing the meshes
  43791. * you wish in the ground reflection.
  43792. */
  43793. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43794. private _groundMaterial;
  43795. /**
  43796. * Gets the ground material created by the helper.
  43797. */
  43798. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43799. /**
  43800. * Stores the creation options.
  43801. */
  43802. private readonly _scene;
  43803. private _options;
  43804. /**
  43805. * This observable will be notified with any error during the creation of the environment,
  43806. * mainly texture creation errors.
  43807. */
  43808. onErrorObservable: Observable<{
  43809. message?: string;
  43810. exception?: any;
  43811. }>;
  43812. /**
  43813. * constructor
  43814. * @param options
  43815. * @param scene The scene to add the material to
  43816. */
  43817. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43818. /**
  43819. * Updates the background according to the new options
  43820. * @param options
  43821. */
  43822. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43823. /**
  43824. * Sets the primary color of all the available elements.
  43825. * @param color the main color to affect to the ground and the background
  43826. */
  43827. setMainColor(color: Color3): void;
  43828. /**
  43829. * Setup the image processing according to the specified options.
  43830. */
  43831. private _setupImageProcessing;
  43832. /**
  43833. * Setup the environment texture according to the specified options.
  43834. */
  43835. private _setupEnvironmentTexture;
  43836. /**
  43837. * Setup the background according to the specified options.
  43838. */
  43839. private _setupBackground;
  43840. /**
  43841. * Get the scene sizes according to the setup.
  43842. */
  43843. private _getSceneSize;
  43844. /**
  43845. * Setup the ground according to the specified options.
  43846. */
  43847. private _setupGround;
  43848. /**
  43849. * Setup the ground material according to the specified options.
  43850. */
  43851. private _setupGroundMaterial;
  43852. /**
  43853. * Setup the ground diffuse texture according to the specified options.
  43854. */
  43855. private _setupGroundDiffuseTexture;
  43856. /**
  43857. * Setup the ground mirror texture according to the specified options.
  43858. */
  43859. private _setupGroundMirrorTexture;
  43860. /**
  43861. * Setup the ground to receive the mirror texture.
  43862. */
  43863. private _setupMirrorInGroundMaterial;
  43864. /**
  43865. * Setup the skybox according to the specified options.
  43866. */
  43867. private _setupSkybox;
  43868. /**
  43869. * Setup the skybox material according to the specified options.
  43870. */
  43871. private _setupSkyboxMaterial;
  43872. /**
  43873. * Setup the skybox reflection texture according to the specified options.
  43874. */
  43875. private _setupSkyboxReflectionTexture;
  43876. private _errorHandler;
  43877. /**
  43878. * Dispose all the elements created by the Helper.
  43879. */
  43880. dispose(): void;
  43881. }
  43882. }
  43883. declare module "babylonjs/Helpers/photoDome" {
  43884. import { Observable } from "babylonjs/Misc/observable";
  43885. import { Nullable } from "babylonjs/types";
  43886. import { Scene } from "babylonjs/scene";
  43887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43888. import { Mesh } from "babylonjs/Meshes/mesh";
  43889. import { Texture } from "babylonjs/Materials/Textures/texture";
  43890. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43891. /**
  43892. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43893. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43894. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43895. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43896. */
  43897. export class PhotoDome extends TransformNode {
  43898. private _useDirectMapping;
  43899. /**
  43900. * The texture being displayed on the sphere
  43901. */
  43902. protected _photoTexture: Texture;
  43903. /**
  43904. * Gets or sets the texture being displayed on the sphere
  43905. */
  43906. photoTexture: Texture;
  43907. /**
  43908. * Observable raised when an error occured while loading the 360 image
  43909. */
  43910. onLoadErrorObservable: Observable<string>;
  43911. /**
  43912. * The skybox material
  43913. */
  43914. protected _material: BackgroundMaterial;
  43915. /**
  43916. * The surface used for the skybox
  43917. */
  43918. protected _mesh: Mesh;
  43919. /**
  43920. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43921. * Also see the options.resolution property.
  43922. */
  43923. fovMultiplier: number;
  43924. /**
  43925. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43926. * @param name Element's name, child elements will append suffixes for their own names.
  43927. * @param urlsOfPhoto defines the url of the photo to display
  43928. * @param options defines an object containing optional or exposed sub element properties
  43929. * @param onError defines a callback called when an error occured while loading the texture
  43930. */
  43931. constructor(name: string, urlOfPhoto: string, options: {
  43932. resolution?: number;
  43933. size?: number;
  43934. useDirectMapping?: boolean;
  43935. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43936. /**
  43937. * Releases resources associated with this node.
  43938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43940. */
  43941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43942. }
  43943. }
  43944. declare module "babylonjs/Misc/textureTools" {
  43945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43946. import { Texture } from "babylonjs/Materials/Textures/texture";
  43947. import { Scene } from "babylonjs/scene";
  43948. /**
  43949. * Class used to host texture specific utilities
  43950. */
  43951. export class TextureTools {
  43952. /**
  43953. * Uses the GPU to create a copy texture rescaled at a given size
  43954. * @param texture Texture to copy from
  43955. * @param width defines the desired width
  43956. * @param height defines the desired height
  43957. * @param useBilinearMode defines if bilinear mode has to be used
  43958. * @return the generated texture
  43959. */
  43960. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43961. /**
  43962. * Gets an environment BRDF texture for a given scene
  43963. * @param scene defines the hosting scene
  43964. * @returns the environment BRDF texture
  43965. */
  43966. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43967. private static _environmentBRDFBase64Texture;
  43968. }
  43969. }
  43970. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43971. export var pbrFragmentDeclaration: {
  43972. name: string;
  43973. shader: string;
  43974. };
  43975. }
  43976. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43977. export var pbrUboDeclaration: {
  43978. name: string;
  43979. shader: string;
  43980. };
  43981. }
  43982. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43983. export var pbrFunctions: {
  43984. name: string;
  43985. shader: string;
  43986. };
  43987. }
  43988. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43989. export var harmonicsFunctions: {
  43990. name: string;
  43991. shader: string;
  43992. };
  43993. }
  43994. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43995. export var pbrLightFunctions: {
  43996. name: string;
  43997. shader: string;
  43998. };
  43999. }
  44000. declare module "babylonjs/Shaders/pbr.fragment" {
  44001. import "Shaders/ShadersInclude/pbrFragmentDeclaration";
  44002. import "Shaders/ShadersInclude/pbrUboDeclaration";
  44003. import "Shaders/ShadersInclude/lightFragmentDeclaration";
  44004. import "Shaders/ShadersInclude/lightUboDeclaration";
  44005. import "Shaders/ShadersInclude/reflectionFunction";
  44006. import "Shaders/ShadersInclude/imageProcessingDeclaration";
  44007. import "Shaders/ShadersInclude/helperFunctions";
  44008. import "Shaders/ShadersInclude/imageProcessingFunctions";
  44009. import "Shaders/ShadersInclude/shadowsFragmentFunctions";
  44010. import "Shaders/ShadersInclude/pbrFunctions";
  44011. import "Shaders/ShadersInclude/harmonicsFunctions";
  44012. import "Shaders/ShadersInclude/pbrLightFunctions";
  44013. import "Shaders/ShadersInclude/bumpFragmentFunctions";
  44014. import "Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44015. import "Shaders/ShadersInclude/logDepthDeclaration";
  44016. import "Shaders/ShadersInclude/fogFragmentDeclaration";
  44017. import "Shaders/ShadersInclude/clipPlaneFragment";
  44018. import "Shaders/ShadersInclude/bumpFragment";
  44019. import "Shaders/ShadersInclude/depthPrePass";
  44020. import "Shaders/ShadersInclude/lightFragment";
  44021. import "Shaders/ShadersInclude/logDepthFragment";
  44022. import "Shaders/ShadersInclude/fogFragment";
  44023. export var pbrPixelShader: {
  44024. name: string;
  44025. shader: string;
  44026. };
  44027. }
  44028. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44029. export var pbrVertexDeclaration: {
  44030. name: string;
  44031. shader: string;
  44032. };
  44033. }
  44034. declare module "babylonjs/Shaders/pbr.vertex" {
  44035. import "Shaders/ShadersInclude/pbrVertexDeclaration";
  44036. import "Shaders/ShadersInclude/pbrUboDeclaration";
  44037. import "Shaders/ShadersInclude/helperFunctions";
  44038. import "Shaders/ShadersInclude/bonesDeclaration";
  44039. import "Shaders/ShadersInclude/instancesDeclaration";
  44040. import "Shaders/ShadersInclude/harmonicsFunctions";
  44041. import "Shaders/ShadersInclude/bumpVertexDeclaration";
  44042. import "Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44043. import "Shaders/ShadersInclude/fogVertexDeclaration";
  44044. import "Shaders/ShadersInclude/lightFragmentDeclaration";
  44045. import "Shaders/ShadersInclude/lightUboDeclaration";
  44046. import "Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44047. import "Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44048. import "Shaders/ShadersInclude/logDepthDeclaration";
  44049. import "Shaders/ShadersInclude/morphTargetsVertex";
  44050. import "Shaders/ShadersInclude/instancesVertex";
  44051. import "Shaders/ShadersInclude/bonesVertex";
  44052. import "Shaders/ShadersInclude/bumpVertex";
  44053. import "Shaders/ShadersInclude/clipPlaneVertex";
  44054. import "Shaders/ShadersInclude/fogVertex";
  44055. import "Shaders/ShadersInclude/shadowsVertex";
  44056. import "Shaders/ShadersInclude/logDepthVertex";
  44057. export var pbrVertexShader: {
  44058. name: string;
  44059. shader: string;
  44060. };
  44061. }
  44062. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44063. import { IAnimatable } from "babylonjs/Misc/tools";
  44064. import { Nullable } from "babylonjs/types";
  44065. import { Scene } from "babylonjs/scene";
  44066. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44067. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44069. import { Mesh } from "babylonjs/Meshes/mesh";
  44070. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44071. import { Material } from "babylonjs/Materials/material";
  44072. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44074. import "Shaders/pbr.fragment";
  44075. import "Shaders/pbr.vertex";
  44076. /**
  44077. * The Physically based material base class of BJS.
  44078. *
  44079. * This offers the main features of a standard PBR material.
  44080. * For more information, please refer to the documentation :
  44081. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44082. */
  44083. export abstract class PBRBaseMaterial extends PushMaterial {
  44084. /**
  44085. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44086. */
  44087. static readonly PBRMATERIAL_OPAQUE: number;
  44088. /**
  44089. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44090. */
  44091. static readonly PBRMATERIAL_ALPHATEST: number;
  44092. /**
  44093. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44094. */
  44095. static readonly PBRMATERIAL_ALPHABLEND: number;
  44096. /**
  44097. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44098. * They are also discarded below the alpha cutoff threshold to improve performances.
  44099. */
  44100. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44101. /**
  44102. * Defines the default value of how much AO map is occluding the analytical lights
  44103. * (point spot...).
  44104. */
  44105. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44106. /**
  44107. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44108. */
  44109. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44110. /**
  44111. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44112. * to enhance interoperability with other engines.
  44113. */
  44114. static readonly LIGHTFALLOFF_GLTF: number;
  44115. /**
  44116. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44117. * to enhance interoperability with other materials.
  44118. */
  44119. static readonly LIGHTFALLOFF_STANDARD: number;
  44120. /**
  44121. * Intensity of the direct lights e.g. the four lights available in your scene.
  44122. * This impacts both the direct diffuse and specular highlights.
  44123. */
  44124. protected _directIntensity: number;
  44125. /**
  44126. * Intensity of the emissive part of the material.
  44127. * This helps controlling the emissive effect without modifying the emissive color.
  44128. */
  44129. protected _emissiveIntensity: number;
  44130. /**
  44131. * Intensity of the environment e.g. how much the environment will light the object
  44132. * either through harmonics for rough material or through the refelction for shiny ones.
  44133. */
  44134. protected _environmentIntensity: number;
  44135. /**
  44136. * This is a special control allowing the reduction of the specular highlights coming from the
  44137. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44138. */
  44139. protected _specularIntensity: number;
  44140. /**
  44141. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44142. */
  44143. private _lightingInfos;
  44144. /**
  44145. * Debug Control allowing disabling the bump map on this material.
  44146. */
  44147. protected _disableBumpMap: boolean;
  44148. /**
  44149. * AKA Diffuse Texture in standard nomenclature.
  44150. */
  44151. protected _albedoTexture: BaseTexture;
  44152. /**
  44153. * AKA Occlusion Texture in other nomenclature.
  44154. */
  44155. protected _ambientTexture: BaseTexture;
  44156. /**
  44157. * AKA Occlusion Texture Intensity in other nomenclature.
  44158. */
  44159. protected _ambientTextureStrength: number;
  44160. /**
  44161. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44162. * 1 means it completely occludes it
  44163. * 0 mean it has no impact
  44164. */
  44165. protected _ambientTextureImpactOnAnalyticalLights: number;
  44166. /**
  44167. * Stores the alpha values in a texture.
  44168. */
  44169. protected _opacityTexture: BaseTexture;
  44170. /**
  44171. * Stores the reflection values in a texture.
  44172. */
  44173. protected _reflectionTexture: BaseTexture;
  44174. /**
  44175. * Stores the refraction values in a texture.
  44176. */
  44177. protected _refractionTexture: BaseTexture;
  44178. /**
  44179. * Stores the emissive values in a texture.
  44180. */
  44181. protected _emissiveTexture: BaseTexture;
  44182. /**
  44183. * AKA Specular texture in other nomenclature.
  44184. */
  44185. protected _reflectivityTexture: BaseTexture;
  44186. /**
  44187. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44188. */
  44189. protected _metallicTexture: BaseTexture;
  44190. /**
  44191. * Specifies the metallic scalar of the metallic/roughness workflow.
  44192. * Can also be used to scale the metalness values of the metallic texture.
  44193. */
  44194. protected _metallic: Nullable<number>;
  44195. /**
  44196. * Specifies the roughness scalar of the metallic/roughness workflow.
  44197. * Can also be used to scale the roughness values of the metallic texture.
  44198. */
  44199. protected _roughness: Nullable<number>;
  44200. /**
  44201. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44202. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44203. */
  44204. protected _microSurfaceTexture: BaseTexture;
  44205. /**
  44206. * Stores surface normal data used to displace a mesh in a texture.
  44207. */
  44208. protected _bumpTexture: BaseTexture;
  44209. /**
  44210. * Stores the pre-calculated light information of a mesh in a texture.
  44211. */
  44212. protected _lightmapTexture: BaseTexture;
  44213. /**
  44214. * The color of a material in ambient lighting.
  44215. */
  44216. protected _ambientColor: Color3;
  44217. /**
  44218. * AKA Diffuse Color in other nomenclature.
  44219. */
  44220. protected _albedoColor: Color3;
  44221. /**
  44222. * AKA Specular Color in other nomenclature.
  44223. */
  44224. protected _reflectivityColor: Color3;
  44225. /**
  44226. * The color applied when light is reflected from a material.
  44227. */
  44228. protected _reflectionColor: Color3;
  44229. /**
  44230. * The color applied when light is emitted from a material.
  44231. */
  44232. protected _emissiveColor: Color3;
  44233. /**
  44234. * AKA Glossiness in other nomenclature.
  44235. */
  44236. protected _microSurface: number;
  44237. /**
  44238. * source material index of refraction (IOR)' / 'destination material IOR.
  44239. */
  44240. protected _indexOfRefraction: number;
  44241. /**
  44242. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44243. */
  44244. protected _invertRefractionY: boolean;
  44245. /**
  44246. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44247. * Materials half opaque for instance using refraction could benefit from this control.
  44248. */
  44249. protected _linkRefractionWithTransparency: boolean;
  44250. /**
  44251. * Specifies that the material will use the light map as a show map.
  44252. */
  44253. protected _useLightmapAsShadowmap: boolean;
  44254. /**
  44255. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44256. * makes the reflect vector face the model (under horizon).
  44257. */
  44258. protected _useHorizonOcclusion: boolean;
  44259. /**
  44260. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44261. * too much the area relying on ambient texture to define their ambient occlusion.
  44262. */
  44263. protected _useRadianceOcclusion: boolean;
  44264. /**
  44265. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44266. */
  44267. protected _useAlphaFromAlbedoTexture: boolean;
  44268. /**
  44269. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44270. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44271. */
  44272. protected _useSpecularOverAlpha: boolean;
  44273. /**
  44274. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44275. */
  44276. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44277. /**
  44278. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44279. */
  44280. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44281. /**
  44282. * Specifies if the metallic texture contains the roughness information in its green channel.
  44283. */
  44284. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44285. /**
  44286. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44287. */
  44288. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44289. /**
  44290. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44291. */
  44292. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44293. /**
  44294. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44295. */
  44296. protected _useAmbientInGrayScale: boolean;
  44297. /**
  44298. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44299. * The material will try to infer what glossiness each pixel should be.
  44300. */
  44301. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44302. /**
  44303. * Defines the falloff type used in this material.
  44304. * It by default is Physical.
  44305. */
  44306. protected _lightFalloff: number;
  44307. /**
  44308. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44309. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44310. */
  44311. protected _useRadianceOverAlpha: boolean;
  44312. /**
  44313. * Allows using an object space normal map (instead of tangent space).
  44314. */
  44315. protected _useObjectSpaceNormalMap: boolean;
  44316. /**
  44317. * Allows using the bump map in parallax mode.
  44318. */
  44319. protected _useParallax: boolean;
  44320. /**
  44321. * Allows using the bump map in parallax occlusion mode.
  44322. */
  44323. protected _useParallaxOcclusion: boolean;
  44324. /**
  44325. * Controls the scale bias of the parallax mode.
  44326. */
  44327. protected _parallaxScaleBias: number;
  44328. /**
  44329. * If sets to true, disables all the lights affecting the material.
  44330. */
  44331. protected _disableLighting: boolean;
  44332. /**
  44333. * Number of Simultaneous lights allowed on the material.
  44334. */
  44335. protected _maxSimultaneousLights: number;
  44336. /**
  44337. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44338. */
  44339. protected _invertNormalMapX: boolean;
  44340. /**
  44341. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44342. */
  44343. protected _invertNormalMapY: boolean;
  44344. /**
  44345. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44346. */
  44347. protected _twoSidedLighting: boolean;
  44348. /**
  44349. * Defines the alpha limits in alpha test mode.
  44350. */
  44351. protected _alphaCutOff: number;
  44352. /**
  44353. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44354. */
  44355. protected _forceAlphaTest: boolean;
  44356. /**
  44357. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44358. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44359. */
  44360. protected _useAlphaFresnel: boolean;
  44361. /**
  44362. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44363. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44364. */
  44365. protected _useLinearAlphaFresnel: boolean;
  44366. /**
  44367. * The transparency mode of the material.
  44368. */
  44369. protected _transparencyMode: Nullable<number>;
  44370. /**
  44371. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44372. * from cos thetav and roughness:
  44373. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44374. */
  44375. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44376. /**
  44377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44378. */
  44379. protected _forceIrradianceInFragment: boolean;
  44380. /**
  44381. * Force normal to face away from face.
  44382. */
  44383. protected _forceNormalForward: boolean;
  44384. /**
  44385. * Enables specular anti aliasing in the PBR shader.
  44386. * It will both interacts on the Geometry for analytical and IBL lighting.
  44387. * It also prefilter the roughness map based on the bump values.
  44388. */
  44389. protected _enableSpecularAntiAliasing: boolean;
  44390. /**
  44391. * Default configuration related to image processing available in the PBR Material.
  44392. */
  44393. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44394. /**
  44395. * Keep track of the image processing observer to allow dispose and replace.
  44396. */
  44397. private _imageProcessingObserver;
  44398. /**
  44399. * Attaches a new image processing configuration to the PBR Material.
  44400. * @param configuration
  44401. */
  44402. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44403. /**
  44404. * Stores the available render targets.
  44405. */
  44406. private _renderTargets;
  44407. /**
  44408. * Sets the global ambient color for the material used in lighting calculations.
  44409. */
  44410. private _globalAmbientColor;
  44411. /**
  44412. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44413. */
  44414. private _useLogarithmicDepth;
  44415. /**
  44416. * If set to true, no lighting calculations will be applied.
  44417. */
  44418. private _unlit;
  44419. /**
  44420. * Instantiates a new PBRMaterial instance.
  44421. *
  44422. * @param name The material name
  44423. * @param scene The scene the material will be use in.
  44424. */
  44425. constructor(name: string, scene: Scene);
  44426. /**
  44427. * Gets a boolean indicating that current material needs to register RTT
  44428. */
  44429. readonly hasRenderTargetTextures: boolean;
  44430. /**
  44431. * Gets the name of the material class.
  44432. */
  44433. getClassName(): string;
  44434. /**
  44435. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44436. */
  44437. /**
  44438. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44439. */
  44440. useLogarithmicDepth: boolean;
  44441. /**
  44442. * Gets the current transparency mode.
  44443. */
  44444. /**
  44445. * Sets the transparency mode of the material.
  44446. *
  44447. * | Value | Type | Description |
  44448. * | ----- | ----------------------------------- | ----------- |
  44449. * | 0 | OPAQUE | |
  44450. * | 1 | ALPHATEST | |
  44451. * | 2 | ALPHABLEND | |
  44452. * | 3 | ALPHATESTANDBLEND | |
  44453. *
  44454. */
  44455. transparencyMode: Nullable<number>;
  44456. /**
  44457. * Returns true if alpha blending should be disabled.
  44458. */
  44459. private readonly _disableAlphaBlending;
  44460. /**
  44461. * Specifies whether or not this material should be rendered in alpha blend mode.
  44462. */
  44463. needAlphaBlending(): boolean;
  44464. /**
  44465. * Specifies if the mesh will require alpha blending.
  44466. * @param mesh - BJS mesh.
  44467. */
  44468. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44469. /**
  44470. * Specifies whether or not this material should be rendered in alpha test mode.
  44471. */
  44472. needAlphaTesting(): boolean;
  44473. /**
  44474. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44475. */
  44476. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44477. /**
  44478. * Gets the texture used for the alpha test.
  44479. */
  44480. getAlphaTestTexture(): BaseTexture;
  44481. /**
  44482. * Specifies that the submesh is ready to be used.
  44483. * @param mesh - BJS mesh.
  44484. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44485. * @param useInstances - Specifies that instances should be used.
  44486. * @returns - boolean indicating that the submesh is ready or not.
  44487. */
  44488. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44489. /**
  44490. * Specifies if the material uses metallic roughness workflow.
  44491. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44492. */
  44493. isMetallicWorkflow(): boolean;
  44494. private _prepareEffect;
  44495. private _prepareDefines;
  44496. /**
  44497. * Force shader compilation
  44498. */
  44499. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44500. clipPlane: boolean;
  44501. }>): void;
  44502. /**
  44503. * Initializes the uniform buffer layout for the shader.
  44504. */
  44505. buildUniformLayout(): void;
  44506. /**
  44507. * Unbinds the textures.
  44508. */
  44509. unbind(): void;
  44510. /**
  44511. * Binds the submesh data.
  44512. * @param world - The world matrix.
  44513. * @param mesh - The BJS mesh.
  44514. * @param subMesh - A submesh of the BJS mesh.
  44515. */
  44516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44517. /**
  44518. * Returns the animatable textures.
  44519. * @returns - Array of animatable textures.
  44520. */
  44521. getAnimatables(): IAnimatable[];
  44522. /**
  44523. * Returns the texture used for reflections.
  44524. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44525. */
  44526. private _getReflectionTexture;
  44527. /**
  44528. * Returns the texture used for refraction or null if none is used.
  44529. * @returns - Refection texture if present. If no refraction texture and refraction
  44530. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44531. */
  44532. private _getRefractionTexture;
  44533. /**
  44534. * Disposes the resources of the material.
  44535. * @param forceDisposeEffect - Forces the disposal of effects.
  44536. * @param forceDisposeTextures - Forces the disposal of all textures.
  44537. */
  44538. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44539. }
  44540. }
  44541. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44542. import { Nullable } from "babylonjs/types";
  44543. import { Scene } from "babylonjs/scene";
  44544. import { Color3 } from "babylonjs/Maths/math";
  44545. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44546. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44548. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44549. /**
  44550. * The Physically based material of BJS.
  44551. *
  44552. * This offers the main features of a standard PBR material.
  44553. * For more information, please refer to the documentation :
  44554. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44555. */
  44556. export class PBRMaterial extends PBRBaseMaterial {
  44557. /**
  44558. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44559. */
  44560. static readonly PBRMATERIAL_OPAQUE: number;
  44561. /**
  44562. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44563. */
  44564. static readonly PBRMATERIAL_ALPHATEST: number;
  44565. /**
  44566. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44567. */
  44568. static readonly PBRMATERIAL_ALPHABLEND: number;
  44569. /**
  44570. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44571. * They are also discarded below the alpha cutoff threshold to improve performances.
  44572. */
  44573. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44574. /**
  44575. * Defines the default value of how much AO map is occluding the analytical lights
  44576. * (point spot...).
  44577. */
  44578. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44579. /**
  44580. * Intensity of the direct lights e.g. the four lights available in your scene.
  44581. * This impacts both the direct diffuse and specular highlights.
  44582. */
  44583. directIntensity: number;
  44584. /**
  44585. * Intensity of the emissive part of the material.
  44586. * This helps controlling the emissive effect without modifying the emissive color.
  44587. */
  44588. emissiveIntensity: number;
  44589. /**
  44590. * Intensity of the environment e.g. how much the environment will light the object
  44591. * either through harmonics for rough material or through the refelction for shiny ones.
  44592. */
  44593. environmentIntensity: number;
  44594. /**
  44595. * This is a special control allowing the reduction of the specular highlights coming from the
  44596. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44597. */
  44598. specularIntensity: number;
  44599. /**
  44600. * Debug Control allowing disabling the bump map on this material.
  44601. */
  44602. disableBumpMap: boolean;
  44603. /**
  44604. * AKA Diffuse Texture in standard nomenclature.
  44605. */
  44606. albedoTexture: BaseTexture;
  44607. /**
  44608. * AKA Occlusion Texture in other nomenclature.
  44609. */
  44610. ambientTexture: BaseTexture;
  44611. /**
  44612. * AKA Occlusion Texture Intensity in other nomenclature.
  44613. */
  44614. ambientTextureStrength: number;
  44615. /**
  44616. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44617. * 1 means it completely occludes it
  44618. * 0 mean it has no impact
  44619. */
  44620. ambientTextureImpactOnAnalyticalLights: number;
  44621. /**
  44622. * Stores the alpha values in a texture.
  44623. */
  44624. opacityTexture: BaseTexture;
  44625. /**
  44626. * Stores the reflection values in a texture.
  44627. */
  44628. reflectionTexture: Nullable<BaseTexture>;
  44629. /**
  44630. * Stores the emissive values in a texture.
  44631. */
  44632. emissiveTexture: BaseTexture;
  44633. /**
  44634. * AKA Specular texture in other nomenclature.
  44635. */
  44636. reflectivityTexture: BaseTexture;
  44637. /**
  44638. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44639. */
  44640. metallicTexture: BaseTexture;
  44641. /**
  44642. * Specifies the metallic scalar of the metallic/roughness workflow.
  44643. * Can also be used to scale the metalness values of the metallic texture.
  44644. */
  44645. metallic: Nullable<number>;
  44646. /**
  44647. * Specifies the roughness scalar of the metallic/roughness workflow.
  44648. * Can also be used to scale the roughness values of the metallic texture.
  44649. */
  44650. roughness: Nullable<number>;
  44651. /**
  44652. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44653. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44654. */
  44655. microSurfaceTexture: BaseTexture;
  44656. /**
  44657. * Stores surface normal data used to displace a mesh in a texture.
  44658. */
  44659. bumpTexture: BaseTexture;
  44660. /**
  44661. * Stores the pre-calculated light information of a mesh in a texture.
  44662. */
  44663. lightmapTexture: BaseTexture;
  44664. /**
  44665. * Stores the refracted light information in a texture.
  44666. */
  44667. refractionTexture: BaseTexture;
  44668. /**
  44669. * The color of a material in ambient lighting.
  44670. */
  44671. ambientColor: Color3;
  44672. /**
  44673. * AKA Diffuse Color in other nomenclature.
  44674. */
  44675. albedoColor: Color3;
  44676. /**
  44677. * AKA Specular Color in other nomenclature.
  44678. */
  44679. reflectivityColor: Color3;
  44680. /**
  44681. * The color reflected from the material.
  44682. */
  44683. reflectionColor: Color3;
  44684. /**
  44685. * The color emitted from the material.
  44686. */
  44687. emissiveColor: Color3;
  44688. /**
  44689. * AKA Glossiness in other nomenclature.
  44690. */
  44691. microSurface: number;
  44692. /**
  44693. * source material index of refraction (IOR)' / 'destination material IOR.
  44694. */
  44695. indexOfRefraction: number;
  44696. /**
  44697. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44698. */
  44699. invertRefractionY: boolean;
  44700. /**
  44701. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44702. * Materials half opaque for instance using refraction could benefit from this control.
  44703. */
  44704. linkRefractionWithTransparency: boolean;
  44705. /**
  44706. * If true, the light map contains occlusion information instead of lighting info.
  44707. */
  44708. useLightmapAsShadowmap: boolean;
  44709. /**
  44710. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44711. */
  44712. useAlphaFromAlbedoTexture: boolean;
  44713. /**
  44714. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44715. */
  44716. forceAlphaTest: boolean;
  44717. /**
  44718. * Defines the alpha limits in alpha test mode.
  44719. */
  44720. alphaCutOff: number;
  44721. /**
  44722. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44723. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44724. */
  44725. useSpecularOverAlpha: boolean;
  44726. /**
  44727. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44728. */
  44729. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44730. /**
  44731. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44732. */
  44733. useRoughnessFromMetallicTextureAlpha: boolean;
  44734. /**
  44735. * Specifies if the metallic texture contains the roughness information in its green channel.
  44736. */
  44737. useRoughnessFromMetallicTextureGreen: boolean;
  44738. /**
  44739. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44740. */
  44741. useMetallnessFromMetallicTextureBlue: boolean;
  44742. /**
  44743. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44744. */
  44745. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44746. /**
  44747. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44748. */
  44749. useAmbientInGrayScale: boolean;
  44750. /**
  44751. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44752. * The material will try to infer what glossiness each pixel should be.
  44753. */
  44754. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44755. /**
  44756. * BJS is using an harcoded light falloff based on a manually sets up range.
  44757. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44758. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44759. */
  44760. /**
  44761. * BJS is using an harcoded light falloff based on a manually sets up range.
  44762. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44763. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44764. */
  44765. usePhysicalLightFalloff: boolean;
  44766. /**
  44767. * In order to support the falloff compatibility with gltf, a special mode has been added
  44768. * to reproduce the gltf light falloff.
  44769. */
  44770. /**
  44771. * In order to support the falloff compatibility with gltf, a special mode has been added
  44772. * to reproduce the gltf light falloff.
  44773. */
  44774. useGLTFLightFalloff: boolean;
  44775. /**
  44776. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44777. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44778. */
  44779. useRadianceOverAlpha: boolean;
  44780. /**
  44781. * Allows using an object space normal map (instead of tangent space).
  44782. */
  44783. useObjectSpaceNormalMap: boolean;
  44784. /**
  44785. * Allows using the bump map in parallax mode.
  44786. */
  44787. useParallax: boolean;
  44788. /**
  44789. * Allows using the bump map in parallax occlusion mode.
  44790. */
  44791. useParallaxOcclusion: boolean;
  44792. /**
  44793. * Controls the scale bias of the parallax mode.
  44794. */
  44795. parallaxScaleBias: number;
  44796. /**
  44797. * If sets to true, disables all the lights affecting the material.
  44798. */
  44799. disableLighting: boolean;
  44800. /**
  44801. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44802. */
  44803. forceIrradianceInFragment: boolean;
  44804. /**
  44805. * Number of Simultaneous lights allowed on the material.
  44806. */
  44807. maxSimultaneousLights: number;
  44808. /**
  44809. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44810. */
  44811. invertNormalMapX: boolean;
  44812. /**
  44813. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44814. */
  44815. invertNormalMapY: boolean;
  44816. /**
  44817. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44818. */
  44819. twoSidedLighting: boolean;
  44820. /**
  44821. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44822. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44823. */
  44824. useAlphaFresnel: boolean;
  44825. /**
  44826. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44827. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44828. */
  44829. useLinearAlphaFresnel: boolean;
  44830. /**
  44831. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44832. * And/Or occlude the blended part.
  44833. */
  44834. environmentBRDFTexture: Nullable<BaseTexture>;
  44835. /**
  44836. * Force normal to face away from face.
  44837. */
  44838. forceNormalForward: boolean;
  44839. /**
  44840. * Enables specular anti aliasing in the PBR shader.
  44841. * It will both interacts on the Geometry for analytical and IBL lighting.
  44842. * It also prefilter the roughness map based on the bump values.
  44843. */
  44844. enableSpecularAntiAliasing: boolean;
  44845. /**
  44846. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44847. * makes the reflect vector face the model (under horizon).
  44848. */
  44849. useHorizonOcclusion: boolean;
  44850. /**
  44851. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44852. * too much the area relying on ambient texture to define their ambient occlusion.
  44853. */
  44854. useRadianceOcclusion: boolean;
  44855. /**
  44856. * If set to true, no lighting calculations will be applied.
  44857. */
  44858. unlit: boolean;
  44859. /**
  44860. * Gets the image processing configuration used either in this material.
  44861. */
  44862. /**
  44863. * Sets the Default image processing configuration used either in the this material.
  44864. *
  44865. * If sets to null, the scene one is in use.
  44866. */
  44867. imageProcessingConfiguration: ImageProcessingConfiguration;
  44868. /**
  44869. * Gets wether the color curves effect is enabled.
  44870. */
  44871. /**
  44872. * Sets wether the color curves effect is enabled.
  44873. */
  44874. cameraColorCurvesEnabled: boolean;
  44875. /**
  44876. * Gets wether the color grading effect is enabled.
  44877. */
  44878. /**
  44879. * Gets wether the color grading effect is enabled.
  44880. */
  44881. cameraColorGradingEnabled: boolean;
  44882. /**
  44883. * Gets wether tonemapping is enabled or not.
  44884. */
  44885. /**
  44886. * Sets wether tonemapping is enabled or not
  44887. */
  44888. cameraToneMappingEnabled: boolean;
  44889. /**
  44890. * The camera exposure used on this material.
  44891. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44892. * This corresponds to a photographic exposure.
  44893. */
  44894. /**
  44895. * The camera exposure used on this material.
  44896. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44897. * This corresponds to a photographic exposure.
  44898. */
  44899. cameraExposure: number;
  44900. /**
  44901. * Gets The camera contrast used on this material.
  44902. */
  44903. /**
  44904. * Sets The camera contrast used on this material.
  44905. */
  44906. cameraContrast: number;
  44907. /**
  44908. * Gets the Color Grading 2D Lookup Texture.
  44909. */
  44910. /**
  44911. * Sets the Color Grading 2D Lookup Texture.
  44912. */
  44913. cameraColorGradingTexture: Nullable<BaseTexture>;
  44914. /**
  44915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44917. * 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;
  44918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44919. */
  44920. /**
  44921. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44922. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44923. * 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;
  44924. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44925. */
  44926. cameraColorCurves: Nullable<ColorCurves>;
  44927. /**
  44928. * Instantiates a new PBRMaterial instance.
  44929. *
  44930. * @param name The material name
  44931. * @param scene The scene the material will be use in.
  44932. */
  44933. constructor(name: string, scene: Scene);
  44934. /**
  44935. * Returns the name of this material class.
  44936. */
  44937. getClassName(): string;
  44938. /**
  44939. * Returns an array of the actively used textures.
  44940. * @returns - Array of BaseTextures
  44941. */
  44942. getActiveTextures(): BaseTexture[];
  44943. /**
  44944. * Checks to see if a texture is used in the material.
  44945. * @param texture - Base texture to use.
  44946. * @returns - Boolean specifying if a texture is used in the material.
  44947. */
  44948. hasTexture(texture: BaseTexture): boolean;
  44949. /**
  44950. * Makes a duplicate of the current material.
  44951. * @param name - name to use for the new material.
  44952. */
  44953. clone(name: string): PBRMaterial;
  44954. /**
  44955. * Serializes this PBR Material.
  44956. * @returns - An object with the serialized material.
  44957. */
  44958. serialize(): any;
  44959. /**
  44960. * Parses a PBR Material from a serialized object.
  44961. * @param source - Serialized object.
  44962. * @param scene - BJS scene instance.
  44963. * @param rootUrl - url for the scene object
  44964. * @returns - PBRMaterial
  44965. */
  44966. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44967. }
  44968. }
  44969. declare module "babylonjs/Helpers/sceneHelpers" {
  44970. import { Nullable } from "babylonjs/types";
  44971. import { Mesh } from "babylonjs/Meshes/mesh";
  44972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44973. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44974. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44975. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44976. /** @hidden */
  44977. export var _forceSceneHelpersToBundle: boolean;
  44978. module "babylonjs/scene" {
  44979. interface Scene {
  44980. /**
  44981. * Creates a default light for the scene.
  44982. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44983. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44984. */
  44985. createDefaultLight(replace?: boolean): void;
  44986. /**
  44987. * Creates a default camera for the scene.
  44988. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44989. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44990. * @param replace has default false, when true replaces the active camera in the scene
  44991. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44992. */
  44993. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44994. /**
  44995. * Creates a default camera and a default light.
  44996. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44997. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44998. * @param replace has the default false, when true replaces the active camera/light in the scene
  44999. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45000. */
  45001. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45002. /**
  45003. * Creates a new sky box
  45004. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45005. * @param environmentTexture defines the texture to use as environment texture
  45006. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45007. * @param scale defines the overall scale of the skybox
  45008. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45009. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45010. * @returns a new mesh holding the sky box
  45011. */
  45012. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45013. /**
  45014. * Creates a new environment
  45015. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45016. * @param options defines the options you can use to configure the environment
  45017. * @returns the new EnvironmentHelper
  45018. */
  45019. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45020. /**
  45021. * Creates a new VREXperienceHelper
  45022. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45023. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45024. * @returns a new VREXperienceHelper
  45025. */
  45026. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45027. /**
  45028. * Creates a new XREXperienceHelper
  45029. * @see http://doc.babylonjs.com/how_to/webxr
  45030. * @returns a promise for a new XREXperienceHelper
  45031. */
  45032. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45033. }
  45034. }
  45035. }
  45036. declare module "babylonjs/Helpers/videoDome" {
  45037. import { Scene } from "babylonjs/scene";
  45038. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45039. import { Mesh } from "babylonjs/Meshes/mesh";
  45040. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45041. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45042. /**
  45043. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45044. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45045. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45046. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45047. */
  45048. export class VideoDome extends TransformNode {
  45049. private _useDirectMapping;
  45050. /**
  45051. * The video texture being displayed on the sphere
  45052. */
  45053. protected _videoTexture: VideoTexture;
  45054. /**
  45055. * Gets the video texture being displayed on the sphere
  45056. */
  45057. readonly videoTexture: VideoTexture;
  45058. /**
  45059. * The skybox material
  45060. */
  45061. protected _material: BackgroundMaterial;
  45062. /**
  45063. * The surface used for the skybox
  45064. */
  45065. protected _mesh: Mesh;
  45066. /**
  45067. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45068. * Also see the options.resolution property.
  45069. */
  45070. fovMultiplier: number;
  45071. /**
  45072. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45073. * @param name Element's name, child elements will append suffixes for their own names.
  45074. * @param urlsOrVideo defines the url(s) or the video element to use
  45075. * @param options An object containing optional or exposed sub element properties
  45076. */
  45077. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45078. resolution?: number;
  45079. clickToPlay?: boolean;
  45080. autoPlay?: boolean;
  45081. loop?: boolean;
  45082. size?: number;
  45083. poster?: string;
  45084. useDirectMapping?: boolean;
  45085. }, scene: Scene);
  45086. /**
  45087. * Releases resources associated with this node.
  45088. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45089. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45090. */
  45091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45092. }
  45093. }
  45094. declare module "babylonjs/Helpers/index" {
  45095. export * from "babylonjs/Helpers/environmentHelper";
  45096. export * from "babylonjs/Helpers/photoDome";
  45097. export * from "babylonjs/Helpers/sceneHelpers";
  45098. export * from "babylonjs/Helpers/videoDome";
  45099. }
  45100. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45101. import { PerfCounter } from "babylonjs/Misc/tools";
  45102. import { IDisposable } from "babylonjs/scene";
  45103. import { Engine } from "babylonjs/Engines/engine";
  45104. /**
  45105. * This class can be used to get instrumentation data from a Babylon engine
  45106. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45107. */
  45108. export class EngineInstrumentation implements IDisposable {
  45109. /**
  45110. * Define the instrumented engine.
  45111. */
  45112. engine: Engine;
  45113. private _captureGPUFrameTime;
  45114. private _gpuFrameTimeToken;
  45115. private _gpuFrameTime;
  45116. private _captureShaderCompilationTime;
  45117. private _shaderCompilationTime;
  45118. private _onBeginFrameObserver;
  45119. private _onEndFrameObserver;
  45120. private _onBeforeShaderCompilationObserver;
  45121. private _onAfterShaderCompilationObserver;
  45122. /**
  45123. * Gets the perf counter used for GPU frame time
  45124. */
  45125. readonly gpuFrameTimeCounter: PerfCounter;
  45126. /**
  45127. * Gets the GPU frame time capture status
  45128. */
  45129. /**
  45130. * Enable or disable the GPU frame time capture
  45131. */
  45132. captureGPUFrameTime: boolean;
  45133. /**
  45134. * Gets the perf counter used for shader compilation time
  45135. */
  45136. readonly shaderCompilationTimeCounter: PerfCounter;
  45137. /**
  45138. * Gets the shader compilation time capture status
  45139. */
  45140. /**
  45141. * Enable or disable the shader compilation time capture
  45142. */
  45143. captureShaderCompilationTime: boolean;
  45144. /**
  45145. * Instantiates a new engine instrumentation.
  45146. * This class can be used to get instrumentation data from a Babylon engine
  45147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45148. * @param engine Defines the engine to instrument
  45149. */
  45150. constructor(
  45151. /**
  45152. * Define the instrumented engine.
  45153. */
  45154. engine: Engine);
  45155. /**
  45156. * Dispose and release associated resources.
  45157. */
  45158. dispose(): void;
  45159. }
  45160. }
  45161. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45162. import { PerfCounter } from "babylonjs/Misc/tools";
  45163. import { Scene, IDisposable } from "babylonjs/scene";
  45164. /**
  45165. * This class can be used to get instrumentation data from a Babylon engine
  45166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45167. */
  45168. export class SceneInstrumentation implements IDisposable {
  45169. /**
  45170. * Defines the scene to instrument
  45171. */
  45172. scene: Scene;
  45173. private _captureActiveMeshesEvaluationTime;
  45174. private _activeMeshesEvaluationTime;
  45175. private _captureRenderTargetsRenderTime;
  45176. private _renderTargetsRenderTime;
  45177. private _captureFrameTime;
  45178. private _frameTime;
  45179. private _captureRenderTime;
  45180. private _renderTime;
  45181. private _captureInterFrameTime;
  45182. private _interFrameTime;
  45183. private _captureParticlesRenderTime;
  45184. private _particlesRenderTime;
  45185. private _captureSpritesRenderTime;
  45186. private _spritesRenderTime;
  45187. private _capturePhysicsTime;
  45188. private _physicsTime;
  45189. private _captureAnimationsTime;
  45190. private _animationsTime;
  45191. private _captureCameraRenderTime;
  45192. private _cameraRenderTime;
  45193. private _onBeforeActiveMeshesEvaluationObserver;
  45194. private _onAfterActiveMeshesEvaluationObserver;
  45195. private _onBeforeRenderTargetsRenderObserver;
  45196. private _onAfterRenderTargetsRenderObserver;
  45197. private _onAfterRenderObserver;
  45198. private _onBeforeDrawPhaseObserver;
  45199. private _onAfterDrawPhaseObserver;
  45200. private _onBeforeAnimationsObserver;
  45201. private _onBeforeParticlesRenderingObserver;
  45202. private _onAfterParticlesRenderingObserver;
  45203. private _onBeforeSpritesRenderingObserver;
  45204. private _onAfterSpritesRenderingObserver;
  45205. private _onBeforePhysicsObserver;
  45206. private _onAfterPhysicsObserver;
  45207. private _onAfterAnimationsObserver;
  45208. private _onBeforeCameraRenderObserver;
  45209. private _onAfterCameraRenderObserver;
  45210. /**
  45211. * Gets the perf counter used for active meshes evaluation time
  45212. */
  45213. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45214. /**
  45215. * Gets the active meshes evaluation time capture status
  45216. */
  45217. /**
  45218. * Enable or disable the active meshes evaluation time capture
  45219. */
  45220. captureActiveMeshesEvaluationTime: boolean;
  45221. /**
  45222. * Gets the perf counter used for render targets render time
  45223. */
  45224. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45225. /**
  45226. * Gets the render targets render time capture status
  45227. */
  45228. /**
  45229. * Enable or disable the render targets render time capture
  45230. */
  45231. captureRenderTargetsRenderTime: boolean;
  45232. /**
  45233. * Gets the perf counter used for particles render time
  45234. */
  45235. readonly particlesRenderTimeCounter: PerfCounter;
  45236. /**
  45237. * Gets the particles render time capture status
  45238. */
  45239. /**
  45240. * Enable or disable the particles render time capture
  45241. */
  45242. captureParticlesRenderTime: boolean;
  45243. /**
  45244. * Gets the perf counter used for sprites render time
  45245. */
  45246. readonly spritesRenderTimeCounter: PerfCounter;
  45247. /**
  45248. * Gets the sprites render time capture status
  45249. */
  45250. /**
  45251. * Enable or disable the sprites render time capture
  45252. */
  45253. captureSpritesRenderTime: boolean;
  45254. /**
  45255. * Gets the perf counter used for physics time
  45256. */
  45257. readonly physicsTimeCounter: PerfCounter;
  45258. /**
  45259. * Gets the physics time capture status
  45260. */
  45261. /**
  45262. * Enable or disable the physics time capture
  45263. */
  45264. capturePhysicsTime: boolean;
  45265. /**
  45266. * Gets the perf counter used for animations time
  45267. */
  45268. readonly animationsTimeCounter: PerfCounter;
  45269. /**
  45270. * Gets the animations time capture status
  45271. */
  45272. /**
  45273. * Enable or disable the animations time capture
  45274. */
  45275. captureAnimationsTime: boolean;
  45276. /**
  45277. * Gets the perf counter used for frame time capture
  45278. */
  45279. readonly frameTimeCounter: PerfCounter;
  45280. /**
  45281. * Gets the frame time capture status
  45282. */
  45283. /**
  45284. * Enable or disable the frame time capture
  45285. */
  45286. captureFrameTime: boolean;
  45287. /**
  45288. * Gets the perf counter used for inter-frames time capture
  45289. */
  45290. readonly interFrameTimeCounter: PerfCounter;
  45291. /**
  45292. * Gets the inter-frames time capture status
  45293. */
  45294. /**
  45295. * Enable or disable the inter-frames time capture
  45296. */
  45297. captureInterFrameTime: boolean;
  45298. /**
  45299. * Gets the perf counter used for render time capture
  45300. */
  45301. readonly renderTimeCounter: PerfCounter;
  45302. /**
  45303. * Gets the render time capture status
  45304. */
  45305. /**
  45306. * Enable or disable the render time capture
  45307. */
  45308. captureRenderTime: boolean;
  45309. /**
  45310. * Gets the perf counter used for camera render time capture
  45311. */
  45312. readonly cameraRenderTimeCounter: PerfCounter;
  45313. /**
  45314. * Gets the camera render time capture status
  45315. */
  45316. /**
  45317. * Enable or disable the camera render time capture
  45318. */
  45319. captureCameraRenderTime: boolean;
  45320. /**
  45321. * Gets the perf counter used for draw calls
  45322. */
  45323. readonly drawCallsCounter: PerfCounter;
  45324. /**
  45325. * Gets the perf counter used for texture collisions
  45326. */
  45327. readonly textureCollisionsCounter: PerfCounter;
  45328. /**
  45329. * Instantiates a new scene instrumentation.
  45330. * This class can be used to get instrumentation data from a Babylon engine
  45331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45332. * @param scene Defines the scene to instrument
  45333. */
  45334. constructor(
  45335. /**
  45336. * Defines the scene to instrument
  45337. */
  45338. scene: Scene);
  45339. /**
  45340. * Dispose and release associated resources.
  45341. */
  45342. dispose(): void;
  45343. }
  45344. }
  45345. declare module "babylonjs/Instrumentation/index" {
  45346. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45347. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45348. export * from "babylonjs/Instrumentation/timeToken";
  45349. }
  45350. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45351. import { Scene } from "babylonjs/scene";
  45352. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45353. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45354. import { AbstractScene } from "babylonjs/abstractScene";
  45355. module "babylonjs/abstractScene" {
  45356. interface AbstractScene {
  45357. /**
  45358. * The list of effect layers (highlights/glow) added to the scene
  45359. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45360. * @see http://doc.babylonjs.com/how_to/glow_layer
  45361. */
  45362. effectLayers: Array<EffectLayer>;
  45363. /**
  45364. * Removes the given effect layer from this scene.
  45365. * @param toRemove defines the effect layer to remove
  45366. * @returns the index of the removed effect layer
  45367. */
  45368. removeEffectLayer(toRemove: EffectLayer): number;
  45369. /**
  45370. * Adds the given effect layer to this scene
  45371. * @param newEffectLayer defines the effect layer to add
  45372. */
  45373. addEffectLayer(newEffectLayer: EffectLayer): void;
  45374. }
  45375. }
  45376. /**
  45377. * Defines the layer scene component responsible to manage any effect layers
  45378. * in a given scene.
  45379. */
  45380. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45381. /**
  45382. * The component name helpfull to identify the component in the list of scene components.
  45383. */
  45384. readonly name: string;
  45385. /**
  45386. * The scene the component belongs to.
  45387. */
  45388. scene: Scene;
  45389. private _engine;
  45390. private _renderEffects;
  45391. private _needStencil;
  45392. private _previousStencilState;
  45393. /**
  45394. * Creates a new instance of the component for the given scene
  45395. * @param scene Defines the scene to register the component in
  45396. */
  45397. constructor(scene: Scene);
  45398. /**
  45399. * Registers the component in a given scene
  45400. */
  45401. register(): void;
  45402. /**
  45403. * Rebuilds the elements related to this component in case of
  45404. * context lost for instance.
  45405. */
  45406. rebuild(): void;
  45407. /**
  45408. * Serializes the component data to the specified json object
  45409. * @param serializationObject The object to serialize to
  45410. */
  45411. serialize(serializationObject: any): void;
  45412. /**
  45413. * Adds all the element from the container to the scene
  45414. * @param container the container holding the elements
  45415. */
  45416. addFromContainer(container: AbstractScene): void;
  45417. /**
  45418. * Removes all the elements in the container from the scene
  45419. * @param container contains the elements to remove
  45420. */
  45421. removeFromContainer(container: AbstractScene): void;
  45422. /**
  45423. * Disposes the component and the associated ressources.
  45424. */
  45425. dispose(): void;
  45426. private _isReadyForMesh;
  45427. private _renderMainTexture;
  45428. private _setStencil;
  45429. private _setStencilBack;
  45430. private _draw;
  45431. private _drawCamera;
  45432. private _drawRenderingGroup;
  45433. }
  45434. }
  45435. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45436. export var glowMapGenerationPixelShader: {
  45437. name: string;
  45438. shader: string;
  45439. };
  45440. }
  45441. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45442. import "Shaders/ShadersInclude/bonesDeclaration";
  45443. import "Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45444. import "Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45445. import "Shaders/ShadersInclude/instancesDeclaration";
  45446. import "Shaders/ShadersInclude/morphTargetsVertex";
  45447. import "Shaders/ShadersInclude/instancesVertex";
  45448. import "Shaders/ShadersInclude/bonesVertex";
  45449. export var glowMapGenerationVertexShader: {
  45450. name: string;
  45451. shader: string;
  45452. };
  45453. }
  45454. declare module "babylonjs/Layers/effectLayer" {
  45455. import { Observable } from "babylonjs/Misc/observable";
  45456. import { Nullable } from "babylonjs/types";
  45457. import { Camera } from "babylonjs/Cameras/camera";
  45458. import { Scene } from "babylonjs/scene";
  45459. import { Color4, ISize } from "babylonjs/Maths/math";
  45460. import { Engine } from "babylonjs/Engines/engine";
  45461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45463. import { Mesh } from "babylonjs/Meshes/mesh";
  45464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45466. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45467. import { Effect } from "babylonjs/Materials/effect";
  45468. import { Material } from "babylonjs/Materials/material";
  45469. import "Shaders/glowMapGeneration.fragment";
  45470. import "Shaders/glowMapGeneration.vertex";
  45471. /**
  45472. * Effect layer options. This helps customizing the behaviour
  45473. * of the effect layer.
  45474. */
  45475. export interface IEffectLayerOptions {
  45476. /**
  45477. * Multiplication factor apply to the canvas size to compute the render target size
  45478. * used to generated the objects (the smaller the faster).
  45479. */
  45480. mainTextureRatio: number;
  45481. /**
  45482. * Enforces a fixed size texture to ensure effect stability across devices.
  45483. */
  45484. mainTextureFixedSize?: number;
  45485. /**
  45486. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45487. */
  45488. alphaBlendingMode: number;
  45489. /**
  45490. * The camera attached to the layer.
  45491. */
  45492. camera: Nullable<Camera>;
  45493. /**
  45494. * The rendering group to draw the layer in.
  45495. */
  45496. renderingGroupId: number;
  45497. }
  45498. /**
  45499. * The effect layer Helps adding post process effect blended with the main pass.
  45500. *
  45501. * This can be for instance use to generate glow or higlight effects on the scene.
  45502. *
  45503. * The effect layer class can not be used directly and is intented to inherited from to be
  45504. * customized per effects.
  45505. */
  45506. export abstract class EffectLayer {
  45507. private _vertexBuffers;
  45508. private _indexBuffer;
  45509. private _cachedDefines;
  45510. private _effectLayerMapGenerationEffect;
  45511. private _effectLayerOptions;
  45512. private _mergeEffect;
  45513. protected _scene: Scene;
  45514. protected _engine: Engine;
  45515. protected _maxSize: number;
  45516. protected _mainTextureDesiredSize: ISize;
  45517. protected _mainTexture: RenderTargetTexture;
  45518. protected _shouldRender: boolean;
  45519. protected _postProcesses: PostProcess[];
  45520. protected _textures: BaseTexture[];
  45521. protected _emissiveTextureAndColor: {
  45522. texture: Nullable<BaseTexture>;
  45523. color: Color4;
  45524. };
  45525. /**
  45526. * The name of the layer
  45527. */
  45528. name: string;
  45529. /**
  45530. * The clear color of the texture used to generate the glow map.
  45531. */
  45532. neutralColor: Color4;
  45533. /**
  45534. * Specifies wether the highlight layer is enabled or not.
  45535. */
  45536. isEnabled: boolean;
  45537. /**
  45538. * Gets the camera attached to the layer.
  45539. */
  45540. readonly camera: Nullable<Camera>;
  45541. /**
  45542. * Gets the rendering group id the layer should render in.
  45543. */
  45544. readonly renderingGroupId: number;
  45545. /**
  45546. * An event triggered when the effect layer has been disposed.
  45547. */
  45548. onDisposeObservable: Observable<EffectLayer>;
  45549. /**
  45550. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45551. */
  45552. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45553. /**
  45554. * An event triggered when the generated texture is being merged in the scene.
  45555. */
  45556. onBeforeComposeObservable: Observable<EffectLayer>;
  45557. /**
  45558. * An event triggered when the generated texture has been merged in the scene.
  45559. */
  45560. onAfterComposeObservable: Observable<EffectLayer>;
  45561. /**
  45562. * An event triggered when the efffect layer changes its size.
  45563. */
  45564. onSizeChangedObservable: Observable<EffectLayer>;
  45565. /**
  45566. * Instantiates a new effect Layer and references it in the scene.
  45567. * @param name The name of the layer
  45568. * @param scene The scene to use the layer in
  45569. */
  45570. constructor(
  45571. /** The Friendly of the effect in the scene */
  45572. name: string, scene: Scene);
  45573. /**
  45574. * Get the effect name of the layer.
  45575. * @return The effect name
  45576. */
  45577. abstract getEffectName(): string;
  45578. /**
  45579. * Checks for the readiness of the element composing the layer.
  45580. * @param subMesh the mesh to check for
  45581. * @param useInstances specify wether or not to use instances to render the mesh
  45582. * @return true if ready otherwise, false
  45583. */
  45584. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45585. /**
  45586. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45587. * @returns true if the effect requires stencil during the main canvas render pass.
  45588. */
  45589. abstract needStencil(): boolean;
  45590. /**
  45591. * Create the merge effect. This is the shader use to blit the information back
  45592. * to the main canvas at the end of the scene rendering.
  45593. * @returns The effect containing the shader used to merge the effect on the main canvas
  45594. */
  45595. protected abstract _createMergeEffect(): Effect;
  45596. /**
  45597. * Creates the render target textures and post processes used in the effect layer.
  45598. */
  45599. protected abstract _createTextureAndPostProcesses(): void;
  45600. /**
  45601. * Implementation specific of rendering the generating effect on the main canvas.
  45602. * @param effect The effect used to render through
  45603. */
  45604. protected abstract _internalRender(effect: Effect): void;
  45605. /**
  45606. * Sets the required values for both the emissive texture and and the main color.
  45607. */
  45608. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45609. /**
  45610. * Free any resources and references associated to a mesh.
  45611. * Internal use
  45612. * @param mesh The mesh to free.
  45613. */
  45614. abstract _disposeMesh(mesh: Mesh): void;
  45615. /**
  45616. * Serializes this layer (Glow or Highlight for example)
  45617. * @returns a serialized layer object
  45618. */
  45619. abstract serialize?(): any;
  45620. /**
  45621. * Initializes the effect layer with the required options.
  45622. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45623. */
  45624. protected _init(options: Partial<IEffectLayerOptions>): void;
  45625. /**
  45626. * Generates the index buffer of the full screen quad blending to the main canvas.
  45627. */
  45628. private _generateIndexBuffer;
  45629. /**
  45630. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45631. */
  45632. private _genrateVertexBuffer;
  45633. /**
  45634. * Sets the main texture desired size which is the closest power of two
  45635. * of the engine canvas size.
  45636. */
  45637. private _setMainTextureSize;
  45638. /**
  45639. * Creates the main texture for the effect layer.
  45640. */
  45641. protected _createMainTexture(): void;
  45642. /**
  45643. * Checks for the readiness of the element composing the layer.
  45644. * @param subMesh the mesh to check for
  45645. * @param useInstances specify wether or not to use instances to render the mesh
  45646. * @param emissiveTexture the associated emissive texture used to generate the glow
  45647. * @return true if ready otherwise, false
  45648. */
  45649. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45650. /**
  45651. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45652. */
  45653. render(): void;
  45654. /**
  45655. * Determine if a given mesh will be used in the current effect.
  45656. * @param mesh mesh to test
  45657. * @returns true if the mesh will be used
  45658. */
  45659. hasMesh(mesh: AbstractMesh): boolean;
  45660. /**
  45661. * Returns true if the layer contains information to display, otherwise false.
  45662. * @returns true if the glow layer should be rendered
  45663. */
  45664. shouldRender(): boolean;
  45665. /**
  45666. * Returns true if the mesh should render, otherwise false.
  45667. * @param mesh The mesh to render
  45668. * @returns true if it should render otherwise false
  45669. */
  45670. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45671. /**
  45672. * Returns true if the mesh should render, otherwise false.
  45673. * @param mesh The mesh to render
  45674. * @returns true if it should render otherwise false
  45675. */
  45676. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45677. /**
  45678. * Renders the submesh passed in parameter to the generation map.
  45679. */
  45680. protected _renderSubMesh(subMesh: SubMesh): void;
  45681. /**
  45682. * Rebuild the required buffers.
  45683. * @hidden Internal use only.
  45684. */
  45685. _rebuild(): void;
  45686. /**
  45687. * Dispose only the render target textures and post process.
  45688. */
  45689. private _disposeTextureAndPostProcesses;
  45690. /**
  45691. * Dispose the highlight layer and free resources.
  45692. */
  45693. dispose(): void;
  45694. /**
  45695. * Gets the class name of the effect layer
  45696. * @returns the string with the class name of the effect layer
  45697. */
  45698. getClassName(): string;
  45699. /**
  45700. * Creates an effect layer from parsed effect layer data
  45701. * @param parsedEffectLayer defines effect layer data
  45702. * @param scene defines the current scene
  45703. * @param rootUrl defines the root URL containing the effect layer information
  45704. * @returns a parsed effect Layer
  45705. */
  45706. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45707. }
  45708. }
  45709. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45710. export var glowMapMergePixelShader: {
  45711. name: string;
  45712. shader: string;
  45713. };
  45714. }
  45715. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45716. export var glowMapMergeVertexShader: {
  45717. name: string;
  45718. shader: string;
  45719. };
  45720. }
  45721. declare module "babylonjs/Layers/glowLayer" {
  45722. import { Nullable } from "babylonjs/types";
  45723. import { Camera } from "babylonjs/Cameras/camera";
  45724. import { Scene } from "babylonjs/scene";
  45725. import { Color4 } from "babylonjs/Maths/math";
  45726. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45728. import { Mesh } from "babylonjs/Meshes/mesh";
  45729. import { Texture } from "babylonjs/Materials/Textures/texture";
  45730. import { Effect } from "babylonjs/Materials/effect";
  45731. import { Material } from "babylonjs/Materials/material";
  45732. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45733. import "Shaders/glowMapMerge.fragment";
  45734. import "Shaders/glowMapMerge.vertex";
  45735. module "babylonjs/abstractScene" {
  45736. interface AbstractScene {
  45737. /**
  45738. * Return a the first highlight layer of the scene with a given name.
  45739. * @param name The name of the highlight layer to look for.
  45740. * @return The highlight layer if found otherwise null.
  45741. */
  45742. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45743. }
  45744. }
  45745. /**
  45746. * Glow layer options. This helps customizing the behaviour
  45747. * of the glow layer.
  45748. */
  45749. export interface IGlowLayerOptions {
  45750. /**
  45751. * Multiplication factor apply to the canvas size to compute the render target size
  45752. * used to generated the glowing objects (the smaller the faster).
  45753. */
  45754. mainTextureRatio: number;
  45755. /**
  45756. * Enforces a fixed size texture to ensure resize independant blur.
  45757. */
  45758. mainTextureFixedSize?: number;
  45759. /**
  45760. * How big is the kernel of the blur texture.
  45761. */
  45762. blurKernelSize: number;
  45763. /**
  45764. * The camera attached to the layer.
  45765. */
  45766. camera: Nullable<Camera>;
  45767. /**
  45768. * Enable MSAA by chosing the number of samples.
  45769. */
  45770. mainTextureSamples?: number;
  45771. /**
  45772. * The rendering group to draw the layer in.
  45773. */
  45774. renderingGroupId: number;
  45775. }
  45776. /**
  45777. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45778. *
  45779. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45780. * glowy meshes to your scene.
  45781. *
  45782. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45783. */
  45784. export class GlowLayer extends EffectLayer {
  45785. /**
  45786. * Effect Name of the layer.
  45787. */
  45788. static readonly EffectName: string;
  45789. /**
  45790. * The default blur kernel size used for the glow.
  45791. */
  45792. static DefaultBlurKernelSize: number;
  45793. /**
  45794. * The default texture size ratio used for the glow.
  45795. */
  45796. static DefaultTextureRatio: number;
  45797. /**
  45798. * Sets the kernel size of the blur.
  45799. */
  45800. /**
  45801. * Gets the kernel size of the blur.
  45802. */
  45803. blurKernelSize: number;
  45804. /**
  45805. * Sets the glow intensity.
  45806. */
  45807. /**
  45808. * Gets the glow intensity.
  45809. */
  45810. intensity: number;
  45811. private _options;
  45812. private _intensity;
  45813. private _horizontalBlurPostprocess1;
  45814. private _verticalBlurPostprocess1;
  45815. private _horizontalBlurPostprocess2;
  45816. private _verticalBlurPostprocess2;
  45817. private _blurTexture1;
  45818. private _blurTexture2;
  45819. private _postProcesses1;
  45820. private _postProcesses2;
  45821. private _includedOnlyMeshes;
  45822. private _excludedMeshes;
  45823. /**
  45824. * Callback used to let the user override the color selection on a per mesh basis
  45825. */
  45826. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45827. /**
  45828. * Callback used to let the user override the texture selection on a per mesh basis
  45829. */
  45830. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45831. /**
  45832. * Instantiates a new glow Layer and references it to the scene.
  45833. * @param name The name of the layer
  45834. * @param scene The scene to use the layer in
  45835. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45836. */
  45837. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45838. /**
  45839. * Get the effect name of the layer.
  45840. * @return The effect name
  45841. */
  45842. getEffectName(): string;
  45843. /**
  45844. * Create the merge effect. This is the shader use to blit the information back
  45845. * to the main canvas at the end of the scene rendering.
  45846. */
  45847. protected _createMergeEffect(): Effect;
  45848. /**
  45849. * Creates the render target textures and post processes used in the glow layer.
  45850. */
  45851. protected _createTextureAndPostProcesses(): void;
  45852. /**
  45853. * Checks for the readiness of the element composing the layer.
  45854. * @param subMesh the mesh to check for
  45855. * @param useInstances specify wether or not to use instances to render the mesh
  45856. * @param emissiveTexture the associated emissive texture used to generate the glow
  45857. * @return true if ready otherwise, false
  45858. */
  45859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45860. /**
  45861. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45862. */
  45863. needStencil(): boolean;
  45864. /**
  45865. * Implementation specific of rendering the generating effect on the main canvas.
  45866. * @param effect The effect used to render through
  45867. */
  45868. protected _internalRender(effect: Effect): void;
  45869. /**
  45870. * Sets the required values for both the emissive texture and and the main color.
  45871. */
  45872. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45873. /**
  45874. * Returns true if the mesh should render, otherwise false.
  45875. * @param mesh The mesh to render
  45876. * @returns true if it should render otherwise false
  45877. */
  45878. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45879. /**
  45880. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45881. * @param mesh The mesh to exclude from the glow layer
  45882. */
  45883. addExcludedMesh(mesh: Mesh): void;
  45884. /**
  45885. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45886. * @param mesh The mesh to remove
  45887. */
  45888. removeExcludedMesh(mesh: Mesh): void;
  45889. /**
  45890. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45891. * @param mesh The mesh to include in the glow layer
  45892. */
  45893. addIncludedOnlyMesh(mesh: Mesh): void;
  45894. /**
  45895. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45896. * @param mesh The mesh to remove
  45897. */
  45898. removeIncludedOnlyMesh(mesh: Mesh): void;
  45899. /**
  45900. * Determine if a given mesh will be used in the glow layer
  45901. * @param mesh The mesh to test
  45902. * @returns true if the mesh will be highlighted by the current glow layer
  45903. */
  45904. hasMesh(mesh: AbstractMesh): boolean;
  45905. /**
  45906. * Free any resources and references associated to a mesh.
  45907. * Internal use
  45908. * @param mesh The mesh to free.
  45909. * @hidden
  45910. */
  45911. _disposeMesh(mesh: Mesh): void;
  45912. /**
  45913. * Gets the class name of the effect layer
  45914. * @returns the string with the class name of the effect layer
  45915. */
  45916. getClassName(): string;
  45917. /**
  45918. * Serializes this glow layer
  45919. * @returns a serialized glow layer object
  45920. */
  45921. serialize(): any;
  45922. /**
  45923. * Creates a Glow Layer from parsed glow layer data
  45924. * @param parsedGlowLayer defines glow layer data
  45925. * @param scene defines the current scene
  45926. * @param rootUrl defines the root URL containing the glow layer information
  45927. * @returns a parsed Glow Layer
  45928. */
  45929. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45930. }
  45931. }
  45932. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45933. export var glowBlurPostProcessPixelShader: {
  45934. name: string;
  45935. shader: string;
  45936. };
  45937. }
  45938. declare module "babylonjs/Layers/highlightLayer" {
  45939. import { Observable } from "babylonjs/Misc/observable";
  45940. import { Nullable } from "babylonjs/types";
  45941. import { Camera } from "babylonjs/Cameras/camera";
  45942. import { Scene } from "babylonjs/scene";
  45943. import { Color3, Color4 } from "babylonjs/Maths/math";
  45944. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45946. import { Mesh } from "babylonjs/Meshes/mesh";
  45947. import { Effect } from "babylonjs/Materials/effect";
  45948. import { Material } from "babylonjs/Materials/material";
  45949. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45950. import "Shaders/glowMapMerge.fragment";
  45951. import "Shaders/glowMapMerge.vertex";
  45952. import "Shaders/glowBlurPostProcess.fragment";
  45953. module "babylonjs/abstractScene" {
  45954. interface AbstractScene {
  45955. /**
  45956. * Return a the first highlight layer of the scene with a given name.
  45957. * @param name The name of the highlight layer to look for.
  45958. * @return The highlight layer if found otherwise null.
  45959. */
  45960. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45961. }
  45962. }
  45963. /**
  45964. * Highlight layer options. This helps customizing the behaviour
  45965. * of the highlight layer.
  45966. */
  45967. export interface IHighlightLayerOptions {
  45968. /**
  45969. * Multiplication factor apply to the canvas size to compute the render target size
  45970. * used to generated the glowing objects (the smaller the faster).
  45971. */
  45972. mainTextureRatio: number;
  45973. /**
  45974. * Enforces a fixed size texture to ensure resize independant blur.
  45975. */
  45976. mainTextureFixedSize?: number;
  45977. /**
  45978. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45979. * of the picture to blur (the smaller the faster).
  45980. */
  45981. blurTextureSizeRatio: number;
  45982. /**
  45983. * How big in texel of the blur texture is the vertical blur.
  45984. */
  45985. blurVerticalSize: number;
  45986. /**
  45987. * How big in texel of the blur texture is the horizontal blur.
  45988. */
  45989. blurHorizontalSize: number;
  45990. /**
  45991. * Alpha blending mode used to apply the blur. Default is combine.
  45992. */
  45993. alphaBlendingMode: number;
  45994. /**
  45995. * The camera attached to the layer.
  45996. */
  45997. camera: Nullable<Camera>;
  45998. /**
  45999. * Should we display highlight as a solid stroke?
  46000. */
  46001. isStroke?: boolean;
  46002. /**
  46003. * The rendering group to draw the layer in.
  46004. */
  46005. renderingGroupId: number;
  46006. }
  46007. /**
  46008. * The highlight layer Helps adding a glow effect around a mesh.
  46009. *
  46010. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46011. * glowy meshes to your scene.
  46012. *
  46013. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46014. */
  46015. export class HighlightLayer extends EffectLayer {
  46016. name: string;
  46017. /**
  46018. * Effect Name of the highlight layer.
  46019. */
  46020. static readonly EffectName: string;
  46021. /**
  46022. * The neutral color used during the preparation of the glow effect.
  46023. * This is black by default as the blend operation is a blend operation.
  46024. */
  46025. static NeutralColor: Color4;
  46026. /**
  46027. * Stencil value used for glowing meshes.
  46028. */
  46029. static GlowingMeshStencilReference: number;
  46030. /**
  46031. * Stencil value used for the other meshes in the scene.
  46032. */
  46033. static NormalMeshStencilReference: number;
  46034. /**
  46035. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46036. */
  46037. innerGlow: boolean;
  46038. /**
  46039. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46040. */
  46041. outerGlow: boolean;
  46042. /**
  46043. * Specifies the horizontal size of the blur.
  46044. */
  46045. /**
  46046. * Gets the horizontal size of the blur.
  46047. */
  46048. blurHorizontalSize: number;
  46049. /**
  46050. * Specifies the vertical size of the blur.
  46051. */
  46052. /**
  46053. * Gets the vertical size of the blur.
  46054. */
  46055. blurVerticalSize: number;
  46056. /**
  46057. * An event triggered when the highlight layer is being blurred.
  46058. */
  46059. onBeforeBlurObservable: Observable<HighlightLayer>;
  46060. /**
  46061. * An event triggered when the highlight layer has been blurred.
  46062. */
  46063. onAfterBlurObservable: Observable<HighlightLayer>;
  46064. private _instanceGlowingMeshStencilReference;
  46065. private _options;
  46066. private _downSamplePostprocess;
  46067. private _horizontalBlurPostprocess;
  46068. private _verticalBlurPostprocess;
  46069. private _blurTexture;
  46070. private _meshes;
  46071. private _excludedMeshes;
  46072. /**
  46073. * Instantiates a new highlight Layer and references it to the scene..
  46074. * @param name The name of the layer
  46075. * @param scene The scene to use the layer in
  46076. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46077. */
  46078. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46079. /**
  46080. * Get the effect name of the layer.
  46081. * @return The effect name
  46082. */
  46083. getEffectName(): string;
  46084. /**
  46085. * Create the merge effect. This is the shader use to blit the information back
  46086. * to the main canvas at the end of the scene rendering.
  46087. */
  46088. protected _createMergeEffect(): Effect;
  46089. /**
  46090. * Creates the render target textures and post processes used in the highlight layer.
  46091. */
  46092. protected _createTextureAndPostProcesses(): void;
  46093. /**
  46094. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46095. */
  46096. needStencil(): boolean;
  46097. /**
  46098. * Checks for the readiness of the element composing the layer.
  46099. * @param subMesh the mesh to check for
  46100. * @param useInstances specify wether or not to use instances to render the mesh
  46101. * @param emissiveTexture the associated emissive texture used to generate the glow
  46102. * @return true if ready otherwise, false
  46103. */
  46104. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46105. /**
  46106. * Implementation specific of rendering the generating effect on the main canvas.
  46107. * @param effect The effect used to render through
  46108. */
  46109. protected _internalRender(effect: Effect): void;
  46110. /**
  46111. * Returns true if the layer contains information to display, otherwise false.
  46112. */
  46113. shouldRender(): boolean;
  46114. /**
  46115. * Returns true if the mesh should render, otherwise false.
  46116. * @param mesh The mesh to render
  46117. * @returns true if it should render otherwise false
  46118. */
  46119. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46120. /**
  46121. * Sets the required values for both the emissive texture and and the main color.
  46122. */
  46123. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46124. /**
  46125. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46126. * @param mesh The mesh to exclude from the highlight layer
  46127. */
  46128. addExcludedMesh(mesh: Mesh): void;
  46129. /**
  46130. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46131. * @param mesh The mesh to highlight
  46132. */
  46133. removeExcludedMesh(mesh: Mesh): void;
  46134. /**
  46135. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46136. * @param mesh mesh to test
  46137. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46138. */
  46139. hasMesh(mesh: AbstractMesh): boolean;
  46140. /**
  46141. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46142. * @param mesh The mesh to highlight
  46143. * @param color The color of the highlight
  46144. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46145. */
  46146. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46147. /**
  46148. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46149. * @param mesh The mesh to highlight
  46150. */
  46151. removeMesh(mesh: Mesh): void;
  46152. /**
  46153. * Force the stencil to the normal expected value for none glowing parts
  46154. */
  46155. private _defaultStencilReference;
  46156. /**
  46157. * Free any resources and references associated to a mesh.
  46158. * Internal use
  46159. * @param mesh The mesh to free.
  46160. * @hidden
  46161. */
  46162. _disposeMesh(mesh: Mesh): void;
  46163. /**
  46164. * Dispose the highlight layer and free resources.
  46165. */
  46166. dispose(): void;
  46167. /**
  46168. * Gets the class name of the effect layer
  46169. * @returns the string with the class name of the effect layer
  46170. */
  46171. getClassName(): string;
  46172. /**
  46173. * Serializes this Highlight layer
  46174. * @returns a serialized Highlight layer object
  46175. */
  46176. serialize(): any;
  46177. /**
  46178. * Creates a Highlight layer from parsed Highlight layer data
  46179. * @param parsedHightlightLayer defines the Highlight layer data
  46180. * @param scene defines the current scene
  46181. * @param rootUrl defines the root URL containing the Highlight layer information
  46182. * @returns a parsed Highlight layer
  46183. */
  46184. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46185. }
  46186. }
  46187. declare module "babylonjs/Layers/index" {
  46188. export * from "babylonjs/Layers/effectLayer";
  46189. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46190. export * from "babylonjs/Layers/glowLayer";
  46191. export * from "babylonjs/Layers/highlightLayer";
  46192. export * from "babylonjs/Layers/layer";
  46193. export * from "babylonjs/Layers/layerSceneComponent";
  46194. }
  46195. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46196. import { Nullable } from "babylonjs/types";
  46197. import { Scene } from "babylonjs/scene";
  46198. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46199. import { AbstractScene } from "babylonjs/abstractScene";
  46200. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46201. module "babylonjs/abstractScene" {
  46202. interface AbstractScene {
  46203. /**
  46204. * The list of lens flare system added to the scene
  46205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46206. */
  46207. lensFlareSystems: Array<LensFlareSystem>;
  46208. /**
  46209. * Removes the given lens flare system from this scene.
  46210. * @param toRemove The lens flare system to remove
  46211. * @returns The index of the removed lens flare system
  46212. */
  46213. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46214. /**
  46215. * Adds the given lens flare system to this scene
  46216. * @param newLensFlareSystem The lens flare system to add
  46217. */
  46218. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46219. /**
  46220. * Gets a lens flare system using its name
  46221. * @param name defines the name to look for
  46222. * @returns the lens flare system or null if not found
  46223. */
  46224. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46225. /**
  46226. * Gets a lens flare system using its id
  46227. * @param id defines the id to look for
  46228. * @returns the lens flare system or null if not found
  46229. */
  46230. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46231. }
  46232. }
  46233. /**
  46234. * Defines the lens flare scene component responsible to manage any lens flares
  46235. * in a given scene.
  46236. */
  46237. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46238. /**
  46239. * The component name helpfull to identify the component in the list of scene components.
  46240. */
  46241. readonly name: string;
  46242. /**
  46243. * The scene the component belongs to.
  46244. */
  46245. scene: Scene;
  46246. /**
  46247. * Creates a new instance of the component for the given scene
  46248. * @param scene Defines the scene to register the component in
  46249. */
  46250. constructor(scene: Scene);
  46251. /**
  46252. * Registers the component in a given scene
  46253. */
  46254. register(): void;
  46255. /**
  46256. * Rebuilds the elements related to this component in case of
  46257. * context lost for instance.
  46258. */
  46259. rebuild(): void;
  46260. /**
  46261. * Adds all the element from the container to the scene
  46262. * @param container the container holding the elements
  46263. */
  46264. addFromContainer(container: AbstractScene): void;
  46265. /**
  46266. * Removes all the elements in the container from the scene
  46267. * @param container contains the elements to remove
  46268. */
  46269. removeFromContainer(container: AbstractScene): void;
  46270. /**
  46271. * Serializes the component data to the specified json object
  46272. * @param serializationObject The object to serialize to
  46273. */
  46274. serialize(serializationObject: any): void;
  46275. /**
  46276. * Disposes the component and the associated ressources.
  46277. */
  46278. dispose(): void;
  46279. private _draw;
  46280. }
  46281. }
  46282. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46283. export var lensFlarePixelShader: {
  46284. name: string;
  46285. shader: string;
  46286. };
  46287. }
  46288. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46289. export var lensFlareVertexShader: {
  46290. name: string;
  46291. shader: string;
  46292. };
  46293. }
  46294. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46295. import { Scene } from "babylonjs/scene";
  46296. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46298. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46299. import "Shaders/lensFlare.fragment";
  46300. import "Shaders/lensFlare.vertex";
  46301. /**
  46302. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46303. * It is usually composed of several `lensFlare`.
  46304. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46305. */
  46306. export class LensFlareSystem {
  46307. /**
  46308. * Define the name of the lens flare system
  46309. */
  46310. name: string;
  46311. /**
  46312. * List of lens flares used in this system.
  46313. */
  46314. lensFlares: LensFlare[];
  46315. /**
  46316. * Define a limit from the border the lens flare can be visible.
  46317. */
  46318. borderLimit: number;
  46319. /**
  46320. * Define a viewport border we do not want to see the lens flare in.
  46321. */
  46322. viewportBorder: number;
  46323. /**
  46324. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46325. */
  46326. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46327. /**
  46328. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46329. */
  46330. layerMask: number;
  46331. /**
  46332. * Define the id of the lens flare system in the scene.
  46333. * (equal to name by default)
  46334. */
  46335. id: string;
  46336. private _scene;
  46337. private _emitter;
  46338. private _vertexBuffers;
  46339. private _indexBuffer;
  46340. private _effect;
  46341. private _positionX;
  46342. private _positionY;
  46343. private _isEnabled;
  46344. /**
  46345. * Instantiates a lens flare system.
  46346. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46347. * It is usually composed of several `lensFlare`.
  46348. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46349. * @param name Define the name of the lens flare system in the scene
  46350. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46351. * @param scene Define the scene the lens flare system belongs to
  46352. */
  46353. constructor(
  46354. /**
  46355. * Define the name of the lens flare system
  46356. */
  46357. name: string, emitter: any, scene: Scene);
  46358. /**
  46359. * Define if the lens flare system is enabled.
  46360. */
  46361. isEnabled: boolean;
  46362. /**
  46363. * Get the scene the effects belongs to.
  46364. * @returns the scene holding the lens flare system
  46365. */
  46366. getScene(): Scene;
  46367. /**
  46368. * Get the emitter of the lens flare system.
  46369. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46370. * @returns the emitter of the lens flare system
  46371. */
  46372. getEmitter(): any;
  46373. /**
  46374. * Set the emitter of the lens flare system.
  46375. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46376. * @param newEmitter Define the new emitter of the system
  46377. */
  46378. setEmitter(newEmitter: any): void;
  46379. /**
  46380. * Get the lens flare system emitter position.
  46381. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46382. * @returns the position
  46383. */
  46384. getEmitterPosition(): Vector3;
  46385. /**
  46386. * @hidden
  46387. */
  46388. computeEffectivePosition(globalViewport: Viewport): boolean;
  46389. /** @hidden */
  46390. _isVisible(): boolean;
  46391. /**
  46392. * @hidden
  46393. */
  46394. render(): boolean;
  46395. /**
  46396. * Dispose and release the lens flare with its associated resources.
  46397. */
  46398. dispose(): void;
  46399. /**
  46400. * Parse a lens flare system from a JSON repressentation
  46401. * @param parsedLensFlareSystem Define the JSON to parse
  46402. * @param scene Define the scene the parsed system should be instantiated in
  46403. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46404. * @returns the parsed system
  46405. */
  46406. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46407. /**
  46408. * Serialize the current Lens Flare System into a JSON representation.
  46409. * @returns the serialized JSON
  46410. */
  46411. serialize(): any;
  46412. }
  46413. }
  46414. declare module "babylonjs/LensFlares/lensFlare" {
  46415. import { Nullable } from "babylonjs/types";
  46416. import { Color3 } from "babylonjs/Maths/math";
  46417. import { Texture } from "babylonjs/Materials/Textures/texture";
  46418. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46419. /**
  46420. * This represents one of the lens effect in a `lensFlareSystem`.
  46421. * It controls one of the indiviual texture used in the effect.
  46422. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46423. */
  46424. export class LensFlare {
  46425. /**
  46426. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46427. */
  46428. size: number;
  46429. /**
  46430. * 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.
  46431. */
  46432. position: number;
  46433. /**
  46434. * Define the lens color.
  46435. */
  46436. color: Color3;
  46437. /**
  46438. * Define the lens texture.
  46439. */
  46440. texture: Nullable<Texture>;
  46441. /**
  46442. * Define the alpha mode to render this particular lens.
  46443. */
  46444. alphaMode: number;
  46445. private _system;
  46446. /**
  46447. * Creates a new Lens Flare.
  46448. * This represents one of the lens effect in a `lensFlareSystem`.
  46449. * It controls one of the indiviual texture used in the effect.
  46450. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46451. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46452. * @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.
  46453. * @param color Define the lens color
  46454. * @param imgUrl Define the lens texture url
  46455. * @param system Define the `lensFlareSystem` this flare is part of
  46456. * @returns The newly created Lens Flare
  46457. */
  46458. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46459. /**
  46460. * Instantiates a new Lens Flare.
  46461. * This represents one of the lens effect in a `lensFlareSystem`.
  46462. * It controls one of the indiviual texture used in the effect.
  46463. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46464. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46465. * @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.
  46466. * @param color Define the lens color
  46467. * @param imgUrl Define the lens texture url
  46468. * @param system Define the `lensFlareSystem` this flare is part of
  46469. */
  46470. constructor(
  46471. /**
  46472. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46473. */
  46474. size: number,
  46475. /**
  46476. * 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.
  46477. */
  46478. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46479. /**
  46480. * Dispose and release the lens flare with its associated resources.
  46481. */
  46482. dispose(): void;
  46483. }
  46484. }
  46485. declare module "babylonjs/LensFlares/index" {
  46486. export * from "babylonjs/LensFlares/lensFlare";
  46487. export * from "babylonjs/LensFlares/lensFlareSystem";
  46488. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46489. }
  46490. declare module "babylonjs/Lights/Shadows/index" {
  46491. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46492. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46493. }
  46494. declare module "babylonjs/Lights/directionalLight" {
  46495. import { Camera } from "babylonjs/Cameras/camera";
  46496. import { Scene } from "babylonjs/scene";
  46497. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46499. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46500. import { Effect } from "babylonjs/Materials/effect";
  46501. /**
  46502. * A directional light is defined by a direction (what a surprise!).
  46503. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46504. * 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.
  46505. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46506. */
  46507. export class DirectionalLight extends ShadowLight {
  46508. private _shadowFrustumSize;
  46509. /**
  46510. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46511. */
  46512. /**
  46513. * Specifies a fix frustum size for the shadow generation.
  46514. */
  46515. shadowFrustumSize: number;
  46516. private _shadowOrthoScale;
  46517. /**
  46518. * Gets the shadow projection scale against the optimal computed one.
  46519. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46520. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46521. */
  46522. /**
  46523. * Sets the shadow projection scale against the optimal computed one.
  46524. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46525. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46526. */
  46527. shadowOrthoScale: number;
  46528. /**
  46529. * Automatically compute the projection matrix to best fit (including all the casters)
  46530. * on each frame.
  46531. */
  46532. autoUpdateExtends: boolean;
  46533. private _orthoLeft;
  46534. private _orthoRight;
  46535. private _orthoTop;
  46536. private _orthoBottom;
  46537. /**
  46538. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46539. * The directional light is emitted from everywhere in the given direction.
  46540. * It can cast shadows.
  46541. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46542. * @param name The friendly name of the light
  46543. * @param direction The direction of the light
  46544. * @param scene The scene the light belongs to
  46545. */
  46546. constructor(name: string, direction: Vector3, scene: Scene);
  46547. /**
  46548. * Returns the string "DirectionalLight".
  46549. * @return The class name
  46550. */
  46551. getClassName(): string;
  46552. /**
  46553. * Returns the integer 1.
  46554. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46555. */
  46556. getTypeID(): number;
  46557. /**
  46558. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46559. * Returns the DirectionalLight Shadow projection matrix.
  46560. */
  46561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46562. /**
  46563. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46564. * Returns the DirectionalLight Shadow projection matrix.
  46565. */
  46566. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46567. /**
  46568. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46569. * Returns the DirectionalLight Shadow projection matrix.
  46570. */
  46571. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46572. protected _buildUniformLayout(): void;
  46573. /**
  46574. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46575. * @param effect The effect to update
  46576. * @param lightIndex The index of the light in the effect to update
  46577. * @returns The directional light
  46578. */
  46579. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46580. /**
  46581. * Gets the minZ used for shadow according to both the scene and the light.
  46582. *
  46583. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46584. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46585. * @param activeCamera The camera we are returning the min for
  46586. * @returns the depth min z
  46587. */
  46588. getDepthMinZ(activeCamera: Camera): number;
  46589. /**
  46590. * Gets the maxZ used for shadow according to both the scene and the light.
  46591. *
  46592. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46593. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46594. * @param activeCamera The camera we are returning the max for
  46595. * @returns the depth max z
  46596. */
  46597. getDepthMaxZ(activeCamera: Camera): number;
  46598. /**
  46599. * Prepares the list of defines specific to the light type.
  46600. * @param defines the list of defines
  46601. * @param lightIndex defines the index of the light for the effect
  46602. */
  46603. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46604. }
  46605. }
  46606. declare module "babylonjs/Lights/pointLight" {
  46607. import { Scene } from "babylonjs/scene";
  46608. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46610. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46611. import { Effect } from "babylonjs/Materials/effect";
  46612. /**
  46613. * A point light is a light defined by an unique point in world space.
  46614. * The light is emitted in every direction from this point.
  46615. * A good example of a point light is a standard light bulb.
  46616. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46617. */
  46618. export class PointLight extends ShadowLight {
  46619. private _shadowAngle;
  46620. /**
  46621. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46622. * This specifies what angle the shadow will use to be created.
  46623. *
  46624. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46625. */
  46626. /**
  46627. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46628. * This specifies what angle the shadow will use to be created.
  46629. *
  46630. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46631. */
  46632. shadowAngle: number;
  46633. /**
  46634. * Gets the direction if it has been set.
  46635. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46636. */
  46637. /**
  46638. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46639. */
  46640. direction: Vector3;
  46641. /**
  46642. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46643. * A PointLight emits the light in every direction.
  46644. * It can cast shadows.
  46645. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46646. * ```javascript
  46647. * var pointLight = new PointLight("pl", camera.position, scene);
  46648. * ```
  46649. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46650. * @param name The light friendly name
  46651. * @param position The position of the point light in the scene
  46652. * @param scene The scene the lights belongs to
  46653. */
  46654. constructor(name: string, position: Vector3, scene: Scene);
  46655. /**
  46656. * Returns the string "PointLight"
  46657. * @returns the class name
  46658. */
  46659. getClassName(): string;
  46660. /**
  46661. * Returns the integer 0.
  46662. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46663. */
  46664. getTypeID(): number;
  46665. /**
  46666. * Specifies wether or not the shadowmap should be a cube texture.
  46667. * @returns true if the shadowmap needs to be a cube texture.
  46668. */
  46669. needCube(): boolean;
  46670. /**
  46671. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46672. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46673. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46674. */
  46675. getShadowDirection(faceIndex?: number): Vector3;
  46676. /**
  46677. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46678. * - fov = PI / 2
  46679. * - aspect ratio : 1.0
  46680. * - z-near and far equal to the active camera minZ and maxZ.
  46681. * Returns the PointLight.
  46682. */
  46683. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46684. protected _buildUniformLayout(): void;
  46685. /**
  46686. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46687. * @param effect The effect to update
  46688. * @param lightIndex The index of the light in the effect to update
  46689. * @returns The point light
  46690. */
  46691. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46692. /**
  46693. * Prepares the list of defines specific to the light type.
  46694. * @param defines the list of defines
  46695. * @param lightIndex defines the index of the light for the effect
  46696. */
  46697. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46698. }
  46699. }
  46700. declare module "babylonjs/Lights/spotLight" {
  46701. import { Nullable } from "babylonjs/types";
  46702. import { Scene } from "babylonjs/scene";
  46703. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46705. import { Effect } from "babylonjs/Materials/effect";
  46706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46707. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46708. /**
  46709. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46710. * These values define a cone of light starting from the position, emitting toward the direction.
  46711. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46712. * and the exponent defines the speed of the decay of the light with distance (reach).
  46713. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46714. */
  46715. export class SpotLight extends ShadowLight {
  46716. private _angle;
  46717. private _innerAngle;
  46718. private _cosHalfAngle;
  46719. private _lightAngleScale;
  46720. private _lightAngleOffset;
  46721. /**
  46722. * Gets the cone angle of the spot light in Radians.
  46723. */
  46724. /**
  46725. * Sets the cone angle of the spot light in Radians.
  46726. */
  46727. angle: number;
  46728. /**
  46729. * Only used in gltf falloff mode, this defines the angle where
  46730. * the directional falloff will start before cutting at angle which could be seen
  46731. * as outer angle.
  46732. */
  46733. /**
  46734. * Only used in gltf falloff mode, this defines the angle where
  46735. * the directional falloff will start before cutting at angle which could be seen
  46736. * as outer angle.
  46737. */
  46738. innerAngle: number;
  46739. private _shadowAngleScale;
  46740. /**
  46741. * Allows scaling the angle of the light for shadow generation only.
  46742. */
  46743. /**
  46744. * Allows scaling the angle of the light for shadow generation only.
  46745. */
  46746. shadowAngleScale: number;
  46747. /**
  46748. * The light decay speed with the distance from the emission spot.
  46749. */
  46750. exponent: number;
  46751. private _projectionTextureMatrix;
  46752. /**
  46753. * Allows reading the projecton texture
  46754. */
  46755. readonly projectionTextureMatrix: Matrix;
  46756. protected _projectionTextureLightNear: number;
  46757. /**
  46758. * Gets the near clip of the Spotlight for texture projection.
  46759. */
  46760. /**
  46761. * Sets the near clip of the Spotlight for texture projection.
  46762. */
  46763. projectionTextureLightNear: number;
  46764. protected _projectionTextureLightFar: number;
  46765. /**
  46766. * Gets the far clip of the Spotlight for texture projection.
  46767. */
  46768. /**
  46769. * Sets the far clip of the Spotlight for texture projection.
  46770. */
  46771. projectionTextureLightFar: number;
  46772. protected _projectionTextureUpDirection: Vector3;
  46773. /**
  46774. * Gets the Up vector of the Spotlight for texture projection.
  46775. */
  46776. /**
  46777. * Sets the Up vector of the Spotlight for texture projection.
  46778. */
  46779. projectionTextureUpDirection: Vector3;
  46780. private _projectionTexture;
  46781. /**
  46782. * Gets the projection texture of the light.
  46783. */
  46784. /**
  46785. * Sets the projection texture of the light.
  46786. */
  46787. projectionTexture: Nullable<BaseTexture>;
  46788. private _projectionTextureViewLightDirty;
  46789. private _projectionTextureProjectionLightDirty;
  46790. private _projectionTextureDirty;
  46791. private _projectionTextureViewTargetVector;
  46792. private _projectionTextureViewLightMatrix;
  46793. private _projectionTextureProjectionLightMatrix;
  46794. private _projectionTextureScalingMatrix;
  46795. /**
  46796. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46797. * It can cast shadows.
  46798. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46799. * @param name The light friendly name
  46800. * @param position The position of the spot light in the scene
  46801. * @param direction The direction of the light in the scene
  46802. * @param angle The cone angle of the light in Radians
  46803. * @param exponent The light decay speed with the distance from the emission spot
  46804. * @param scene The scene the lights belongs to
  46805. */
  46806. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46807. /**
  46808. * Returns the string "SpotLight".
  46809. * @returns the class name
  46810. */
  46811. getClassName(): string;
  46812. /**
  46813. * Returns the integer 2.
  46814. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46815. */
  46816. getTypeID(): number;
  46817. /**
  46818. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46819. */
  46820. protected _setDirection(value: Vector3): void;
  46821. /**
  46822. * Overrides the position setter to recompute the projection texture view light Matrix.
  46823. */
  46824. protected _setPosition(value: Vector3): void;
  46825. /**
  46826. * 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.
  46827. * Returns the SpotLight.
  46828. */
  46829. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46830. protected _computeProjectionTextureViewLightMatrix(): void;
  46831. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46832. /**
  46833. * Main function for light texture projection matrix computing.
  46834. */
  46835. protected _computeProjectionTextureMatrix(): void;
  46836. protected _buildUniformLayout(): void;
  46837. private _computeAngleValues;
  46838. /**
  46839. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46840. * @param effect The effect to update
  46841. * @param lightIndex The index of the light in the effect to update
  46842. * @returns The spot light
  46843. */
  46844. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46845. /**
  46846. * Disposes the light and the associated resources.
  46847. */
  46848. dispose(): void;
  46849. /**
  46850. * Prepares the list of defines specific to the light type.
  46851. * @param defines the list of defines
  46852. * @param lightIndex defines the index of the light for the effect
  46853. */
  46854. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46855. }
  46856. }
  46857. declare module "babylonjs/Lights/index" {
  46858. export * from "babylonjs/Lights/light";
  46859. export * from "babylonjs/Lights/shadowLight";
  46860. export * from "babylonjs/Lights/Shadows/index";
  46861. export * from "babylonjs/Lights/directionalLight";
  46862. export * from "babylonjs/Lights/hemisphericLight";
  46863. export * from "babylonjs/Lights/pointLight";
  46864. export * from "babylonjs/Lights/spotLight";
  46865. }
  46866. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46867. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46868. /**
  46869. * Header information of HDR texture files.
  46870. */
  46871. export interface HDRInfo {
  46872. /**
  46873. * The height of the texture in pixels.
  46874. */
  46875. height: number;
  46876. /**
  46877. * The width of the texture in pixels.
  46878. */
  46879. width: number;
  46880. /**
  46881. * The index of the beginning of the data in the binary file.
  46882. */
  46883. dataPosition: number;
  46884. }
  46885. /**
  46886. * This groups tools to convert HDR texture to native colors array.
  46887. */
  46888. export class HDRTools {
  46889. private static Ldexp;
  46890. private static Rgbe2float;
  46891. private static readStringLine;
  46892. /**
  46893. * Reads header information from an RGBE texture stored in a native array.
  46894. * More information on this format are available here:
  46895. * https://en.wikipedia.org/wiki/RGBE_image_format
  46896. *
  46897. * @param uint8array The binary file stored in native array.
  46898. * @return The header information.
  46899. */
  46900. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46901. /**
  46902. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46903. * This RGBE texture needs to store the information as a panorama.
  46904. *
  46905. * More information on this format are available here:
  46906. * https://en.wikipedia.org/wiki/RGBE_image_format
  46907. *
  46908. * @param buffer The binary file stored in an array buffer.
  46909. * @param size The expected size of the extracted cubemap.
  46910. * @return The Cube Map information.
  46911. */
  46912. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46913. /**
  46914. * Returns the pixels data extracted from an RGBE texture.
  46915. * This pixels will be stored left to right up to down in the R G B order in one array.
  46916. *
  46917. * More information on this format are available here:
  46918. * https://en.wikipedia.org/wiki/RGBE_image_format
  46919. *
  46920. * @param uint8array The binary file stored in an array buffer.
  46921. * @param hdrInfo The header information of the file.
  46922. * @return The pixels data in RGB right to left up to down order.
  46923. */
  46924. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46925. private static RGBE_ReadPixels_RLE;
  46926. }
  46927. }
  46928. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46929. import { Nullable } from "babylonjs/types";
  46930. import { Scene } from "babylonjs/scene";
  46931. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46933. /**
  46934. * This represents a texture coming from an HDR input.
  46935. *
  46936. * The only supported format is currently panorama picture stored in RGBE format.
  46937. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46938. */
  46939. export class HDRCubeTexture extends BaseTexture {
  46940. private static _facesMapping;
  46941. private _generateHarmonics;
  46942. private _noMipmap;
  46943. private _textureMatrix;
  46944. private _size;
  46945. private _onLoad;
  46946. private _onError;
  46947. /**
  46948. * The texture URL.
  46949. */
  46950. url: string;
  46951. /**
  46952. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46953. */
  46954. coordinatesMode: number;
  46955. protected _isBlocking: boolean;
  46956. /**
  46957. * Sets wether or not the texture is blocking during loading.
  46958. */
  46959. /**
  46960. * Gets wether or not the texture is blocking during loading.
  46961. */
  46962. isBlocking: boolean;
  46963. protected _rotationY: number;
  46964. /**
  46965. * Sets texture matrix rotation angle around Y axis in radians.
  46966. */
  46967. /**
  46968. * Gets texture matrix rotation angle around Y axis radians.
  46969. */
  46970. rotationY: number;
  46971. /**
  46972. * Gets or sets the center of the bounding box associated with the cube texture
  46973. * It must define where the camera used to render the texture was set
  46974. */
  46975. boundingBoxPosition: Vector3;
  46976. private _boundingBoxSize;
  46977. /**
  46978. * Gets or sets the size of the bounding box associated with the cube texture
  46979. * When defined, the cubemap will switch to local mode
  46980. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46981. * @example https://www.babylonjs-playground.com/#RNASML
  46982. */
  46983. boundingBoxSize: Vector3;
  46984. /**
  46985. * Instantiates an HDRTexture from the following parameters.
  46986. *
  46987. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46988. * @param scene The scene the texture will be used in
  46989. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46990. * @param noMipmap Forces to not generate the mipmap if true
  46991. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46992. * @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)
  46993. * @param reserved Reserved flag for internal use.
  46994. */
  46995. 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>);
  46996. /**
  46997. * Get the current class name of the texture useful for serialization or dynamic coding.
  46998. * @returns "HDRCubeTexture"
  46999. */
  47000. getClassName(): string;
  47001. /**
  47002. * Occurs when the file is raw .hdr file.
  47003. */
  47004. private loadTexture;
  47005. clone(): HDRCubeTexture;
  47006. delayLoad(): void;
  47007. /**
  47008. * Get the texture reflection matrix used to rotate/transform the reflection.
  47009. * @returns the reflection matrix
  47010. */
  47011. getReflectionTextureMatrix(): Matrix;
  47012. /**
  47013. * Set the texture reflection matrix used to rotate/transform the reflection.
  47014. * @param value Define the reflection matrix to set
  47015. */
  47016. setReflectionTextureMatrix(value: Matrix): void;
  47017. /**
  47018. * Parses a JSON representation of an HDR Texture in order to create the texture
  47019. * @param parsedTexture Define the JSON representation
  47020. * @param scene Define the scene the texture should be created in
  47021. * @param rootUrl Define the root url in case we need to load relative dependencies
  47022. * @returns the newly created texture after parsing
  47023. */
  47024. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47025. serialize(): any;
  47026. }
  47027. }
  47028. declare module "babylonjs/Physics/physicsEngine" {
  47029. import { Nullable } from "babylonjs/types";
  47030. import { Vector3 } from "babylonjs/Maths/math";
  47031. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47032. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47033. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47034. /**
  47035. * Class used to control physics engine
  47036. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47037. */
  47038. export class PhysicsEngine implements IPhysicsEngine {
  47039. private _physicsPlugin;
  47040. /**
  47041. * Global value used to control the smallest number supported by the simulation
  47042. */
  47043. static Epsilon: number;
  47044. private _impostors;
  47045. private _joints;
  47046. /**
  47047. * Gets the gravity vector used by the simulation
  47048. */
  47049. gravity: Vector3;
  47050. /**
  47051. * Creates a new Physics Engine
  47052. * @param gravity defines the gravity vector used by the simulation
  47053. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47054. */
  47055. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47056. /**
  47057. * Sets the gravity vector used by the simulation
  47058. * @param gravity defines the gravity vector to use
  47059. */
  47060. setGravity(gravity: Vector3): void;
  47061. /**
  47062. * Set the time step of the physics engine.
  47063. * Default is 1/60.
  47064. * To slow it down, enter 1/600 for example.
  47065. * To speed it up, 1/30
  47066. * @param newTimeStep defines the new timestep to apply to this world.
  47067. */
  47068. setTimeStep(newTimeStep?: number): void;
  47069. /**
  47070. * Get the time step of the physics engine.
  47071. * @returns the current time step
  47072. */
  47073. getTimeStep(): number;
  47074. /**
  47075. * Release all resources
  47076. */
  47077. dispose(): void;
  47078. /**
  47079. * Gets the name of the current physics plugin
  47080. * @returns the name of the plugin
  47081. */
  47082. getPhysicsPluginName(): string;
  47083. /**
  47084. * Adding a new impostor for the impostor tracking.
  47085. * This will be done by the impostor itself.
  47086. * @param impostor the impostor to add
  47087. */
  47088. addImpostor(impostor: PhysicsImpostor): void;
  47089. /**
  47090. * Remove an impostor from the engine.
  47091. * This impostor and its mesh will not longer be updated by the physics engine.
  47092. * @param impostor the impostor to remove
  47093. */
  47094. removeImpostor(impostor: PhysicsImpostor): void;
  47095. /**
  47096. * Add a joint to the physics engine
  47097. * @param mainImpostor defines the main impostor to which the joint is added.
  47098. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47099. * @param joint defines the joint that will connect both impostors.
  47100. */
  47101. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47102. /**
  47103. * Removes a joint from the simulation
  47104. * @param mainImpostor defines the impostor used with the joint
  47105. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47106. * @param joint defines the joint to remove
  47107. */
  47108. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47109. /**
  47110. * Called by the scene. No need to call it.
  47111. * @param delta defines the timespam between frames
  47112. */
  47113. _step(delta: number): void;
  47114. /**
  47115. * Gets the current plugin used to run the simulation
  47116. * @returns current plugin
  47117. */
  47118. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47119. /**
  47120. * Gets the list of physic impostors
  47121. * @returns an array of PhysicsImpostor
  47122. */
  47123. getImpostors(): Array<PhysicsImpostor>;
  47124. /**
  47125. * Gets the impostor for a physics enabled object
  47126. * @param object defines the object impersonated by the impostor
  47127. * @returns the PhysicsImpostor or null if not found
  47128. */
  47129. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47130. /**
  47131. * Gets the impostor for a physics body object
  47132. * @param body defines physics body used by the impostor
  47133. * @returns the PhysicsImpostor or null if not found
  47134. */
  47135. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47136. }
  47137. }
  47138. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47139. import { Nullable } from "babylonjs/types";
  47140. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47142. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47143. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47144. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47145. /** @hidden */
  47146. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47147. private _useDeltaForWorldStep;
  47148. world: any;
  47149. name: string;
  47150. private _physicsMaterials;
  47151. private _fixedTimeStep;
  47152. BJSCANNON: any;
  47153. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47154. setGravity(gravity: Vector3): void;
  47155. setTimeStep(timeStep: number): void;
  47156. getTimeStep(): number;
  47157. executeStep(delta: number): void;
  47158. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47159. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47160. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47161. private _processChildMeshes;
  47162. removePhysicsBody(impostor: PhysicsImpostor): void;
  47163. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47164. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47165. private _addMaterial;
  47166. private _checkWithEpsilon;
  47167. private _createShape;
  47168. private _createHeightmap;
  47169. private _minus90X;
  47170. private _plus90X;
  47171. private _tmpPosition;
  47172. private _tmpDeltaPosition;
  47173. private _tmpUnityRotation;
  47174. private _updatePhysicsBodyTransformation;
  47175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47176. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47177. isSupported(): boolean;
  47178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47182. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47183. getBodyMass(impostor: PhysicsImpostor): number;
  47184. getBodyFriction(impostor: PhysicsImpostor): number;
  47185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47186. getBodyRestitution(impostor: PhysicsImpostor): number;
  47187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47188. sleepBody(impostor: PhysicsImpostor): void;
  47189. wakeUpBody(impostor: PhysicsImpostor): void;
  47190. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47191. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47192. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47193. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47194. getRadius(impostor: PhysicsImpostor): number;
  47195. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47196. dispose(): void;
  47197. private _extendNamespace;
  47198. }
  47199. }
  47200. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47201. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47202. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47203. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47205. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47206. import { Nullable } from "babylonjs/types";
  47207. /** @hidden */
  47208. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47209. world: any;
  47210. name: string;
  47211. BJSOIMO: any;
  47212. constructor(iterations?: number);
  47213. setGravity(gravity: Vector3): void;
  47214. setTimeStep(timeStep: number): void;
  47215. getTimeStep(): number;
  47216. private _tmpImpostorsArray;
  47217. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47218. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47219. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47220. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47221. private _tmpPositionVector;
  47222. removePhysicsBody(impostor: PhysicsImpostor): void;
  47223. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47224. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47225. isSupported(): boolean;
  47226. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47227. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47228. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47229. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47230. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47231. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47232. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47233. getBodyMass(impostor: PhysicsImpostor): number;
  47234. getBodyFriction(impostor: PhysicsImpostor): number;
  47235. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47236. getBodyRestitution(impostor: PhysicsImpostor): number;
  47237. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47238. sleepBody(impostor: PhysicsImpostor): void;
  47239. wakeUpBody(impostor: PhysicsImpostor): void;
  47240. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47241. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47242. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47243. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47244. getRadius(impostor: PhysicsImpostor): number;
  47245. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47246. dispose(): void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Probes/reflectionProbe" {
  47250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47251. import { Vector3 } from "babylonjs/Maths/math";
  47252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47253. import { Nullable } from "babylonjs/types";
  47254. import { Scene } from "babylonjs/scene";
  47255. module "babylonjs/abstractScene" {
  47256. interface AbstractScene {
  47257. /**
  47258. * The list of reflection probes added to the scene
  47259. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47260. */
  47261. reflectionProbes: Array<ReflectionProbe>;
  47262. /**
  47263. * Removes the given reflection probe from this scene.
  47264. * @param toRemove The reflection probe to remove
  47265. * @returns The index of the removed reflection probe
  47266. */
  47267. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47268. /**
  47269. * Adds the given reflection probe to this scene.
  47270. * @param newReflectionProbe The reflection probe to add
  47271. */
  47272. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47273. }
  47274. }
  47275. /**
  47276. * Class used to generate realtime reflection / refraction cube textures
  47277. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47278. */
  47279. export class ReflectionProbe {
  47280. /** defines the name of the probe */
  47281. name: string;
  47282. private _scene;
  47283. private _renderTargetTexture;
  47284. private _projectionMatrix;
  47285. private _viewMatrix;
  47286. private _target;
  47287. private _add;
  47288. private _attachedMesh;
  47289. private _invertYAxis;
  47290. /** Gets or sets probe position (center of the cube map) */
  47291. position: Vector3;
  47292. /**
  47293. * Creates a new reflection probe
  47294. * @param name defines the name of the probe
  47295. * @param size defines the texture resolution (for each face)
  47296. * @param scene defines the hosting scene
  47297. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47298. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47299. */
  47300. constructor(
  47301. /** defines the name of the probe */
  47302. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47303. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47304. samples: number;
  47305. /** Gets or sets the refresh rate to use (on every frame by default) */
  47306. refreshRate: number;
  47307. /**
  47308. * Gets the hosting scene
  47309. * @returns a Scene
  47310. */
  47311. getScene(): Scene;
  47312. /** Gets the internal CubeTexture used to render to */
  47313. readonly cubeTexture: RenderTargetTexture;
  47314. /** Gets the list of meshes to render */
  47315. readonly renderList: Nullable<AbstractMesh[]>;
  47316. /**
  47317. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47318. * @param mesh defines the mesh to attach to
  47319. */
  47320. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47321. /**
  47322. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47323. * @param renderingGroupId The rendering group id corresponding to its index
  47324. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47325. */
  47326. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47327. /**
  47328. * Clean all associated resources
  47329. */
  47330. dispose(): void;
  47331. /**
  47332. * Converts the reflection probe information to a readable string for debug purpose.
  47333. * @param fullDetails Supports for multiple levels of logging within scene loading
  47334. * @returns the human readable reflection probe info
  47335. */
  47336. toString(fullDetails?: boolean): string;
  47337. /**
  47338. * Get the class name of the relfection probe.
  47339. * @returns "ReflectionProbe"
  47340. */
  47341. getClassName(): string;
  47342. /**
  47343. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47344. * @returns The JSON representation of the texture
  47345. */
  47346. serialize(): any;
  47347. /**
  47348. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47349. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47350. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47351. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47352. * @returns The parsed reflection probe if successful
  47353. */
  47354. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47355. }
  47356. }
  47357. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47358. /** @hidden */
  47359. export var _BabylonLoaderRegistered: boolean;
  47360. }
  47361. declare module "babylonjs/Loading/Plugins/index" {
  47362. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47363. }
  47364. declare module "babylonjs/Loading/index" {
  47365. export * from "babylonjs/Loading/loadingScreen";
  47366. export * from "babylonjs/Loading/Plugins/index";
  47367. export * from "babylonjs/Loading/sceneLoader";
  47368. }
  47369. declare module "babylonjs/Materials/Background/index" {
  47370. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47371. }
  47372. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47373. import { Scene } from "babylonjs/scene";
  47374. import { Color3 } from "babylonjs/Maths/math";
  47375. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47377. /**
  47378. * The Physically based simple base material of BJS.
  47379. *
  47380. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47381. * It is used as the base class for both the specGloss and metalRough conventions.
  47382. */
  47383. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47384. /**
  47385. * Number of Simultaneous lights allowed on the material.
  47386. */
  47387. maxSimultaneousLights: number;
  47388. /**
  47389. * If sets to true, disables all the lights affecting the material.
  47390. */
  47391. disableLighting: boolean;
  47392. /**
  47393. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47394. */
  47395. environmentTexture: BaseTexture;
  47396. /**
  47397. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47398. */
  47399. invertNormalMapX: boolean;
  47400. /**
  47401. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47402. */
  47403. invertNormalMapY: boolean;
  47404. /**
  47405. * Normal map used in the model.
  47406. */
  47407. normalTexture: BaseTexture;
  47408. /**
  47409. * Emissivie color used to self-illuminate the model.
  47410. */
  47411. emissiveColor: Color3;
  47412. /**
  47413. * Emissivie texture used to self-illuminate the model.
  47414. */
  47415. emissiveTexture: BaseTexture;
  47416. /**
  47417. * Occlusion Channel Strenght.
  47418. */
  47419. occlusionStrength: number;
  47420. /**
  47421. * Occlusion Texture of the material (adding extra occlusion effects).
  47422. */
  47423. occlusionTexture: BaseTexture;
  47424. /**
  47425. * Defines the alpha limits in alpha test mode.
  47426. */
  47427. alphaCutOff: number;
  47428. /**
  47429. * Gets the current double sided mode.
  47430. */
  47431. /**
  47432. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47433. */
  47434. doubleSided: boolean;
  47435. /**
  47436. * Stores the pre-calculated light information of a mesh in a texture.
  47437. */
  47438. lightmapTexture: BaseTexture;
  47439. /**
  47440. * If true, the light map contains occlusion information instead of lighting info.
  47441. */
  47442. useLightmapAsShadowmap: boolean;
  47443. /**
  47444. * Return the active textures of the material.
  47445. */
  47446. getActiveTextures(): BaseTexture[];
  47447. hasTexture(texture: BaseTexture): boolean;
  47448. /**
  47449. * Instantiates a new PBRMaterial instance.
  47450. *
  47451. * @param name The material name
  47452. * @param scene The scene the material will be use in.
  47453. */
  47454. constructor(name: string, scene: Scene);
  47455. getClassName(): string;
  47456. }
  47457. }
  47458. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47459. import { Scene } from "babylonjs/scene";
  47460. import { Color3 } from "babylonjs/Maths/math";
  47461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47462. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47463. /**
  47464. * The PBR material of BJS following the metal roughness convention.
  47465. *
  47466. * This fits to the PBR convention in the GLTF definition:
  47467. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47468. */
  47469. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47470. /**
  47471. * The base color has two different interpretations depending on the value of metalness.
  47472. * When the material is a metal, the base color is the specific measured reflectance value
  47473. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47474. * of the material.
  47475. */
  47476. baseColor: Color3;
  47477. /**
  47478. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47479. * well as opacity information in the alpha channel.
  47480. */
  47481. baseTexture: BaseTexture;
  47482. /**
  47483. * Specifies the metallic scalar value of the material.
  47484. * Can also be used to scale the metalness values of the metallic texture.
  47485. */
  47486. metallic: number;
  47487. /**
  47488. * Specifies the roughness scalar value of the material.
  47489. * Can also be used to scale the roughness values of the metallic texture.
  47490. */
  47491. roughness: number;
  47492. /**
  47493. * Texture containing both the metallic value in the B channel and the
  47494. * roughness value in the G channel to keep better precision.
  47495. */
  47496. metallicRoughnessTexture: BaseTexture;
  47497. /**
  47498. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47499. *
  47500. * @param name The material name
  47501. * @param scene The scene the material will be use in.
  47502. */
  47503. constructor(name: string, scene: Scene);
  47504. /**
  47505. * Return the currrent class name of the material.
  47506. */
  47507. getClassName(): string;
  47508. /**
  47509. * Return the active textures of the material.
  47510. */
  47511. getActiveTextures(): BaseTexture[];
  47512. /**
  47513. * Checks to see if a texture is used in the material.
  47514. * @param texture - Base texture to use.
  47515. * @returns - Boolean specifying if a texture is used in the material.
  47516. */
  47517. hasTexture(texture: BaseTexture): boolean;
  47518. /**
  47519. * Makes a duplicate of the current material.
  47520. * @param name - name to use for the new material.
  47521. */
  47522. clone(name: string): PBRMetallicRoughnessMaterial;
  47523. /**
  47524. * Serialize the material to a parsable JSON object.
  47525. */
  47526. serialize(): any;
  47527. /**
  47528. * Parses a JSON object correponding to the serialize function.
  47529. */
  47530. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47531. }
  47532. }
  47533. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47534. import { Scene } from "babylonjs/scene";
  47535. import { Color3 } from "babylonjs/Maths/math";
  47536. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47537. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47538. /**
  47539. * The PBR material of BJS following the specular glossiness convention.
  47540. *
  47541. * This fits to the PBR convention in the GLTF definition:
  47542. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47543. */
  47544. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47545. /**
  47546. * Specifies the diffuse color of the material.
  47547. */
  47548. diffuseColor: Color3;
  47549. /**
  47550. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47551. * channel.
  47552. */
  47553. diffuseTexture: BaseTexture;
  47554. /**
  47555. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47556. */
  47557. specularColor: Color3;
  47558. /**
  47559. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47560. */
  47561. glossiness: number;
  47562. /**
  47563. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47564. */
  47565. specularGlossinessTexture: BaseTexture;
  47566. /**
  47567. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47568. *
  47569. * @param name The material name
  47570. * @param scene The scene the material will be use in.
  47571. */
  47572. constructor(name: string, scene: Scene);
  47573. /**
  47574. * Return the currrent class name of the material.
  47575. */
  47576. getClassName(): string;
  47577. /**
  47578. * Return the active textures of the material.
  47579. */
  47580. getActiveTextures(): BaseTexture[];
  47581. /**
  47582. * Checks to see if a texture is used in the material.
  47583. * @param texture - Base texture to use.
  47584. * @returns - Boolean specifying if a texture is used in the material.
  47585. */
  47586. hasTexture(texture: BaseTexture): boolean;
  47587. /**
  47588. * Makes a duplicate of the current material.
  47589. * @param name - name to use for the new material.
  47590. */
  47591. clone(name: string): PBRSpecularGlossinessMaterial;
  47592. /**
  47593. * Serialize the material to a parsable JSON object.
  47594. */
  47595. serialize(): any;
  47596. /**
  47597. * Parses a JSON object correponding to the serialize function.
  47598. */
  47599. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47600. }
  47601. }
  47602. declare module "babylonjs/Materials/PBR/index" {
  47603. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47604. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47605. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47606. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47607. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47608. }
  47609. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47610. import { Nullable } from "babylonjs/types";
  47611. import { Scene } from "babylonjs/scene";
  47612. import { Matrix } from "babylonjs/Maths/math";
  47613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47614. /**
  47615. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47616. * It can help converting any input color in a desired output one. This can then be used to create effects
  47617. * from sepia, black and white to sixties or futuristic rendering...
  47618. *
  47619. * The only supported format is currently 3dl.
  47620. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47621. */
  47622. export class ColorGradingTexture extends BaseTexture {
  47623. /**
  47624. * The current texture matrix. (will always be identity in color grading texture)
  47625. */
  47626. private _textureMatrix;
  47627. /**
  47628. * The texture URL.
  47629. */
  47630. url: string;
  47631. /**
  47632. * Empty line regex stored for GC.
  47633. */
  47634. private static _noneEmptyLineRegex;
  47635. private _engine;
  47636. /**
  47637. * Instantiates a ColorGradingTexture from the following parameters.
  47638. *
  47639. * @param url The location of the color gradind data (currently only supporting 3dl)
  47640. * @param scene The scene the texture will be used in
  47641. */
  47642. constructor(url: string, scene: Scene);
  47643. /**
  47644. * Returns the texture matrix used in most of the material.
  47645. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47646. */
  47647. getTextureMatrix(): Matrix;
  47648. /**
  47649. * Occurs when the file being loaded is a .3dl LUT file.
  47650. */
  47651. private load3dlTexture;
  47652. /**
  47653. * Starts the loading process of the texture.
  47654. */
  47655. private loadTexture;
  47656. /**
  47657. * Clones the color gradind texture.
  47658. */
  47659. clone(): ColorGradingTexture;
  47660. /**
  47661. * Called during delayed load for textures.
  47662. */
  47663. delayLoad(): void;
  47664. /**
  47665. * Parses a color grading texture serialized by Babylon.
  47666. * @param parsedTexture The texture information being parsedTexture
  47667. * @param scene The scene to load the texture in
  47668. * @param rootUrl The root url of the data assets to load
  47669. * @return A color gradind texture
  47670. */
  47671. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47672. /**
  47673. * Serializes the LUT texture to json format.
  47674. */
  47675. serialize(): any;
  47676. }
  47677. }
  47678. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47679. import { Nullable } from "babylonjs/types";
  47680. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47681. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47682. /**
  47683. * Implementation of the DDS Texture Loader.
  47684. * @hidden
  47685. */
  47686. export class _DDSTextureLoader implements IInternalTextureLoader {
  47687. /**
  47688. * Defines wether the loader supports cascade loading the different faces.
  47689. */
  47690. readonly supportCascades: boolean;
  47691. /**
  47692. * This returns if the loader support the current file information.
  47693. * @param extension defines the file extension of the file being loaded
  47694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47695. * @param fallback defines the fallback internal texture if any
  47696. * @param isBase64 defines whether the texture is encoded as a base64
  47697. * @param isBuffer defines whether the texture data are stored as a buffer
  47698. * @returns true if the loader can load the specified file
  47699. */
  47700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47701. /**
  47702. * Transform the url before loading if required.
  47703. * @param rootUrl the url of the texture
  47704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47705. * @returns the transformed texture
  47706. */
  47707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47708. /**
  47709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47710. * @param rootUrl the url of the texture
  47711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47712. * @returns the fallback texture
  47713. */
  47714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47715. /**
  47716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47717. * @param data contains the texture data
  47718. * @param texture defines the BabylonJS internal texture
  47719. * @param createPolynomials will be true if polynomials have been requested
  47720. * @param onLoad defines the callback to trigger once the texture is ready
  47721. * @param onError defines the callback to trigger in case of error
  47722. */
  47723. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47724. /**
  47725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47726. * @param data contains the texture data
  47727. * @param texture defines the BabylonJS internal texture
  47728. * @param callback defines the method to call once ready to upload
  47729. */
  47730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47731. }
  47732. }
  47733. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47734. import "Shaders/ShadersInclude/helperFunctions";
  47735. export var rgbdEncodePixelShader: {
  47736. name: string;
  47737. shader: string;
  47738. };
  47739. }
  47740. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47741. import "Shaders/ShadersInclude/helperFunctions";
  47742. export var rgbdDecodePixelShader: {
  47743. name: string;
  47744. shader: string;
  47745. };
  47746. }
  47747. declare module "babylonjs/Misc/environmentTextureTools" {
  47748. import { Nullable } from "babylonjs/types";
  47749. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47750. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47751. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47752. import "Shaders/rgbdEncode.fragment";
  47753. import "Shaders/rgbdDecode.fragment";
  47754. /**
  47755. * Raw texture data and descriptor sufficient for WebGL texture upload
  47756. */
  47757. export interface EnvironmentTextureInfo {
  47758. /**
  47759. * Version of the environment map
  47760. */
  47761. version: number;
  47762. /**
  47763. * Width of image
  47764. */
  47765. width: number;
  47766. /**
  47767. * Irradiance information stored in the file.
  47768. */
  47769. irradiance: any;
  47770. /**
  47771. * Specular information stored in the file.
  47772. */
  47773. specular: any;
  47774. }
  47775. /**
  47776. * Sets of helpers addressing the serialization and deserialization of environment texture
  47777. * stored in a BabylonJS env file.
  47778. * Those files are usually stored as .env files.
  47779. */
  47780. export class EnvironmentTextureTools {
  47781. /**
  47782. * Magic number identifying the env file.
  47783. */
  47784. private static _MagicBytes;
  47785. /**
  47786. * Gets the environment info from an env file.
  47787. * @param data The array buffer containing the .env bytes.
  47788. * @returns the environment file info (the json header) if successfully parsed.
  47789. */
  47790. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47791. /**
  47792. * Creates an environment texture from a loaded cube texture.
  47793. * @param texture defines the cube texture to convert in env file
  47794. * @return a promise containing the environment data if succesfull.
  47795. */
  47796. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47797. /**
  47798. * Creates a JSON representation of the spherical data.
  47799. * @param texture defines the texture containing the polynomials
  47800. * @return the JSON representation of the spherical info
  47801. */
  47802. private static _CreateEnvTextureIrradiance;
  47803. /**
  47804. * Uploads the texture info contained in the env file to the GPU.
  47805. * @param texture defines the internal texture to upload to
  47806. * @param arrayBuffer defines the buffer cotaining the data to load
  47807. * @param info defines the texture info retrieved through the GetEnvInfo method
  47808. * @returns a promise
  47809. */
  47810. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47811. /**
  47812. * Uploads the levels of image data to the GPU.
  47813. * @param texture defines the internal texture to upload to
  47814. * @param imageData defines the array buffer views of image data [mipmap][face]
  47815. * @returns a promise
  47816. */
  47817. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47818. /**
  47819. * Uploads spherical polynomials information to the texture.
  47820. * @param texture defines the texture we are trying to upload the information to
  47821. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47822. */
  47823. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47824. /** @hidden */
  47825. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47826. }
  47827. }
  47828. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47829. import { Nullable } from "babylonjs/types";
  47830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47831. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47832. /**
  47833. * Implementation of the ENV Texture Loader.
  47834. * @hidden
  47835. */
  47836. export class _ENVTextureLoader implements IInternalTextureLoader {
  47837. /**
  47838. * Defines wether the loader supports cascade loading the different faces.
  47839. */
  47840. readonly supportCascades: boolean;
  47841. /**
  47842. * This returns if the loader support the current file information.
  47843. * @param extension defines the file extension of the file being loaded
  47844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47845. * @param fallback defines the fallback internal texture if any
  47846. * @param isBase64 defines whether the texture is encoded as a base64
  47847. * @param isBuffer defines whether the texture data are stored as a buffer
  47848. * @returns true if the loader can load the specified file
  47849. */
  47850. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47851. /**
  47852. * Transform the url before loading if required.
  47853. * @param rootUrl the url of the texture
  47854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47855. * @returns the transformed texture
  47856. */
  47857. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47858. /**
  47859. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47860. * @param rootUrl the url of the texture
  47861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47862. * @returns the fallback texture
  47863. */
  47864. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47865. /**
  47866. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47867. * @param data contains the texture data
  47868. * @param texture defines the BabylonJS internal texture
  47869. * @param createPolynomials will be true if polynomials have been requested
  47870. * @param onLoad defines the callback to trigger once the texture is ready
  47871. * @param onError defines the callback to trigger in case of error
  47872. */
  47873. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47874. /**
  47875. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47876. * @param data contains the texture data
  47877. * @param texture defines the BabylonJS internal texture
  47878. * @param callback defines the method to call once ready to upload
  47879. */
  47880. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47881. }
  47882. }
  47883. declare module "babylonjs/Misc/khronosTextureContainer" {
  47884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47885. /**
  47886. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47887. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47888. */
  47889. export class KhronosTextureContainer {
  47890. /** contents of the KTX container file */
  47891. arrayBuffer: any;
  47892. private static HEADER_LEN;
  47893. private static COMPRESSED_2D;
  47894. private static COMPRESSED_3D;
  47895. private static TEX_2D;
  47896. private static TEX_3D;
  47897. /**
  47898. * Gets the openGL type
  47899. */
  47900. glType: number;
  47901. /**
  47902. * Gets the openGL type size
  47903. */
  47904. glTypeSize: number;
  47905. /**
  47906. * Gets the openGL format
  47907. */
  47908. glFormat: number;
  47909. /**
  47910. * Gets the openGL internal format
  47911. */
  47912. glInternalFormat: number;
  47913. /**
  47914. * Gets the base internal format
  47915. */
  47916. glBaseInternalFormat: number;
  47917. /**
  47918. * Gets image width in pixel
  47919. */
  47920. pixelWidth: number;
  47921. /**
  47922. * Gets image height in pixel
  47923. */
  47924. pixelHeight: number;
  47925. /**
  47926. * Gets image depth in pixels
  47927. */
  47928. pixelDepth: number;
  47929. /**
  47930. * Gets the number of array elements
  47931. */
  47932. numberOfArrayElements: number;
  47933. /**
  47934. * Gets the number of faces
  47935. */
  47936. numberOfFaces: number;
  47937. /**
  47938. * Gets the number of mipmap levels
  47939. */
  47940. numberOfMipmapLevels: number;
  47941. /**
  47942. * Gets the bytes of key value data
  47943. */
  47944. bytesOfKeyValueData: number;
  47945. /**
  47946. * Gets the load type
  47947. */
  47948. loadType: number;
  47949. /**
  47950. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47951. */
  47952. isInvalid: boolean;
  47953. /**
  47954. * Creates a new KhronosTextureContainer
  47955. * @param arrayBuffer contents of the KTX container file
  47956. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47957. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47958. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47959. */
  47960. constructor(
  47961. /** contents of the KTX container file */
  47962. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47963. /**
  47964. * Revert the endianness of a value.
  47965. * Not as fast hardware based, but will probably never need to use
  47966. * @param val defines the value to convert
  47967. * @returns the new value
  47968. */
  47969. switchEndianness(val: number): number;
  47970. /**
  47971. * Uploads KTX content to a Babylon Texture.
  47972. * It is assumed that the texture has already been created & is currently bound
  47973. * @hidden
  47974. */
  47975. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47976. private _upload2DCompressedLevels;
  47977. }
  47978. }
  47979. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47980. import { Nullable } from "babylonjs/types";
  47981. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47982. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47983. /**
  47984. * Implementation of the KTX Texture Loader.
  47985. * @hidden
  47986. */
  47987. export class _KTXTextureLoader implements IInternalTextureLoader {
  47988. /**
  47989. * Defines wether the loader supports cascade loading the different faces.
  47990. */
  47991. readonly supportCascades: boolean;
  47992. /**
  47993. * This returns if the loader support the current file information.
  47994. * @param extension defines the file extension of the file being loaded
  47995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47996. * @param fallback defines the fallback internal texture if any
  47997. * @param isBase64 defines whether the texture is encoded as a base64
  47998. * @param isBuffer defines whether the texture data are stored as a buffer
  47999. * @returns true if the loader can load the specified file
  48000. */
  48001. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48002. /**
  48003. * Transform the url before loading if required.
  48004. * @param rootUrl the url of the texture
  48005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48006. * @returns the transformed texture
  48007. */
  48008. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48009. /**
  48010. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48011. * @param rootUrl the url of the texture
  48012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48013. * @returns the fallback texture
  48014. */
  48015. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48016. /**
  48017. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48018. * @param data contains the texture data
  48019. * @param texture defines the BabylonJS internal texture
  48020. * @param createPolynomials will be true if polynomials have been requested
  48021. * @param onLoad defines the callback to trigger once the texture is ready
  48022. * @param onError defines the callback to trigger in case of error
  48023. */
  48024. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48025. /**
  48026. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48027. * @param data contains the texture data
  48028. * @param texture defines the BabylonJS internal texture
  48029. * @param callback defines the method to call once ready to upload
  48030. */
  48031. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48032. }
  48033. }
  48034. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48035. import { Nullable } from "babylonjs/types";
  48036. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48037. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48038. /**
  48039. * Implementation of the TGA Texture Loader.
  48040. * @hidden
  48041. */
  48042. export class _TGATextureLoader implements IInternalTextureLoader {
  48043. /**
  48044. * Defines wether the loader supports cascade loading the different faces.
  48045. */
  48046. readonly supportCascades: boolean;
  48047. /**
  48048. * This returns if the loader support the current file information.
  48049. * @param extension defines the file extension of the file being loaded
  48050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48051. * @param fallback defines the fallback internal texture if any
  48052. * @param isBase64 defines whether the texture is encoded as a base64
  48053. * @param isBuffer defines whether the texture data are stored as a buffer
  48054. * @returns true if the loader can load the specified file
  48055. */
  48056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48057. /**
  48058. * Transform the url before loading if required.
  48059. * @param rootUrl the url of the texture
  48060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48061. * @returns the transformed texture
  48062. */
  48063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48064. /**
  48065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48066. * @param rootUrl the url of the texture
  48067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48068. * @returns the fallback texture
  48069. */
  48070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48071. /**
  48072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48073. * @param data contains the texture data
  48074. * @param texture defines the BabylonJS internal texture
  48075. * @param createPolynomials will be true if polynomials have been requested
  48076. * @param onLoad defines the callback to trigger once the texture is ready
  48077. * @param onError defines the callback to trigger in case of error
  48078. */
  48079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48080. /**
  48081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48082. * @param data contains the texture data
  48083. * @param texture defines the BabylonJS internal texture
  48084. * @param callback defines the method to call once ready to upload
  48085. */
  48086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48087. }
  48088. }
  48089. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48090. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48091. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48092. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48093. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48094. }
  48095. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48096. import { Scene } from "babylonjs/scene";
  48097. import { Texture } from "babylonjs/Materials/Textures/texture";
  48098. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48099. /**
  48100. * 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.
  48101. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48102. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48103. */
  48104. export class CustomProceduralTexture extends ProceduralTexture {
  48105. private _animate;
  48106. private _time;
  48107. private _config;
  48108. private _texturePath;
  48109. /**
  48110. * Instantiates a new Custom Procedural Texture.
  48111. * 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.
  48112. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48113. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48114. * @param name Define the name of the texture
  48115. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48116. * @param size Define the size of the texture to create
  48117. * @param scene Define the scene the texture belongs to
  48118. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48119. * @param generateMipMaps Define if the texture should creates mip maps or not
  48120. */
  48121. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48122. private _loadJson;
  48123. /**
  48124. * Is the texture ready to be used ? (rendered at least once)
  48125. * @returns true if ready, otherwise, false.
  48126. */
  48127. isReady(): boolean;
  48128. /**
  48129. * Render the texture to its associated render target.
  48130. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48131. */
  48132. render(useCameraPostProcess?: boolean): void;
  48133. /**
  48134. * Update the list of dependant textures samplers in the shader.
  48135. */
  48136. updateTextures(): void;
  48137. /**
  48138. * Update the uniform values of the procedural texture in the shader.
  48139. */
  48140. updateShaderUniforms(): void;
  48141. /**
  48142. * Define if the texture animates or not.
  48143. */
  48144. animate: boolean;
  48145. }
  48146. }
  48147. declare module "babylonjs/Shaders/noise.fragment" {
  48148. export var noisePixelShader: {
  48149. name: string;
  48150. shader: string;
  48151. };
  48152. }
  48153. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48154. import { Nullable } from "babylonjs/types";
  48155. import { Scene } from "babylonjs/scene";
  48156. import { Texture } from "babylonjs/Materials/Textures/texture";
  48157. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48158. import "Shaders/noise.fragment";
  48159. /**
  48160. * Class used to generate noise procedural textures
  48161. */
  48162. export class NoiseProceduralTexture extends ProceduralTexture {
  48163. private _time;
  48164. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48165. brightness: number;
  48166. /** Defines the number of octaves to process */
  48167. octaves: number;
  48168. /** Defines the level of persistence (0.8 by default) */
  48169. persistence: number;
  48170. /** Gets or sets animation speed factor (default is 1) */
  48171. animationSpeedFactor: number;
  48172. /**
  48173. * Creates a new NoiseProceduralTexture
  48174. * @param name defines the name fo the texture
  48175. * @param size defines the size of the texture (default is 256)
  48176. * @param scene defines the hosting scene
  48177. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48178. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48179. */
  48180. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48181. private _updateShaderUniforms;
  48182. protected _getDefines(): string;
  48183. /** Generate the current state of the procedural texture */
  48184. render(useCameraPostProcess?: boolean): void;
  48185. /**
  48186. * Serializes this noise procedural texture
  48187. * @returns a serialized noise procedural texture object
  48188. */
  48189. serialize(): any;
  48190. /**
  48191. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48192. * @param parsedTexture defines parsed texture data
  48193. * @param scene defines the current scene
  48194. * @param rootUrl defines the root URL containing noise procedural texture information
  48195. * @returns a parsed NoiseProceduralTexture
  48196. */
  48197. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48198. }
  48199. }
  48200. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48201. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48202. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48203. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48204. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48205. }
  48206. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48207. import { Nullable } from "babylonjs/types";
  48208. import { Scene } from "babylonjs/scene";
  48209. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48210. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48211. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48212. /**
  48213. * Raw cube texture where the raw buffers are passed in
  48214. */
  48215. export class RawCubeTexture extends CubeTexture {
  48216. /**
  48217. * Creates a cube texture where the raw buffers are passed in.
  48218. * @param scene defines the scene the texture is attached to
  48219. * @param data defines the array of data to use to create each face
  48220. * @param size defines the size of the textures
  48221. * @param format defines the format of the data
  48222. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48223. * @param generateMipMaps defines if the engine should generate the mip levels
  48224. * @param invertY defines if data must be stored with Y axis inverted
  48225. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48226. * @param compression defines the compression used (null by default)
  48227. */
  48228. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48229. /**
  48230. * Updates the raw cube texture.
  48231. * @param data defines the data to store
  48232. * @param format defines the data format
  48233. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48234. * @param invertY defines if data must be stored with Y axis inverted
  48235. * @param compression defines the compression used (null by default)
  48236. * @param level defines which level of the texture to update
  48237. */
  48238. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48239. /**
  48240. * Updates a raw cube texture with RGBD encoded data.
  48241. * @param data defines the array of data [mipmap][face] to use to create each face
  48242. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48243. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48244. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48245. * @returns a promsie that resolves when the operation is complete
  48246. */
  48247. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48248. /**
  48249. * Clones the raw cube texture.
  48250. * @return a new cube texture
  48251. */
  48252. clone(): CubeTexture;
  48253. /** @hidden */
  48254. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48255. }
  48256. }
  48257. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48258. import { Scene } from "babylonjs/scene";
  48259. import { Texture } from "babylonjs/Materials/Textures/texture";
  48260. /**
  48261. * Class used to store 3D textures containing user data
  48262. */
  48263. export class RawTexture3D extends Texture {
  48264. /** Gets or sets the texture format to use */
  48265. format: number;
  48266. private _engine;
  48267. /**
  48268. * Create a new RawTexture3D
  48269. * @param data defines the data of the texture
  48270. * @param width defines the width of the texture
  48271. * @param height defines the height of the texture
  48272. * @param depth defines the depth of the texture
  48273. * @param format defines the texture format to use
  48274. * @param scene defines the hosting scene
  48275. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48276. * @param invertY defines if texture must be stored with Y axis inverted
  48277. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48278. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48279. */
  48280. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48281. /** Gets or sets the texture format to use */
  48282. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48283. /**
  48284. * Update the texture with new data
  48285. * @param data defines the data to store in the texture
  48286. */
  48287. update(data: ArrayBufferView): void;
  48288. }
  48289. }
  48290. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48291. import { Scene } from "babylonjs/scene";
  48292. import { Plane } from "babylonjs/Maths/math";
  48293. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48294. /**
  48295. * Creates a refraction texture used by refraction channel of the standard material.
  48296. * It is like a mirror but to see through a material.
  48297. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48298. */
  48299. export class RefractionTexture extends RenderTargetTexture {
  48300. /**
  48301. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48302. * 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.
  48303. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48304. */
  48305. refractionPlane: Plane;
  48306. /**
  48307. * Define how deep under the surface we should see.
  48308. */
  48309. depth: number;
  48310. /**
  48311. * Creates a refraction texture used by refraction channel of the standard material.
  48312. * It is like a mirror but to see through a material.
  48313. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48314. * @param name Define the texture name
  48315. * @param size Define the size of the underlying texture
  48316. * @param scene Define the scene the refraction belongs to
  48317. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48318. */
  48319. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48320. /**
  48321. * Clone the refraction texture.
  48322. * @returns the cloned texture
  48323. */
  48324. clone(): RefractionTexture;
  48325. /**
  48326. * Serialize the texture to a JSON representation you could use in Parse later on
  48327. * @returns the serialized JSON representation
  48328. */
  48329. serialize(): any;
  48330. }
  48331. }
  48332. declare module "babylonjs/Materials/Textures/index" {
  48333. export * from "babylonjs/Materials/Textures/baseTexture";
  48334. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48335. export * from "babylonjs/Materials/Textures/cubeTexture";
  48336. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48337. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48338. export * from "babylonjs/Materials/Textures/internalTexture";
  48339. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48340. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48341. export * from "babylonjs/Materials/Textures/Loaders/index";
  48342. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48343. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48344. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48345. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48346. export * from "babylonjs/Materials/Textures/rawTexture";
  48347. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48348. export * from "babylonjs/Materials/Textures/refractionTexture";
  48349. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48350. export * from "babylonjs/Materials/Textures/texture";
  48351. export * from "babylonjs/Materials/Textures/videoTexture";
  48352. }
  48353. declare module "babylonjs/Materials/index" {
  48354. export * from "babylonjs/Materials/Background/index";
  48355. export * from "babylonjs/Materials/colorCurves";
  48356. export * from "babylonjs/Materials/effect";
  48357. export * from "babylonjs/Materials/fresnelParameters";
  48358. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48359. export * from "babylonjs/Materials/material";
  48360. export * from "babylonjs/Materials/materialDefines";
  48361. export * from "babylonjs/Materials/materialHelper";
  48362. export * from "babylonjs/Materials/multiMaterial";
  48363. export * from "babylonjs/Materials/PBR/index";
  48364. export * from "babylonjs/Materials/pushMaterial";
  48365. export * from "babylonjs/Materials/shaderMaterial";
  48366. export * from "babylonjs/Materials/standardMaterial";
  48367. export * from "babylonjs/Materials/Textures/index";
  48368. export * from "babylonjs/Materials/uniformBuffer";
  48369. }
  48370. declare module "babylonjs/Maths/index" {
  48371. export * from "babylonjs/Maths/math.scalar";
  48372. export * from "babylonjs/Maths/math";
  48373. export * from "babylonjs/Maths/sphericalPolynomial";
  48374. }
  48375. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48376. import { IDisposable } from "babylonjs/scene";
  48377. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48378. /**
  48379. * Configuration for Draco compression
  48380. */
  48381. export interface IDracoCompressionConfiguration {
  48382. /**
  48383. * Configuration for the decoder.
  48384. */
  48385. decoder?: {
  48386. /**
  48387. * The url to the WebAssembly module.
  48388. */
  48389. wasmUrl?: string;
  48390. /**
  48391. * The url to the WebAssembly binary.
  48392. */
  48393. wasmBinaryUrl?: string;
  48394. /**
  48395. * The url to the fallback JavaScript module.
  48396. */
  48397. fallbackUrl?: string;
  48398. };
  48399. }
  48400. /**
  48401. * Draco compression (https://google.github.io/draco/)
  48402. *
  48403. * This class wraps the Draco module.
  48404. *
  48405. * **Encoder**
  48406. *
  48407. * The encoder is not currently implemented.
  48408. *
  48409. * **Decoder**
  48410. *
  48411. * 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.
  48412. *
  48413. * To update the configuration, use the following code:
  48414. * ```javascript
  48415. * DracoCompression.Configuration = {
  48416. * decoder: {
  48417. * wasmUrl: "<url to the WebAssembly library>",
  48418. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48419. * fallbackUrl: "<url to the fallback JavaScript library>",
  48420. * }
  48421. * };
  48422. * ```
  48423. *
  48424. * 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.
  48425. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48426. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48427. *
  48428. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48429. * ```javascript
  48430. * var dracoCompression = new DracoCompression();
  48431. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48432. * [VertexBuffer.PositionKind]: 0
  48433. * });
  48434. * ```
  48435. *
  48436. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48437. */
  48438. export class DracoCompression implements IDisposable {
  48439. private static _DecoderModulePromise;
  48440. /**
  48441. * The configuration. Defaults to the following urls:
  48442. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48443. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48444. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48445. */
  48446. static Configuration: IDracoCompressionConfiguration;
  48447. /**
  48448. * Returns true if the decoder is available.
  48449. */
  48450. static readonly DecoderAvailable: boolean;
  48451. /**
  48452. * Constructor
  48453. */
  48454. constructor();
  48455. /**
  48456. * Stop all async operations and release resources.
  48457. */
  48458. dispose(): void;
  48459. /**
  48460. * Decode Draco compressed mesh data to vertex data.
  48461. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48462. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48463. * @returns A promise that resolves with the decoded vertex data
  48464. */
  48465. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48466. [kind: string]: number;
  48467. }): Promise<VertexData>;
  48468. private static _GetDecoderModule;
  48469. private static _LoadScriptAsync;
  48470. private static _LoadFileAsync;
  48471. }
  48472. }
  48473. declare module "babylonjs/Meshes/Compression/index" {
  48474. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48475. }
  48476. declare module "babylonjs/Meshes/csg" {
  48477. import { Nullable } from "babylonjs/types";
  48478. import { Scene } from "babylonjs/scene";
  48479. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48480. import { Mesh } from "babylonjs/Meshes/mesh";
  48481. import { Material } from "babylonjs/Materials/material";
  48482. /**
  48483. * Class for building Constructive Solid Geometry
  48484. */
  48485. export class CSG {
  48486. private polygons;
  48487. /**
  48488. * The world matrix
  48489. */
  48490. matrix: Matrix;
  48491. /**
  48492. * Stores the position
  48493. */
  48494. position: Vector3;
  48495. /**
  48496. * Stores the rotation
  48497. */
  48498. rotation: Vector3;
  48499. /**
  48500. * Stores the rotation quaternion
  48501. */
  48502. rotationQuaternion: Nullable<Quaternion>;
  48503. /**
  48504. * Stores the scaling vector
  48505. */
  48506. scaling: Vector3;
  48507. /**
  48508. * Convert the Mesh to CSG
  48509. * @param mesh The Mesh to convert to CSG
  48510. * @returns A new CSG from the Mesh
  48511. */
  48512. static FromMesh(mesh: Mesh): CSG;
  48513. /**
  48514. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48515. * @param polygons Polygons used to construct a CSG solid
  48516. */
  48517. private static FromPolygons;
  48518. /**
  48519. * Clones, or makes a deep copy, of the CSG
  48520. * @returns A new CSG
  48521. */
  48522. clone(): CSG;
  48523. /**
  48524. * Unions this CSG with another CSG
  48525. * @param csg The CSG to union against this CSG
  48526. * @returns The unioned CSG
  48527. */
  48528. union(csg: CSG): CSG;
  48529. /**
  48530. * Unions this CSG with another CSG in place
  48531. * @param csg The CSG to union against this CSG
  48532. */
  48533. unionInPlace(csg: CSG): void;
  48534. /**
  48535. * Subtracts this CSG with another CSG
  48536. * @param csg The CSG to subtract against this CSG
  48537. * @returns A new CSG
  48538. */
  48539. subtract(csg: CSG): CSG;
  48540. /**
  48541. * Subtracts this CSG with another CSG in place
  48542. * @param csg The CSG to subtact against this CSG
  48543. */
  48544. subtractInPlace(csg: CSG): void;
  48545. /**
  48546. * Intersect this CSG with another CSG
  48547. * @param csg The CSG to intersect against this CSG
  48548. * @returns A new CSG
  48549. */
  48550. intersect(csg: CSG): CSG;
  48551. /**
  48552. * Intersects this CSG with another CSG in place
  48553. * @param csg The CSG to intersect against this CSG
  48554. */
  48555. intersectInPlace(csg: CSG): void;
  48556. /**
  48557. * Return a new CSG solid with solid and empty space switched. This solid is
  48558. * not modified.
  48559. * @returns A new CSG solid with solid and empty space switched
  48560. */
  48561. inverse(): CSG;
  48562. /**
  48563. * Inverses the CSG in place
  48564. */
  48565. inverseInPlace(): void;
  48566. /**
  48567. * This is used to keep meshes transformations so they can be restored
  48568. * when we build back a Babylon Mesh
  48569. * NB : All CSG operations are performed in world coordinates
  48570. * @param csg The CSG to copy the transform attributes from
  48571. * @returns This CSG
  48572. */
  48573. copyTransformAttributes(csg: CSG): CSG;
  48574. /**
  48575. * Build Raw mesh from CSG
  48576. * Coordinates here are in world space
  48577. * @param name The name of the mesh geometry
  48578. * @param scene The Scene
  48579. * @param keepSubMeshes Specifies if the submeshes should be kept
  48580. * @returns A new Mesh
  48581. */
  48582. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48583. /**
  48584. * Build Mesh from CSG taking material and transforms into account
  48585. * @param name The name of the Mesh
  48586. * @param material The material of the Mesh
  48587. * @param scene The Scene
  48588. * @param keepSubMeshes Specifies if submeshes should be kept
  48589. * @returns The new Mesh
  48590. */
  48591. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48592. }
  48593. }
  48594. declare module "babylonjs/Meshes/meshSimplification" {
  48595. import { Mesh } from "babylonjs/Meshes/mesh";
  48596. /**
  48597. * A simplifier interface for future simplification implementations
  48598. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48599. */
  48600. export interface ISimplifier {
  48601. /**
  48602. * Simplification of a given mesh according to the given settings.
  48603. * Since this requires computation, it is assumed that the function runs async.
  48604. * @param settings The settings of the simplification, including quality and distance
  48605. * @param successCallback A callback that will be called after the mesh was simplified.
  48606. * @param errorCallback in case of an error, this callback will be called. optional.
  48607. */
  48608. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  48609. }
  48610. /**
  48611. * Expected simplification settings.
  48612. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  48613. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48614. */
  48615. export interface ISimplificationSettings {
  48616. /**
  48617. * Gets or sets the expected quality
  48618. */
  48619. quality: number;
  48620. /**
  48621. * Gets or sets the distance when this optimized version should be used
  48622. */
  48623. distance: number;
  48624. /**
  48625. * Gets an already optimized mesh
  48626. */
  48627. optimizeMesh?: boolean;
  48628. }
  48629. /**
  48630. * Class used to specify simplification options
  48631. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48632. */
  48633. export class SimplificationSettings implements ISimplificationSettings {
  48634. /** expected quality */
  48635. quality: number;
  48636. /** distance when this optimized version should be used */
  48637. distance: number;
  48638. /** already optimized mesh */
  48639. optimizeMesh?: boolean | undefined;
  48640. /**
  48641. * Creates a SimplificationSettings
  48642. * @param quality expected quality
  48643. * @param distance distance when this optimized version should be used
  48644. * @param optimizeMesh already optimized mesh
  48645. */
  48646. constructor(
  48647. /** expected quality */
  48648. quality: number,
  48649. /** distance when this optimized version should be used */
  48650. distance: number,
  48651. /** already optimized mesh */
  48652. optimizeMesh?: boolean | undefined);
  48653. }
  48654. /**
  48655. * Interface used to define a simplification task
  48656. */
  48657. export interface ISimplificationTask {
  48658. /**
  48659. * Array of settings
  48660. */
  48661. settings: Array<ISimplificationSettings>;
  48662. /**
  48663. * Simplification type
  48664. */
  48665. simplificationType: SimplificationType;
  48666. /**
  48667. * Mesh to simplify
  48668. */
  48669. mesh: Mesh;
  48670. /**
  48671. * Callback called on success
  48672. */
  48673. successCallback?: () => void;
  48674. /**
  48675. * Defines if parallel processing can be used
  48676. */
  48677. parallelProcessing: boolean;
  48678. }
  48679. /**
  48680. * Queue used to order the simplification tasks
  48681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48682. */
  48683. export class SimplificationQueue {
  48684. private _simplificationArray;
  48685. /**
  48686. * Gets a boolean indicating that the process is still running
  48687. */
  48688. running: boolean;
  48689. /**
  48690. * Creates a new queue
  48691. */
  48692. constructor();
  48693. /**
  48694. * Adds a new simplification task
  48695. * @param task defines a task to add
  48696. */
  48697. addTask(task: ISimplificationTask): void;
  48698. /**
  48699. * Execute next task
  48700. */
  48701. executeNext(): void;
  48702. /**
  48703. * Execute a simplification task
  48704. * @param task defines the task to run
  48705. */
  48706. runSimplification(task: ISimplificationTask): void;
  48707. private getSimplifier;
  48708. }
  48709. /**
  48710. * The implemented types of simplification
  48711. * At the moment only Quadratic Error Decimation is implemented
  48712. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48713. */
  48714. export enum SimplificationType {
  48715. /** Quadratic error decimation */
  48716. QUADRATIC = 0
  48717. }
  48718. }
  48719. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  48720. import { Scene } from "babylonjs/scene";
  48721. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  48722. import { ISceneComponent } from "babylonjs/sceneComponent";
  48723. module "babylonjs/scene" {
  48724. interface Scene {
  48725. /** @hidden (Backing field) */
  48726. _simplificationQueue: SimplificationQueue;
  48727. /**
  48728. * Gets or sets the simplification queue attached to the scene
  48729. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48730. */
  48731. simplificationQueue: SimplificationQueue;
  48732. }
  48733. }
  48734. module "babylonjs/Meshes/mesh" {
  48735. interface Mesh {
  48736. /**
  48737. * Simplify the mesh according to the given array of settings.
  48738. * Function will return immediately and will simplify async
  48739. * @param settings a collection of simplification settings
  48740. * @param parallelProcessing should all levels calculate parallel or one after the other
  48741. * @param simplificationType the type of simplification to run
  48742. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  48743. * @returns the current mesh
  48744. */
  48745. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  48746. }
  48747. }
  48748. /**
  48749. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  48750. * created in a scene
  48751. */
  48752. export class SimplicationQueueSceneComponent implements ISceneComponent {
  48753. /**
  48754. * The component name helpfull to identify the component in the list of scene components.
  48755. */
  48756. readonly name: string;
  48757. /**
  48758. * The scene the component belongs to.
  48759. */
  48760. scene: Scene;
  48761. /**
  48762. * Creates a new instance of the component for the given scene
  48763. * @param scene Defines the scene to register the component in
  48764. */
  48765. constructor(scene: Scene);
  48766. /**
  48767. * Registers the component in a given scene
  48768. */
  48769. register(): void;
  48770. /**
  48771. * Rebuilds the elements related to this component in case of
  48772. * context lost for instance.
  48773. */
  48774. rebuild(): void;
  48775. /**
  48776. * Disposes the component and the associated ressources
  48777. */
  48778. dispose(): void;
  48779. private _beforeCameraUpdate;
  48780. }
  48781. }
  48782. declare module "babylonjs/Meshes/index" {
  48783. export * from "babylonjs/Meshes/abstractMesh";
  48784. export * from "babylonjs/Meshes/buffer";
  48785. export * from "babylonjs/Meshes/Compression/index";
  48786. export * from "babylonjs/Meshes/csg";
  48787. export * from "babylonjs/Meshes/geometry";
  48788. export * from "babylonjs/Meshes/groundMesh";
  48789. export * from "babylonjs/Meshes/instancedMesh";
  48790. export * from "babylonjs/Meshes/linesMesh";
  48791. export * from "babylonjs/Meshes/mesh";
  48792. export * from "babylonjs/Meshes/mesh.vertexData";
  48793. export * from "babylonjs/Meshes/meshBuilder";
  48794. export * from "babylonjs/Meshes/meshSimplification";
  48795. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  48796. export * from "babylonjs/Meshes/polygonMesh";
  48797. export * from "babylonjs/Meshes/subMesh";
  48798. export * from "babylonjs/Meshes/transformNode";
  48799. }
  48800. declare module "babylonjs/Morph/index" {
  48801. export * from "babylonjs/Morph/morphTarget";
  48802. export * from "babylonjs/Morph/morphTargetManager";
  48803. }
  48804. declare module "babylonjs/Offline/database" {
  48805. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  48806. /**
  48807. * Class used to enable access to IndexedDB
  48808. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48809. */
  48810. export class Database implements IOfflineProvider {
  48811. private _callbackManifestChecked;
  48812. private _currentSceneUrl;
  48813. private _db;
  48814. private _enableSceneOffline;
  48815. private _enableTexturesOffline;
  48816. private _manifestVersionFound;
  48817. private _mustUpdateRessources;
  48818. private _hasReachedQuota;
  48819. private _isSupported;
  48820. private _idbFactory;
  48821. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  48822. private static IsUASupportingBlobStorage;
  48823. /**
  48824. * Gets a boolean indicating if Database storate is enabled (off by default)
  48825. */
  48826. static IDBStorageEnabled: boolean;
  48827. /**
  48828. * Gets a boolean indicating if scene must be saved in the database
  48829. */
  48830. readonly enableSceneOffline: boolean;
  48831. /**
  48832. * Gets a boolean indicating if textures must be saved in the database
  48833. */
  48834. readonly enableTexturesOffline: boolean;
  48835. /**
  48836. * Creates a new Database
  48837. * @param urlToScene defines the url to load the scene
  48838. * @param callbackManifestChecked defines the callback to use when manifest is checked
  48839. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  48840. */
  48841. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  48842. private static _ParseURL;
  48843. private static _ReturnFullUrlLocation;
  48844. private _checkManifestFile;
  48845. /**
  48846. * Open the database and make it available
  48847. * @param successCallback defines the callback to call on success
  48848. * @param errorCallback defines the callback to call on error
  48849. */
  48850. open(successCallback: () => void, errorCallback: () => void): void;
  48851. /**
  48852. * Loads an image from the database
  48853. * @param url defines the url to load from
  48854. * @param image defines the target DOM image
  48855. */
  48856. loadImage(url: string, image: HTMLImageElement): void;
  48857. private _loadImageFromDBAsync;
  48858. private _saveImageIntoDBAsync;
  48859. private _checkVersionFromDB;
  48860. private _loadVersionFromDBAsync;
  48861. private _saveVersionIntoDBAsync;
  48862. /**
  48863. * Loads a file from database
  48864. * @param url defines the URL to load from
  48865. * @param sceneLoaded defines a callback to call on success
  48866. * @param progressCallBack defines a callback to call when progress changed
  48867. * @param errorCallback defines a callback to call on error
  48868. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  48869. */
  48870. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  48871. private _loadFileAsync;
  48872. private _saveFileAsync;
  48873. }
  48874. }
  48875. declare module "babylonjs/Offline/index" {
  48876. export * from "babylonjs/Offline/database";
  48877. export * from "babylonjs/Offline/IOfflineProvider";
  48878. }
  48879. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  48880. export var gpuUpdateParticlesPixelShader: {
  48881. name: string;
  48882. shader: string;
  48883. };
  48884. }
  48885. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  48886. export var gpuUpdateParticlesVertexShader: {
  48887. name: string;
  48888. shader: string;
  48889. };
  48890. }
  48891. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  48892. export var clipPlaneFragmentDeclaration2: {
  48893. name: string;
  48894. shader: string;
  48895. };
  48896. }
  48897. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  48898. import "Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  48899. import "Shaders/ShadersInclude/imageProcessingDeclaration";
  48900. import "Shaders/ShadersInclude/helperFunctions";
  48901. import "Shaders/ShadersInclude/imageProcessingFunctions";
  48902. import "Shaders/ShadersInclude/clipPlaneFragment";
  48903. export var gpuRenderParticlesPixelShader: {
  48904. name: string;
  48905. shader: string;
  48906. };
  48907. }
  48908. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  48909. export var clipPlaneVertexDeclaration2: {
  48910. name: string;
  48911. shader: string;
  48912. };
  48913. }
  48914. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  48915. import "Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  48916. import "Shaders/ShadersInclude/clipPlaneVertex";
  48917. export var gpuRenderParticlesVertexShader: {
  48918. name: string;
  48919. shader: string;
  48920. };
  48921. }
  48922. declare module "babylonjs/Particles/gpuParticleSystem" {
  48923. import { Nullable } from "babylonjs/types";
  48924. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  48925. import { Observable } from "babylonjs/Misc/observable";
  48926. import { Color4, Color3 } from "babylonjs/Maths/math";
  48927. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48928. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  48929. import { Scene, IDisposable } from "babylonjs/scene";
  48930. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  48931. import "Shaders/gpuUpdateParticles.fragment";
  48932. import "Shaders/gpuUpdateParticles.vertex";
  48933. import "Shaders/gpuRenderParticles.fragment";
  48934. import "Shaders/gpuRenderParticles.vertex";
  48935. /**
  48936. * This represents a GPU particle system in Babylon
  48937. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  48938. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  48939. */
  48940. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  48941. /**
  48942. * The layer mask we are rendering the particles through.
  48943. */
  48944. layerMask: number;
  48945. private _capacity;
  48946. private _activeCount;
  48947. private _currentActiveCount;
  48948. private _accumulatedCount;
  48949. private _renderEffect;
  48950. private _updateEffect;
  48951. private _buffer0;
  48952. private _buffer1;
  48953. private _spriteBuffer;
  48954. private _updateVAO;
  48955. private _renderVAO;
  48956. private _targetIndex;
  48957. private _sourceBuffer;
  48958. private _targetBuffer;
  48959. private _engine;
  48960. private _currentRenderId;
  48961. private _started;
  48962. private _stopped;
  48963. private _timeDelta;
  48964. private _randomTexture;
  48965. private _randomTexture2;
  48966. private _attributesStrideSize;
  48967. private _updateEffectOptions;
  48968. private _randomTextureSize;
  48969. private _actualFrame;
  48970. private readonly _rawTextureWidth;
  48971. /**
  48972. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  48973. */
  48974. static readonly IsSupported: boolean;
  48975. /**
  48976. * An event triggered when the system is disposed.
  48977. */
  48978. onDisposeObservable: Observable<GPUParticleSystem>;
  48979. /**
  48980. * Gets the maximum number of particles active at the same time.
  48981. * @returns The max number of active particles.
  48982. */
  48983. getCapacity(): number;
  48984. /**
  48985. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  48986. * to override the particles.
  48987. */
  48988. forceDepthWrite: boolean;
  48989. /**
  48990. * Gets or set the number of active particles
  48991. */
  48992. activeParticleCount: number;
  48993. private _preWarmDone;
  48994. /**
  48995. * Is this system ready to be used/rendered
  48996. * @return true if the system is ready
  48997. */
  48998. isReady(): boolean;
  48999. /**
  49000. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49001. * @returns True if it has been started, otherwise false.
  49002. */
  49003. isStarted(): boolean;
  49004. /**
  49005. * Starts the particle system and begins to emit
  49006. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49007. */
  49008. start(delay?: number): void;
  49009. /**
  49010. * Stops the particle system.
  49011. */
  49012. stop(): void;
  49013. /**
  49014. * Remove all active particles
  49015. */
  49016. reset(): void;
  49017. /**
  49018. * Returns the string "GPUParticleSystem"
  49019. * @returns a string containing the class name
  49020. */
  49021. getClassName(): string;
  49022. private _colorGradientsTexture;
  49023. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49024. /**
  49025. * Adds a new color gradient
  49026. * @param gradient defines the gradient to use (between 0 and 1)
  49027. * @param color1 defines the color to affect to the specified gradient
  49028. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49029. * @returns the current particle system
  49030. */
  49031. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49032. /**
  49033. * Remove a specific color gradient
  49034. * @param gradient defines the gradient to remove
  49035. * @returns the current particle system
  49036. */
  49037. removeColorGradient(gradient: number): GPUParticleSystem;
  49038. private _angularSpeedGradientsTexture;
  49039. private _sizeGradientsTexture;
  49040. private _velocityGradientsTexture;
  49041. private _limitVelocityGradientsTexture;
  49042. private _dragGradientsTexture;
  49043. private _addFactorGradient;
  49044. /**
  49045. * Adds a new size gradient
  49046. * @param gradient defines the gradient to use (between 0 and 1)
  49047. * @param factor defines the size factor to affect to the specified gradient
  49048. * @returns the current particle system
  49049. */
  49050. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49051. /**
  49052. * Remove a specific size gradient
  49053. * @param gradient defines the gradient to remove
  49054. * @returns the current particle system
  49055. */
  49056. removeSizeGradient(gradient: number): GPUParticleSystem;
  49057. /**
  49058. * Adds a new angular speed gradient
  49059. * @param gradient defines the gradient to use (between 0 and 1)
  49060. * @param factor defines the angular speed to affect to the specified gradient
  49061. * @returns the current particle system
  49062. */
  49063. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49064. /**
  49065. * Remove a specific angular speed gradient
  49066. * @param gradient defines the gradient to remove
  49067. * @returns the current particle system
  49068. */
  49069. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49070. /**
  49071. * Adds a new velocity gradient
  49072. * @param gradient defines the gradient to use (between 0 and 1)
  49073. * @param factor defines the velocity to affect to the specified gradient
  49074. * @returns the current particle system
  49075. */
  49076. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49077. /**
  49078. * Remove a specific velocity gradient
  49079. * @param gradient defines the gradient to remove
  49080. * @returns the current particle system
  49081. */
  49082. removeVelocityGradient(gradient: number): GPUParticleSystem;
  49083. /**
  49084. * Adds a new limit velocity gradient
  49085. * @param gradient defines the gradient to use (between 0 and 1)
  49086. * @param factor defines the limit velocity value to affect to the specified gradient
  49087. * @returns the current particle system
  49088. */
  49089. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49090. /**
  49091. * Remove a specific limit velocity gradient
  49092. * @param gradient defines the gradient to remove
  49093. * @returns the current particle system
  49094. */
  49095. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  49096. /**
  49097. * Adds a new drag gradient
  49098. * @param gradient defines the gradient to use (between 0 and 1)
  49099. * @param factor defines the drag value to affect to the specified gradient
  49100. * @returns the current particle system
  49101. */
  49102. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  49103. /**
  49104. * Remove a specific drag gradient
  49105. * @param gradient defines the gradient to remove
  49106. * @returns the current particle system
  49107. */
  49108. removeDragGradient(gradient: number): GPUParticleSystem;
  49109. /**
  49110. * Not supported by GPUParticleSystem
  49111. * @param gradient defines the gradient to use (between 0 and 1)
  49112. * @param factor defines the emit rate value to affect to the specified gradient
  49113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49114. * @returns the current particle system
  49115. */
  49116. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49117. /**
  49118. * Not supported by GPUParticleSystem
  49119. * @param gradient defines the gradient to remove
  49120. * @returns the current particle system
  49121. */
  49122. removeEmitRateGradient(gradient: number): IParticleSystem;
  49123. /**
  49124. * Not supported by GPUParticleSystem
  49125. * @param gradient defines the gradient to use (between 0 and 1)
  49126. * @param factor defines the start size value to affect to the specified gradient
  49127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49128. * @returns the current particle system
  49129. */
  49130. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49131. /**
  49132. * Not supported by GPUParticleSystem
  49133. * @param gradient defines the gradient to remove
  49134. * @returns the current particle system
  49135. */
  49136. removeStartSizeGradient(gradient: number): IParticleSystem;
  49137. /**
  49138. * Not supported by GPUParticleSystem
  49139. * @param gradient defines the gradient to use (between 0 and 1)
  49140. * @param min defines the color remap minimal range
  49141. * @param max defines the color remap maximal range
  49142. * @returns the current particle system
  49143. */
  49144. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49145. /**
  49146. * Not supported by GPUParticleSystem
  49147. * @param gradient defines the gradient to remove
  49148. * @returns the current particle system
  49149. */
  49150. removeColorRemapGradient(): IParticleSystem;
  49151. /**
  49152. * Not supported by GPUParticleSystem
  49153. * @param gradient defines the gradient to use (between 0 and 1)
  49154. * @param min defines the alpha remap minimal range
  49155. * @param max defines the alpha remap maximal range
  49156. * @returns the current particle system
  49157. */
  49158. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49159. /**
  49160. * Not supported by GPUParticleSystem
  49161. * @param gradient defines the gradient to remove
  49162. * @returns the current particle system
  49163. */
  49164. removeAlphaRemapGradient(): IParticleSystem;
  49165. /**
  49166. * Not supported by GPUParticleSystem
  49167. * @param gradient defines the gradient to use (between 0 and 1)
  49168. * @param color defines the color to affect to the specified gradient
  49169. * @returns the current particle system
  49170. */
  49171. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  49172. /**
  49173. * Not supported by GPUParticleSystem
  49174. * @param gradient defines the gradient to remove
  49175. * @returns the current particle system
  49176. */
  49177. removeRampGradient(): IParticleSystem;
  49178. /**
  49179. * Not supported by GPUParticleSystem
  49180. * @returns the list of ramp gradients
  49181. */
  49182. getRampGradients(): Nullable<Array<Color3Gradient>>;
  49183. /**
  49184. * Not supported by GPUParticleSystem
  49185. * Gets or sets a boolean indicating that ramp gradients must be used
  49186. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  49187. */
  49188. useRampGradients: boolean;
  49189. /**
  49190. * Not supported by GPUParticleSystem
  49191. * @param gradient defines the gradient to use (between 0 and 1)
  49192. * @param factor defines the life time factor to affect to the specified gradient
  49193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49194. * @returns the current particle system
  49195. */
  49196. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49197. /**
  49198. * Not supported by GPUParticleSystem
  49199. * @param gradient defines the gradient to remove
  49200. * @returns the current particle system
  49201. */
  49202. removeLifeTimeGradient(gradient: number): IParticleSystem;
  49203. /**
  49204. * Instantiates a GPU particle system.
  49205. * 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.
  49206. * @param name The name of the particle system
  49207. * @param options The options used to create the system
  49208. * @param scene The scene the particle system belongs to
  49209. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  49210. */
  49211. constructor(name: string, options: Partial<{
  49212. capacity: number;
  49213. randomTextureSize: number;
  49214. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  49215. protected _reset(): void;
  49216. private _createUpdateVAO;
  49217. private _createRenderVAO;
  49218. private _initialize;
  49219. /** @hidden */
  49220. _recreateUpdateEffect(): void;
  49221. /** @hidden */
  49222. _recreateRenderEffect(): void;
  49223. /**
  49224. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  49225. * @param preWarm defines if we are in the pre-warmimg phase
  49226. */
  49227. animate(preWarm?: boolean): void;
  49228. private _createFactorGradientTexture;
  49229. private _createSizeGradientTexture;
  49230. private _createAngularSpeedGradientTexture;
  49231. private _createVelocityGradientTexture;
  49232. private _createLimitVelocityGradientTexture;
  49233. private _createDragGradientTexture;
  49234. private _createColorGradientTexture;
  49235. /**
  49236. * Renders the particle system in its current state
  49237. * @param preWarm defines if the system should only update the particles but not render them
  49238. * @returns the current number of particles
  49239. */
  49240. render(preWarm?: boolean): number;
  49241. /**
  49242. * Rebuilds the particle system
  49243. */
  49244. rebuild(): void;
  49245. private _releaseBuffers;
  49246. private _releaseVAOs;
  49247. /**
  49248. * Disposes the particle system and free the associated resources
  49249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  49250. */
  49251. dispose(disposeTexture?: boolean): void;
  49252. /**
  49253. * Clones the particle system.
  49254. * @param name The name of the cloned object
  49255. * @param newEmitter The new emitter to use
  49256. * @returns the cloned particle system
  49257. */
  49258. clone(name: string, newEmitter: any): GPUParticleSystem;
  49259. /**
  49260. * Serializes the particle system to a JSON object.
  49261. * @returns the JSON object
  49262. */
  49263. serialize(): any;
  49264. /**
  49265. * Parses a JSON object to create a GPU particle system.
  49266. * @param parsedParticleSystem The JSON object to parse
  49267. * @param scene The scene to create the particle system in
  49268. * @param rootUrl The root url to use to load external dependencies like texture
  49269. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  49270. * @returns the parsed GPU particle system
  49271. */
  49272. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  49273. }
  49274. }
  49275. declare module "babylonjs/Particles/particleSystemSet" {
  49276. import { Nullable } from "babylonjs/types";
  49277. import { Color3 } from "babylonjs/Maths/math";
  49278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49280. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49281. import { Scene, IDisposable } from "babylonjs/scene";
  49282. /**
  49283. * Represents a set of particle systems working together to create a specific effect
  49284. */
  49285. export class ParticleSystemSet implements IDisposable {
  49286. private _emitterCreationOptions;
  49287. private _emitterNode;
  49288. /**
  49289. * Gets the particle system list
  49290. */
  49291. systems: IParticleSystem[];
  49292. /**
  49293. * Gets the emitter node used with this set
  49294. */
  49295. readonly emitterNode: Nullable<TransformNode>;
  49296. /**
  49297. * Creates a new emitter mesh as a sphere
  49298. * @param options defines the options used to create the sphere
  49299. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  49300. * @param scene defines the hosting scene
  49301. */
  49302. setEmitterAsSphere(options: {
  49303. diameter: number;
  49304. segments: number;
  49305. color: Color3;
  49306. }, renderingGroupId: number, scene: Scene): void;
  49307. /**
  49308. * Starts all particle systems of the set
  49309. * @param emitter defines an optional mesh to use as emitter for the particle systems
  49310. */
  49311. start(emitter?: AbstractMesh): void;
  49312. /**
  49313. * Release all associated resources
  49314. */
  49315. dispose(): void;
  49316. /**
  49317. * Serialize the set into a JSON compatible object
  49318. * @returns a JSON compatible representation of the set
  49319. */
  49320. serialize(): any;
  49321. /**
  49322. * Parse a new ParticleSystemSet from a serialized source
  49323. * @param data defines a JSON compatible representation of the set
  49324. * @param scene defines the hosting scene
  49325. * @param gpu defines if we want GPU particles or CPU particles
  49326. * @returns a new ParticleSystemSet
  49327. */
  49328. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  49329. }
  49330. }
  49331. declare module "babylonjs/Particles/particleHelper" {
  49332. import { Nullable } from "babylonjs/types";
  49333. import { Scene } from "babylonjs/scene";
  49334. import { Vector3 } from "babylonjs/Maths/math";
  49335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49336. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49337. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  49338. /**
  49339. * This class is made for on one-liner static method to help creating particle system set.
  49340. */
  49341. export class ParticleHelper {
  49342. /**
  49343. * Gets or sets base Assets URL
  49344. */
  49345. static BaseAssetsUrl: string;
  49346. /**
  49347. * Create a default particle system that you can tweak
  49348. * @param emitter defines the emitter to use
  49349. * @param capacity defines the system capacity (default is 500 particles)
  49350. * @param scene defines the hosting scene
  49351. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  49352. * @returns the new Particle system
  49353. */
  49354. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  49355. /**
  49356. * This is the main static method (one-liner) of this helper to create different particle systems
  49357. * @param type This string represents the type to the particle system to create
  49358. * @param scene The scene where the particle system should live
  49359. * @param gpu If the system will use gpu
  49360. * @returns the ParticleSystemSet created
  49361. */
  49362. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  49363. /**
  49364. * Static function used to export a particle system to a ParticleSystemSet variable.
  49365. * Please note that the emitter shape is not exported
  49366. * @param systems defines the particle systems to export
  49367. * @returns the created particle system set
  49368. */
  49369. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  49370. }
  49371. }
  49372. declare module "babylonjs/Particles/particleSystemComponent" {
  49373. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49374. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  49375. import "Shaders/particles.vertex";
  49376. module "babylonjs/Engines/engine" {
  49377. interface Engine {
  49378. /**
  49379. * Create an effect to use with particle systems.
  49380. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  49381. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  49382. * @param uniformsNames defines a list of attribute names
  49383. * @param samplers defines an array of string used to represent textures
  49384. * @param defines defines the string containing the defines to use to compile the shaders
  49385. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  49386. * @param onCompiled defines a function to call when the effect creation is successful
  49387. * @param onError defines a function to call when the effect creation has failed
  49388. * @returns the new Effect
  49389. */
  49390. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  49391. }
  49392. }
  49393. module "babylonjs/Meshes/mesh" {
  49394. interface Mesh {
  49395. /**
  49396. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  49397. * @returns an array of IParticleSystem
  49398. */
  49399. getEmittedParticleSystems(): IParticleSystem[];
  49400. /**
  49401. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  49402. * @returns an array of IParticleSystem
  49403. */
  49404. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  49405. }
  49406. }
  49407. }
  49408. declare module "babylonjs/Particles/index" {
  49409. export * from "babylonjs/Particles/baseParticleSystem";
  49410. export * from "babylonjs/Particles/EmitterTypes/index";
  49411. export * from "babylonjs/Particles/gpuParticleSystem";
  49412. export * from "babylonjs/Particles/IParticleSystem";
  49413. export * from "babylonjs/Particles/particle";
  49414. export * from "babylonjs/Particles/particleHelper";
  49415. export * from "babylonjs/Particles/particleSystem";
  49416. export * from "babylonjs/Particles/particleSystemComponent";
  49417. export * from "babylonjs/Particles/particleSystemSet";
  49418. export * from "babylonjs/Particles/solidParticle";
  49419. export * from "babylonjs/Particles/solidParticleSystem";
  49420. export * from "babylonjs/Particles/subEmitter";
  49421. }
  49422. declare module "babylonjs/Physics/physicsEngineComponent" {
  49423. import { Nullable } from "babylonjs/types";
  49424. import { Observable, Observer } from "babylonjs/Misc/observable";
  49425. import { Vector3 } from "babylonjs/Maths/math";
  49426. import { Mesh } from "babylonjs/Meshes/mesh";
  49427. import { ISceneComponent } from "babylonjs/sceneComponent";
  49428. import { Scene } from "babylonjs/scene";
  49429. import { Node } from "babylonjs/node";
  49430. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49431. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49432. module "babylonjs/scene" {
  49433. interface Scene {
  49434. /** @hidden (Backing field) */
  49435. _physicsEngine: Nullable<IPhysicsEngine>;
  49436. /**
  49437. * Gets the current physics engine
  49438. * @returns a IPhysicsEngine or null if none attached
  49439. */
  49440. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  49441. /**
  49442. * Enables physics to the current scene
  49443. * @param gravity defines the scene's gravity for the physics engine
  49444. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  49445. * @return a boolean indicating if the physics engine was initialized
  49446. */
  49447. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  49448. /**
  49449. * Disables and disposes the physics engine associated with the scene
  49450. */
  49451. disablePhysicsEngine(): void;
  49452. /**
  49453. * Gets a boolean indicating if there is an active physics engine
  49454. * @returns a boolean indicating if there is an active physics engine
  49455. */
  49456. isPhysicsEnabled(): boolean;
  49457. /**
  49458. * Deletes a physics compound impostor
  49459. * @param compound defines the compound to delete
  49460. */
  49461. deleteCompoundImpostor(compound: any): void;
  49462. /**
  49463. * An event triggered when physic simulation is about to be run
  49464. */
  49465. onBeforePhysicsObservable: Observable<Scene>;
  49466. /**
  49467. * An event triggered when physic simulation has been done
  49468. */
  49469. onAfterPhysicsObservable: Observable<Scene>;
  49470. }
  49471. }
  49472. module "babylonjs/Meshes/abstractMesh" {
  49473. interface AbstractMesh {
  49474. /** @hidden */
  49475. _physicsImpostor: Nullable<PhysicsImpostor>;
  49476. /**
  49477. * Gets or sets impostor used for physic simulation
  49478. * @see http://doc.babylonjs.com/features/physics_engine
  49479. */
  49480. physicsImpostor: Nullable<PhysicsImpostor>;
  49481. /**
  49482. * Gets the current physics impostor
  49483. * @see http://doc.babylonjs.com/features/physics_engine
  49484. * @returns a physics impostor or null
  49485. */
  49486. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  49487. /** Apply a physic impulse to the mesh
  49488. * @param force defines the force to apply
  49489. * @param contactPoint defines where to apply the force
  49490. * @returns the current mesh
  49491. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49492. */
  49493. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  49494. /**
  49495. * Creates a physic joint between two meshes
  49496. * @param otherMesh defines the other mesh to use
  49497. * @param pivot1 defines the pivot to use on this mesh
  49498. * @param pivot2 defines the pivot to use on the other mesh
  49499. * @param options defines additional options (can be plugin dependent)
  49500. * @returns the current mesh
  49501. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  49502. */
  49503. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  49504. /** @hidden */
  49505. _disposePhysicsObserver: Nullable<Observer<Node>>;
  49506. }
  49507. }
  49508. /**
  49509. * Defines the physics engine scene component responsible to manage a physics engine
  49510. */
  49511. export class PhysicsEngineSceneComponent implements ISceneComponent {
  49512. /**
  49513. * The component name helpful to identify the component in the list of scene components.
  49514. */
  49515. readonly name: string;
  49516. /**
  49517. * The scene the component belongs to.
  49518. */
  49519. scene: Scene;
  49520. /**
  49521. * Creates a new instance of the component for the given scene
  49522. * @param scene Defines the scene to register the component in
  49523. */
  49524. constructor(scene: Scene);
  49525. /**
  49526. * Registers the component in a given scene
  49527. */
  49528. register(): void;
  49529. /**
  49530. * Rebuilds the elements related to this component in case of
  49531. * context lost for instance.
  49532. */
  49533. rebuild(): void;
  49534. /**
  49535. * Disposes the component and the associated ressources
  49536. */
  49537. dispose(): void;
  49538. }
  49539. }
  49540. declare module "babylonjs/Physics/physicsHelper" {
  49541. import { Nullable } from "babylonjs/types";
  49542. import { Vector3 } from "babylonjs/Maths/math";
  49543. import { Mesh } from "babylonjs/Meshes/mesh";
  49544. import { Ray } from "babylonjs/Culling/ray";
  49545. import { Scene } from "babylonjs/scene";
  49546. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49547. /**
  49548. * A helper for physics simulations
  49549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49550. */
  49551. export class PhysicsHelper {
  49552. private _scene;
  49553. private _physicsEngine;
  49554. /**
  49555. * Initializes the Physics helper
  49556. * @param scene Babylon.js scene
  49557. */
  49558. constructor(scene: Scene);
  49559. /**
  49560. * Applies a radial explosion impulse
  49561. * @param origin the origin of the explosion
  49562. * @param radius the explosion radius
  49563. * @param strength the explosion strength
  49564. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49565. * @returns A physics radial explosion event, or null
  49566. */
  49567. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  49568. /**
  49569. * Applies a radial explosion force
  49570. * @param origin the origin of the explosion
  49571. * @param radius the explosion radius
  49572. * @param strength the explosion strength
  49573. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49574. * @returns A physics radial explosion event, or null
  49575. */
  49576. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  49577. /**
  49578. * Creates a gravitational field
  49579. * @param origin the origin of the explosion
  49580. * @param radius the explosion radius
  49581. * @param strength the explosion strength
  49582. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49583. * @returns A physics gravitational field event, or null
  49584. */
  49585. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  49586. /**
  49587. * Creates a physics updraft event
  49588. * @param origin the origin of the updraft
  49589. * @param radius the radius of the updraft
  49590. * @param strength the strength of the updraft
  49591. * @param height the height of the updraft
  49592. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  49593. * @returns A physics updraft event, or null
  49594. */
  49595. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  49596. /**
  49597. * Creates a physics vortex event
  49598. * @param origin the of the vortex
  49599. * @param radius the radius of the vortex
  49600. * @param strength the strength of the vortex
  49601. * @param height the height of the vortex
  49602. * @returns a Physics vortex event, or null
  49603. * A physics vortex event or null
  49604. */
  49605. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  49606. }
  49607. /**
  49608. * Represents a physics radial explosion event
  49609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49610. */
  49611. export class PhysicsRadialExplosionEvent {
  49612. private _scene;
  49613. private _sphere;
  49614. private _sphereOptions;
  49615. private _rays;
  49616. private _dataFetched;
  49617. /**
  49618. * Initializes a radial explosioin event
  49619. * @param scene BabylonJS scene
  49620. */
  49621. constructor(scene: Scene);
  49622. /**
  49623. * Returns the data related to the radial explosion event (sphere & rays).
  49624. * @returns The radial explosion event data
  49625. */
  49626. getData(): PhysicsRadialExplosionEventData;
  49627. /**
  49628. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  49629. * @param impostor A physics imposter
  49630. * @param origin the origin of the explosion
  49631. * @param radius the explosion radius
  49632. * @param strength the explosion strength
  49633. * @param falloff possible options: Constant & Linear
  49634. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  49635. */
  49636. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  49637. /**
  49638. * Disposes the sphere.
  49639. * @param force Specifies if the sphere should be disposed by force
  49640. */
  49641. dispose(force?: boolean): void;
  49642. /*** Helpers ***/
  49643. private _prepareSphere;
  49644. private _intersectsWithSphere;
  49645. }
  49646. /**
  49647. * Represents a gravitational field event
  49648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49649. */
  49650. export class PhysicsGravitationalFieldEvent {
  49651. private _physicsHelper;
  49652. private _scene;
  49653. private _origin;
  49654. private _radius;
  49655. private _strength;
  49656. private _falloff;
  49657. private _tickCallback;
  49658. private _sphere;
  49659. private _dataFetched;
  49660. /**
  49661. * Initializes the physics gravitational field event
  49662. * @param physicsHelper A physics helper
  49663. * @param scene BabylonJS scene
  49664. * @param origin The origin position of the gravitational field event
  49665. * @param radius The radius of the gravitational field event
  49666. * @param strength The strength of the gravitational field event
  49667. * @param falloff The falloff for the gravitational field event
  49668. */
  49669. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  49670. /**
  49671. * Returns the data related to the gravitational field event (sphere).
  49672. * @returns A gravitational field event
  49673. */
  49674. getData(): PhysicsGravitationalFieldEventData;
  49675. /**
  49676. * Enables the gravitational field.
  49677. */
  49678. enable(): void;
  49679. /**
  49680. * Disables the gravitational field.
  49681. */
  49682. disable(): void;
  49683. /**
  49684. * Disposes the sphere.
  49685. * @param force The force to dispose from the gravitational field event
  49686. */
  49687. dispose(force?: boolean): void;
  49688. private _tick;
  49689. }
  49690. /**
  49691. * Represents a physics updraft event
  49692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49693. */
  49694. export class PhysicsUpdraftEvent {
  49695. private _scene;
  49696. private _origin;
  49697. private _radius;
  49698. private _strength;
  49699. private _height;
  49700. private _updraftMode;
  49701. private _physicsEngine;
  49702. private _originTop;
  49703. private _originDirection;
  49704. private _tickCallback;
  49705. private _cylinder;
  49706. private _cylinderPosition;
  49707. private _dataFetched;
  49708. /**
  49709. * Initializes the physics updraft event
  49710. * @param _scene BabylonJS scene
  49711. * @param _origin The origin position of the updraft
  49712. * @param _radius The radius of the updraft
  49713. * @param _strength The strength of the updraft
  49714. * @param _height The height of the updraft
  49715. * @param _updraftMode The mode of the updraft
  49716. */
  49717. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  49718. /**
  49719. * Returns the data related to the updraft event (cylinder).
  49720. * @returns A physics updraft event
  49721. */
  49722. getData(): PhysicsUpdraftEventData;
  49723. /**
  49724. * Enables the updraft.
  49725. */
  49726. enable(): void;
  49727. /**
  49728. * Disables the cortex.
  49729. */
  49730. disable(): void;
  49731. /**
  49732. * Disposes the sphere.
  49733. * @param force Specifies if the updraft should be disposed by force
  49734. */
  49735. dispose(force?: boolean): void;
  49736. private getImpostorForceAndContactPoint;
  49737. private _tick;
  49738. /*** Helpers ***/
  49739. private _prepareCylinder;
  49740. private _intersectsWithCylinder;
  49741. }
  49742. /**
  49743. * Represents a physics vortex event
  49744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49745. */
  49746. export class PhysicsVortexEvent {
  49747. private _scene;
  49748. private _origin;
  49749. private _radius;
  49750. private _strength;
  49751. private _height;
  49752. private _physicsEngine;
  49753. private _originTop;
  49754. private _centripetalForceThreshold;
  49755. private _updraftMultiplier;
  49756. private _tickCallback;
  49757. private _cylinder;
  49758. private _cylinderPosition;
  49759. private _dataFetched;
  49760. /**
  49761. * Initializes the physics vortex event
  49762. * @param _scene The BabylonJS scene
  49763. * @param _origin The origin position of the vortex
  49764. * @param _radius The radius of the vortex
  49765. * @param _strength The strength of the vortex
  49766. * @param _height The height of the vortex
  49767. */
  49768. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  49769. /**
  49770. * Returns the data related to the vortex event (cylinder).
  49771. * @returns The physics vortex event data
  49772. */
  49773. getData(): PhysicsVortexEventData;
  49774. /**
  49775. * Enables the vortex.
  49776. */
  49777. enable(): void;
  49778. /**
  49779. * Disables the cortex.
  49780. */
  49781. disable(): void;
  49782. /**
  49783. * Disposes the sphere.
  49784. * @param force
  49785. */
  49786. dispose(force?: boolean): void;
  49787. private getImpostorForceAndContactPoint;
  49788. private _tick;
  49789. /*** Helpers ***/
  49790. private _prepareCylinder;
  49791. private _intersectsWithCylinder;
  49792. }
  49793. /**
  49794. * The strenght of the force in correspondence to the distance of the affected object
  49795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49796. */
  49797. export enum PhysicsRadialImpulseFalloff {
  49798. /** Defines that impulse is constant in strength across it's whole radius */
  49799. Constant = 0,
  49800. /** DEfines that impulse gets weaker if it's further from the origin */
  49801. Linear = 1
  49802. }
  49803. /**
  49804. * The strength of the force in correspondence to the distance of the affected object
  49805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49806. */
  49807. export enum PhysicsUpdraftMode {
  49808. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  49809. Center = 0,
  49810. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  49811. Perpendicular = 1
  49812. }
  49813. /**
  49814. * Interface for a physics force and contact point
  49815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49816. */
  49817. export interface PhysicsForceAndContactPoint {
  49818. /**
  49819. * The force applied at the contact point
  49820. */
  49821. force: Vector3;
  49822. /**
  49823. * The contact point
  49824. */
  49825. contactPoint: Vector3;
  49826. }
  49827. /**
  49828. * Interface for radial explosion event data
  49829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49830. */
  49831. export interface PhysicsRadialExplosionEventData {
  49832. /**
  49833. * A sphere used for the radial explosion event
  49834. */
  49835. sphere: Mesh;
  49836. /**
  49837. * An array of rays for the radial explosion event
  49838. */
  49839. rays: Array<Ray>;
  49840. }
  49841. /**
  49842. * Interface for gravitational field event data
  49843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49844. */
  49845. export interface PhysicsGravitationalFieldEventData {
  49846. /**
  49847. * A sphere mesh used for the gravitational field event
  49848. */
  49849. sphere: Mesh;
  49850. }
  49851. /**
  49852. * Interface for updraft event data
  49853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49854. */
  49855. export interface PhysicsUpdraftEventData {
  49856. /**
  49857. * A cylinder used for the updraft event
  49858. */
  49859. cylinder: Mesh;
  49860. }
  49861. /**
  49862. * Interface for vortex event data
  49863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49864. */
  49865. export interface PhysicsVortexEventData {
  49866. /**
  49867. * A cylinder used for the vortex event
  49868. */
  49869. cylinder: Mesh;
  49870. }
  49871. }
  49872. declare module "babylonjs/Physics/Plugins/index" {
  49873. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  49874. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  49875. }
  49876. declare module "babylonjs/Physics/index" {
  49877. export * from "babylonjs/Physics/IPhysicsEngine";
  49878. export * from "babylonjs/Physics/physicsEngine";
  49879. export * from "babylonjs/Physics/physicsEngineComponent";
  49880. export * from "babylonjs/Physics/physicsHelper";
  49881. export * from "babylonjs/Physics/physicsImpostor";
  49882. export * from "babylonjs/Physics/physicsJoint";
  49883. export * from "babylonjs/Physics/Plugins/index";
  49884. }
  49885. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  49886. export var blackAndWhitePixelShader: {
  49887. name: string;
  49888. shader: string;
  49889. };
  49890. }
  49891. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  49892. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  49893. import { Camera } from "babylonjs/Cameras/camera";
  49894. import { Engine } from "babylonjs/Engines/engine";
  49895. import "Shaders/blackAndWhite.fragment";
  49896. /**
  49897. * Post process used to render in black and white
  49898. */
  49899. export class BlackAndWhitePostProcess extends PostProcess {
  49900. /**
  49901. * Linear about to convert he result to black and white (default: 1)
  49902. */
  49903. degree: number;
  49904. /**
  49905. * Creates a black and white post process
  49906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  49907. * @param name The name of the effect.
  49908. * @param options The required width/height ratio to downsize to before computing the render pass.
  49909. * @param camera The camera to apply the render pass to.
  49910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49911. * @param engine The engine which the post process will be applied. (default: current engine)
  49912. * @param reusable If the post process can be reused on the same frame. (default: false)
  49913. */
  49914. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49915. }
  49916. }
  49917. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  49918. import { Nullable } from "babylonjs/types";
  49919. import { Camera } from "babylonjs/Cameras/camera";
  49920. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49921. import { Engine } from "babylonjs/Engines/engine";
  49922. /**
  49923. * This represents a set of one or more post processes in Babylon.
  49924. * A post process can be used to apply a shader to a texture after it is rendered.
  49925. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49926. */
  49927. export class PostProcessRenderEffect {
  49928. private _postProcesses;
  49929. private _getPostProcesses;
  49930. private _singleInstance;
  49931. private _cameras;
  49932. private _indicesForCamera;
  49933. /**
  49934. * Name of the effect
  49935. * @hidden
  49936. */
  49937. _name: string;
  49938. /**
  49939. * Instantiates a post process render effect.
  49940. * A post process can be used to apply a shader to a texture after it is rendered.
  49941. * @param engine The engine the effect is tied to
  49942. * @param name The name of the effect
  49943. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49944. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49945. */
  49946. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49947. /**
  49948. * Checks if all the post processes in the effect are supported.
  49949. */
  49950. readonly isSupported: boolean;
  49951. /**
  49952. * Updates the current state of the effect
  49953. * @hidden
  49954. */
  49955. _update(): void;
  49956. /**
  49957. * Attaches the effect on cameras
  49958. * @param cameras The camera to attach to.
  49959. * @hidden
  49960. */
  49961. _attachCameras(cameras: Camera): void;
  49962. /**
  49963. * Attaches the effect on cameras
  49964. * @param cameras The camera to attach to.
  49965. * @hidden
  49966. */
  49967. _attachCameras(cameras: Camera[]): void;
  49968. /**
  49969. * Detatches the effect on cameras
  49970. * @param cameras The camera to detatch from.
  49971. * @hidden
  49972. */
  49973. _detachCameras(cameras: Camera): void;
  49974. /**
  49975. * Detatches the effect on cameras
  49976. * @param cameras The camera to detatch from.
  49977. * @hidden
  49978. */
  49979. _detachCameras(cameras: Camera[]): void;
  49980. /**
  49981. * Enables the effect on given cameras
  49982. * @param cameras The camera to enable.
  49983. * @hidden
  49984. */
  49985. _enable(cameras: Camera): void;
  49986. /**
  49987. * Enables the effect on given cameras
  49988. * @param cameras The camera to enable.
  49989. * @hidden
  49990. */
  49991. _enable(cameras: Nullable<Camera[]>): void;
  49992. /**
  49993. * Disables the effect on the given cameras
  49994. * @param cameras The camera to disable.
  49995. * @hidden
  49996. */
  49997. _disable(cameras: Camera): void;
  49998. /**
  49999. * Disables the effect on the given cameras
  50000. * @param cameras The camera to disable.
  50001. * @hidden
  50002. */
  50003. _disable(cameras: Nullable<Camera[]>): void;
  50004. /**
  50005. * Gets a list of the post processes contained in the effect.
  50006. * @param camera The camera to get the post processes on.
  50007. * @returns The list of the post processes in the effect.
  50008. */
  50009. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  50010. }
  50011. }
  50012. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  50013. import "Shaders/ShadersInclude/helperFunctions";
  50014. export var extractHighlightsPixelShader: {
  50015. name: string;
  50016. shader: string;
  50017. };
  50018. }
  50019. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  50020. import { Nullable } from "babylonjs/types";
  50021. import { Camera } from "babylonjs/Cameras/camera";
  50022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50023. import { Engine } from "babylonjs/Engines/engine";
  50024. import "Shaders/extractHighlights.fragment";
  50025. /**
  50026. * 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.
  50027. */
  50028. export class ExtractHighlightsPostProcess extends PostProcess {
  50029. /**
  50030. * The luminance threshold, pixels below this value will be set to black.
  50031. */
  50032. threshold: number;
  50033. /** @hidden */
  50034. _exposure: number;
  50035. /**
  50036. * Post process which has the input texture to be used when performing highlight extraction
  50037. * @hidden
  50038. */
  50039. _inputPostProcess: Nullable<PostProcess>;
  50040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50041. }
  50042. }
  50043. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  50044. export var bloomMergePixelShader: {
  50045. name: string;
  50046. shader: string;
  50047. };
  50048. }
  50049. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  50050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50051. import { Nullable } from "babylonjs/types";
  50052. import { Engine } from "babylonjs/Engines/engine";
  50053. import { Camera } from "babylonjs/Cameras/camera";
  50054. import "Shaders/bloomMerge.fragment";
  50055. /**
  50056. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50057. */
  50058. export class BloomMergePostProcess extends PostProcess {
  50059. /** Weight of the bloom to be added to the original input. */
  50060. weight: number;
  50061. /**
  50062. * Creates a new instance of @see BloomMergePostProcess
  50063. * @param name The name of the effect.
  50064. * @param originalFromInput Post process which's input will be used for the merge.
  50065. * @param blurred Blurred highlights post process which's output will be used.
  50066. * @param weight Weight of the bloom to be added to the original input.
  50067. * @param options The required width/height ratio to downsize to before computing the render pass.
  50068. * @param camera The camera to apply the render pass to.
  50069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50070. * @param engine The engine which the post process will be applied. (default: current engine)
  50071. * @param reusable If the post process can be reused on the same frame. (default: false)
  50072. * @param textureType Type of textures used when performing the post process. (default: 0)
  50073. * @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)
  50074. */
  50075. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  50076. /** Weight of the bloom to be added to the original input. */
  50077. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50078. }
  50079. }
  50080. declare module "babylonjs/PostProcesses/bloomEffect" {
  50081. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  50082. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50083. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  50084. import { Camera } from "babylonjs/Cameras/camera";
  50085. import { Scene } from "babylonjs/scene";
  50086. /**
  50087. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  50088. */
  50089. export class BloomEffect extends PostProcessRenderEffect {
  50090. private bloomScale;
  50091. /**
  50092. * @hidden Internal
  50093. */
  50094. _effects: Array<PostProcess>;
  50095. /**
  50096. * @hidden Internal
  50097. */
  50098. _downscale: ExtractHighlightsPostProcess;
  50099. private _blurX;
  50100. private _blurY;
  50101. private _merge;
  50102. /**
  50103. * The luminance threshold to find bright areas of the image to bloom.
  50104. */
  50105. threshold: number;
  50106. /**
  50107. * The strength of the bloom.
  50108. */
  50109. weight: number;
  50110. /**
  50111. * Specifies the size of the bloom blur kernel, relative to the final output size
  50112. */
  50113. kernel: number;
  50114. /**
  50115. * Creates a new instance of @see BloomEffect
  50116. * @param scene The scene the effect belongs to.
  50117. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  50118. * @param bloomKernel The size of the kernel to be used when applying the blur.
  50119. * @param bloomWeight The the strength of bloom.
  50120. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  50121. * @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)
  50122. */
  50123. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  50124. /**
  50125. * Disposes each of the internal effects for a given camera.
  50126. * @param camera The camera to dispose the effect on.
  50127. */
  50128. disposeEffects(camera: Camera): void;
  50129. /**
  50130. * @hidden Internal
  50131. */
  50132. _updateEffects(): void;
  50133. /**
  50134. * Internal
  50135. * @returns if all the contained post processes are ready.
  50136. * @hidden
  50137. */
  50138. _isReady(): boolean;
  50139. }
  50140. }
  50141. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  50142. export var chromaticAberrationPixelShader: {
  50143. name: string;
  50144. shader: string;
  50145. };
  50146. }
  50147. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  50148. import { Vector2 } from "babylonjs/Maths/math";
  50149. import { Nullable } from "babylonjs/types";
  50150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50151. import { Camera } from "babylonjs/Cameras/camera";
  50152. import { Engine } from "babylonjs/Engines/engine";
  50153. import "Shaders/chromaticAberration.fragment";
  50154. /**
  50155. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  50156. */
  50157. export class ChromaticAberrationPostProcess extends PostProcess {
  50158. /**
  50159. * The amount of seperation of rgb channels (default: 30)
  50160. */
  50161. aberrationAmount: number;
  50162. /**
  50163. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  50164. */
  50165. radialIntensity: number;
  50166. /**
  50167. * 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))
  50168. */
  50169. direction: Vector2;
  50170. /**
  50171. * 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))
  50172. */
  50173. centerPosition: Vector2;
  50174. /**
  50175. * Creates a new instance ChromaticAberrationPostProcess
  50176. * @param name The name of the effect.
  50177. * @param screenWidth The width of the screen to apply the effect on.
  50178. * @param screenHeight The height of the screen to apply the effect on.
  50179. * @param options The required width/height ratio to downsize to before computing the render pass.
  50180. * @param camera The camera to apply the render pass to.
  50181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50182. * @param engine The engine which the post process will be applied. (default: current engine)
  50183. * @param reusable If the post process can be reused on the same frame. (default: false)
  50184. * @param textureType Type of textures used when performing the post process. (default: 0)
  50185. * @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)
  50186. */
  50187. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50188. }
  50189. }
  50190. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  50191. export var circleOfConfusionPixelShader: {
  50192. name: string;
  50193. shader: string;
  50194. };
  50195. }
  50196. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  50197. import { Nullable } from "babylonjs/types";
  50198. import { Engine } from "babylonjs/Engines/engine";
  50199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50200. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50201. import { Camera } from "babylonjs/Cameras/camera";
  50202. import "Shaders/circleOfConfusion.fragment";
  50203. /**
  50204. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  50205. */
  50206. export class CircleOfConfusionPostProcess extends PostProcess {
  50207. /**
  50208. * 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.
  50209. */
  50210. lensSize: number;
  50211. /**
  50212. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  50213. */
  50214. fStop: number;
  50215. /**
  50216. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  50217. */
  50218. focusDistance: number;
  50219. /**
  50220. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  50221. */
  50222. focalLength: number;
  50223. private _depthTexture;
  50224. /**
  50225. * Creates a new instance CircleOfConfusionPostProcess
  50226. * @param name The name of the effect.
  50227. * @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.
  50228. * @param options The required width/height ratio to downsize to before computing the render pass.
  50229. * @param camera The camera to apply the render pass to.
  50230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50231. * @param engine The engine which the post process will be applied. (default: current engine)
  50232. * @param reusable If the post process can be reused on the same frame. (default: false)
  50233. * @param textureType Type of textures used when performing the post process. (default: 0)
  50234. * @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)
  50235. */
  50236. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50237. /**
  50238. * 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.
  50239. */
  50240. depthTexture: RenderTargetTexture;
  50241. }
  50242. }
  50243. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  50244. export var colorCorrectionPixelShader: {
  50245. name: string;
  50246. shader: string;
  50247. };
  50248. }
  50249. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  50250. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50251. import { Engine } from "babylonjs/Engines/engine";
  50252. import { Camera } from "babylonjs/Cameras/camera";
  50253. import "Shaders/colorCorrection.fragment";
  50254. /**
  50255. *
  50256. * This post-process allows the modification of rendered colors by using
  50257. * a 'look-up table' (LUT). This effect is also called Color Grading.
  50258. *
  50259. * The object needs to be provided an url to a texture containing the color
  50260. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  50261. * Use an image editing software to tweak the LUT to match your needs.
  50262. *
  50263. * For an example of a color LUT, see here:
  50264. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  50265. * For explanations on color grading, see here:
  50266. * @see http://udn.epicgames.com/Three/ColorGrading.html
  50267. *
  50268. */
  50269. export class ColorCorrectionPostProcess extends PostProcess {
  50270. private _colorTableTexture;
  50271. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50272. }
  50273. }
  50274. declare module "babylonjs/Shaders/convolution.fragment" {
  50275. export var convolutionPixelShader: {
  50276. name: string;
  50277. shader: string;
  50278. };
  50279. }
  50280. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  50281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50282. import { Nullable } from "babylonjs/types";
  50283. import { Camera } from "babylonjs/Cameras/camera";
  50284. import { Engine } from "babylonjs/Engines/engine";
  50285. import "Shaders/convolution.fragment";
  50286. /**
  50287. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  50288. * input texture to perform effects such as edge detection or sharpening
  50289. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50290. */
  50291. export class ConvolutionPostProcess extends PostProcess {
  50292. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  50293. kernel: number[];
  50294. /**
  50295. * Creates a new instance ConvolutionPostProcess
  50296. * @param name The name of the effect.
  50297. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  50298. * @param options The required width/height ratio to downsize to before computing the render pass.
  50299. * @param camera The camera to apply the render pass to.
  50300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50301. * @param engine The engine which the post process will be applied. (default: current engine)
  50302. * @param reusable If the post process can be reused on the same frame. (default: false)
  50303. * @param textureType Type of textures used when performing the post process. (default: 0)
  50304. */
  50305. constructor(name: string,
  50306. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  50307. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50308. /**
  50309. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50310. */
  50311. static EdgeDetect0Kernel: number[];
  50312. /**
  50313. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50314. */
  50315. static EdgeDetect1Kernel: number[];
  50316. /**
  50317. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50318. */
  50319. static EdgeDetect2Kernel: number[];
  50320. /**
  50321. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50322. */
  50323. static SharpenKernel: number[];
  50324. /**
  50325. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50326. */
  50327. static EmbossKernel: number[];
  50328. /**
  50329. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50330. */
  50331. static GaussianKernel: number[];
  50332. }
  50333. }
  50334. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  50335. import { Nullable } from "babylonjs/types";
  50336. import { Vector2 } from "babylonjs/Maths/math";
  50337. import { Camera } from "babylonjs/Cameras/camera";
  50338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50339. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  50340. import { Engine } from "babylonjs/Engines/engine";
  50341. import { Scene } from "babylonjs/scene";
  50342. /**
  50343. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  50344. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  50345. * based on samples that have a large difference in distance than the center pixel.
  50346. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  50347. */
  50348. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  50349. direction: Vector2;
  50350. /**
  50351. * Creates a new instance CircleOfConfusionPostProcess
  50352. * @param name The name of the effect.
  50353. * @param scene The scene the effect belongs to.
  50354. * @param direction The direction the blur should be applied.
  50355. * @param kernel The size of the kernel used to blur.
  50356. * @param options The required width/height ratio to downsize to before computing the render pass.
  50357. * @param camera The camera to apply the render pass to.
  50358. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  50359. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  50360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50361. * @param engine The engine which the post process will be applied. (default: current engine)
  50362. * @param reusable If the post process can be reused on the same frame. (default: false)
  50363. * @param textureType Type of textures used when performing the post process. (default: 0)
  50364. * @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)
  50365. */
  50366. 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);
  50367. }
  50368. }
  50369. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  50370. export var depthOfFieldMergePixelShader: {
  50371. name: string;
  50372. shader: string;
  50373. };
  50374. }
  50375. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  50376. import { Nullable } from "babylonjs/types";
  50377. import { Camera } from "babylonjs/Cameras/camera";
  50378. import { Effect } from "babylonjs/Materials/effect";
  50379. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50380. import { Engine } from "babylonjs/Engines/engine";
  50381. import "Shaders/depthOfFieldMerge.fragment";
  50382. /**
  50383. * Options to be set when merging outputs from the default pipeline.
  50384. */
  50385. export class DepthOfFieldMergePostProcessOptions {
  50386. /**
  50387. * The original image to merge on top of
  50388. */
  50389. originalFromInput: PostProcess;
  50390. /**
  50391. * Parameters to perform the merge of the depth of field effect
  50392. */
  50393. depthOfField?: {
  50394. circleOfConfusion: PostProcess;
  50395. blurSteps: Array<PostProcess>;
  50396. };
  50397. /**
  50398. * Parameters to perform the merge of bloom effect
  50399. */
  50400. bloom?: {
  50401. blurred: PostProcess;
  50402. weight: number;
  50403. };
  50404. }
  50405. /**
  50406. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50407. */
  50408. export class DepthOfFieldMergePostProcess extends PostProcess {
  50409. private blurSteps;
  50410. /**
  50411. * Creates a new instance of DepthOfFieldMergePostProcess
  50412. * @param name The name of the effect.
  50413. * @param originalFromInput Post process which's input will be used for the merge.
  50414. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  50415. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  50416. * @param options The required width/height ratio to downsize to before computing the render pass.
  50417. * @param camera The camera to apply the render pass to.
  50418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50419. * @param engine The engine which the post process will be applied. (default: current engine)
  50420. * @param reusable If the post process can be reused on the same frame. (default: false)
  50421. * @param textureType Type of textures used when performing the post process. (default: 0)
  50422. * @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)
  50423. */
  50424. 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);
  50425. /**
  50426. * Updates the effect with the current post process compile time values and recompiles the shader.
  50427. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  50428. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  50429. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  50430. * @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
  50431. * @param onCompiled Called when the shader has been compiled.
  50432. * @param onError Called if there is an error when compiling a shader.
  50433. */
  50434. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  50435. }
  50436. }
  50437. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  50438. import { Nullable } from "babylonjs/types";
  50439. import { Camera } from "babylonjs/Cameras/camera";
  50440. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50442. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  50443. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  50444. import { Scene } from "babylonjs/scene";
  50445. /**
  50446. * Specifies the level of max blur that should be applied when using the depth of field effect
  50447. */
  50448. export enum DepthOfFieldEffectBlurLevel {
  50449. /**
  50450. * Subtle blur
  50451. */
  50452. Low = 0,
  50453. /**
  50454. * Medium blur
  50455. */
  50456. Medium = 1,
  50457. /**
  50458. * Large blur
  50459. */
  50460. High = 2
  50461. }
  50462. /**
  50463. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  50464. */
  50465. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  50466. private _circleOfConfusion;
  50467. /**
  50468. * @hidden Internal, blurs from high to low
  50469. */
  50470. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  50471. private _depthOfFieldBlurY;
  50472. private _dofMerge;
  50473. /**
  50474. * @hidden Internal post processes in depth of field effect
  50475. */
  50476. _effects: Array<PostProcess>;
  50477. /**
  50478. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  50479. */
  50480. focalLength: number;
  50481. /**
  50482. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  50483. */
  50484. fStop: number;
  50485. /**
  50486. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  50487. */
  50488. focusDistance: number;
  50489. /**
  50490. * 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.
  50491. */
  50492. lensSize: number;
  50493. /**
  50494. * Creates a new instance DepthOfFieldEffect
  50495. * @param scene The scene the effect belongs to.
  50496. * @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.
  50497. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  50498. * @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)
  50499. */
  50500. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  50501. /**
  50502. * 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.
  50503. */
  50504. depthTexture: RenderTargetTexture;
  50505. /**
  50506. * Disposes each of the internal effects for a given camera.
  50507. * @param camera The camera to dispose the effect on.
  50508. */
  50509. disposeEffects(camera: Camera): void;
  50510. /**
  50511. * @hidden Internal
  50512. */
  50513. _updateEffects(): void;
  50514. /**
  50515. * Internal
  50516. * @returns if all the contained post processes are ready.
  50517. * @hidden
  50518. */
  50519. _isReady(): boolean;
  50520. }
  50521. }
  50522. declare module "babylonjs/Shaders/displayPass.fragment" {
  50523. export var displayPassPixelShader: {
  50524. name: string;
  50525. shader: string;
  50526. };
  50527. }
  50528. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  50529. import { Nullable } from "babylonjs/types";
  50530. import { Camera } from "babylonjs/Cameras/camera";
  50531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50532. import { Engine } from "babylonjs/Engines/engine";
  50533. import "Shaders/displayPass.fragment";
  50534. /**
  50535. * DisplayPassPostProcess which produces an output the same as it's input
  50536. */
  50537. export class DisplayPassPostProcess extends PostProcess {
  50538. /**
  50539. * Creates the DisplayPassPostProcess
  50540. * @param name The name of the effect.
  50541. * @param options The required width/height ratio to downsize to before computing the render pass.
  50542. * @param camera The camera to apply the render pass to.
  50543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50544. * @param engine The engine which the post process will be applied. (default: current engine)
  50545. * @param reusable If the post process can be reused on the same frame. (default: false)
  50546. */
  50547. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50548. }
  50549. }
  50550. declare module "babylonjs/Shaders/filter.fragment" {
  50551. export var filterPixelShader: {
  50552. name: string;
  50553. shader: string;
  50554. };
  50555. }
  50556. declare module "babylonjs/PostProcesses/filterPostProcess" {
  50557. import { Nullable } from "babylonjs/types";
  50558. import { Matrix } from "babylonjs/Maths/math";
  50559. import { Camera } from "babylonjs/Cameras/camera";
  50560. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50561. import { Engine } from "babylonjs/Engines/engine";
  50562. import "Shaders/filter.fragment";
  50563. /**
  50564. * Applies a kernel filter to the image
  50565. */
  50566. export class FilterPostProcess extends PostProcess {
  50567. /** The matrix to be applied to the image */
  50568. kernelMatrix: Matrix;
  50569. /**
  50570. *
  50571. * @param name The name of the effect.
  50572. * @param kernelMatrix The matrix to be applied to the image
  50573. * @param options The required width/height ratio to downsize to before computing the render pass.
  50574. * @param camera The camera to apply the render pass to.
  50575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50576. * @param engine The engine which the post process will be applied. (default: current engine)
  50577. * @param reusable If the post process can be reused on the same frame. (default: false)
  50578. */
  50579. constructor(name: string,
  50580. /** The matrix to be applied to the image */
  50581. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50582. }
  50583. }
  50584. declare module "babylonjs/Shaders/grain.fragment" {
  50585. import "Shaders/ShadersInclude/helperFunctions";
  50586. export var grainPixelShader: {
  50587. name: string;
  50588. shader: string;
  50589. };
  50590. }
  50591. declare module "babylonjs/PostProcesses/grainPostProcess" {
  50592. import { Nullable } from "babylonjs/types";
  50593. import { Camera } from "babylonjs/Cameras/camera";
  50594. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50595. import { Engine } from "babylonjs/Engines/engine";
  50596. import "Shaders/grain.fragment";
  50597. /**
  50598. * The GrainPostProcess adds noise to the image at mid luminance levels
  50599. */
  50600. export class GrainPostProcess extends PostProcess {
  50601. /**
  50602. * The intensity of the grain added (default: 30)
  50603. */
  50604. intensity: number;
  50605. /**
  50606. * If the grain should be randomized on every frame
  50607. */
  50608. animated: boolean;
  50609. /**
  50610. * Creates a new instance of @see GrainPostProcess
  50611. * @param name The name of the effect.
  50612. * @param options The required width/height ratio to downsize to before computing the render pass.
  50613. * @param camera The camera to apply the render pass to.
  50614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50615. * @param engine The engine which the post process will be applied. (default: current engine)
  50616. * @param reusable If the post process can be reused on the same frame. (default: false)
  50617. * @param textureType Type of textures used when performing the post process. (default: 0)
  50618. * @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)
  50619. */
  50620. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50621. }
  50622. }
  50623. declare module "babylonjs/Shaders/highlights.fragment" {
  50624. export var highlightsPixelShader: {
  50625. name: string;
  50626. shader: string;
  50627. };
  50628. }
  50629. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  50630. import { Nullable } from "babylonjs/types";
  50631. import { Camera } from "babylonjs/Cameras/camera";
  50632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50633. import { Engine } from "babylonjs/Engines/engine";
  50634. import "Shaders/highlights.fragment";
  50635. /**
  50636. * Extracts highlights from the image
  50637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  50638. */
  50639. export class HighlightsPostProcess extends PostProcess {
  50640. /**
  50641. * Extracts highlights from the image
  50642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  50643. * @param name The name of the effect.
  50644. * @param options The required width/height ratio to downsize to before computing the render pass.
  50645. * @param camera The camera to apply the render pass to.
  50646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50647. * @param engine The engine which the post process will be applied. (default: current engine)
  50648. * @param reusable If the post process can be reused on the same frame. (default: false)
  50649. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  50650. */
  50651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50652. }
  50653. }
  50654. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  50655. import { Nullable } from "babylonjs/types";
  50656. import { Scene } from "babylonjs/scene";
  50657. import { ISceneComponent } from "babylonjs/sceneComponent";
  50658. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  50659. module "babylonjs/scene" {
  50660. interface Scene {
  50661. /** @hidden (Backing field) */
  50662. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  50663. /**
  50664. * Gets or Sets the current geometry buffer associated to the scene.
  50665. */
  50666. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  50667. /**
  50668. * Enables a GeometryBufferRender and associates it with the scene
  50669. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  50670. * @returns the GeometryBufferRenderer
  50671. */
  50672. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  50673. /**
  50674. * Disables the GeometryBufferRender associated with the scene
  50675. */
  50676. disableGeometryBufferRenderer(): void;
  50677. }
  50678. }
  50679. /**
  50680. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  50681. * in several rendering techniques.
  50682. */
  50683. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  50684. /**
  50685. * The component name helpful to identify the component in the list of scene components.
  50686. */
  50687. readonly name: string;
  50688. /**
  50689. * The scene the component belongs to.
  50690. */
  50691. scene: Scene;
  50692. /**
  50693. * Creates a new instance of the component for the given scene
  50694. * @param scene Defines the scene to register the component in
  50695. */
  50696. constructor(scene: Scene);
  50697. /**
  50698. * Registers the component in a given scene
  50699. */
  50700. register(): void;
  50701. /**
  50702. * Rebuilds the elements related to this component in case of
  50703. * context lost for instance.
  50704. */
  50705. rebuild(): void;
  50706. /**
  50707. * Disposes the component and the associated ressources
  50708. */
  50709. dispose(): void;
  50710. private _gatherRenderTargets;
  50711. }
  50712. }
  50713. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  50714. export var mrtFragmentDeclaration: {
  50715. name: string;
  50716. shader: string;
  50717. };
  50718. }
  50719. declare module "babylonjs/Shaders/geometry.fragment" {
  50720. import "Shaders/ShadersInclude/mrtFragmentDeclaration";
  50721. export var geometryPixelShader: {
  50722. name: string;
  50723. shader: string;
  50724. };
  50725. }
  50726. declare module "babylonjs/Shaders/geometry.vertex" {
  50727. import "Shaders/ShadersInclude/bonesDeclaration";
  50728. import "Shaders/ShadersInclude/instancesDeclaration";
  50729. import "Shaders/ShadersInclude/instancesVertex";
  50730. import "Shaders/ShadersInclude/bonesVertex";
  50731. export var geometryVertexShader: {
  50732. name: string;
  50733. shader: string;
  50734. };
  50735. }
  50736. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  50737. import { Matrix } from "babylonjs/Maths/math";
  50738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50739. import { Mesh } from "babylonjs/Meshes/mesh";
  50740. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  50741. import { Effect } from "babylonjs/Materials/effect";
  50742. import { Scene } from "babylonjs/scene";
  50743. import "Shaders/geometry.fragment";
  50744. import "Shaders/geometry.vertex";
  50745. /**
  50746. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  50747. */
  50748. export class GeometryBufferRenderer {
  50749. /**
  50750. * Constant used to retrieve the position texture index in the G-Buffer textures array
  50751. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  50752. */
  50753. static readonly POSITION_TEXTURE_TYPE: number;
  50754. /**
  50755. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  50756. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  50757. */
  50758. static readonly VELOCITY_TEXTURE_TYPE: number;
  50759. /**
  50760. * Dictionary used to store the previous transformation matrices of each rendered mesh
  50761. * in order to compute objects velocities when enableVelocity is set to "true"
  50762. * @hidden
  50763. */
  50764. _previousTransformationMatrices: {
  50765. [index: number]: Matrix;
  50766. };
  50767. private _scene;
  50768. private _multiRenderTarget;
  50769. private _ratio;
  50770. private _enablePosition;
  50771. private _enableVelocity;
  50772. private _positionIndex;
  50773. private _velocityIndex;
  50774. protected _effect: Effect;
  50775. protected _cachedDefines: string;
  50776. /**
  50777. * Set the render list (meshes to be rendered) used in the G buffer.
  50778. */
  50779. renderList: Mesh[];
  50780. /**
  50781. * Gets wether or not G buffer are supported by the running hardware.
  50782. * This requires draw buffer supports
  50783. */
  50784. readonly isSupported: boolean;
  50785. /**
  50786. * Returns the index of the given texture type in the G-Buffer textures array
  50787. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  50788. * @returns the index of the given texture type in the G-Buffer textures array
  50789. */
  50790. getTextureIndex(textureType: number): number;
  50791. /**
  50792. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  50793. */
  50794. /**
  50795. * Sets whether or not objects positions are enabled for the G buffer.
  50796. */
  50797. enablePosition: boolean;
  50798. /**
  50799. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  50800. */
  50801. /**
  50802. * Sets wether or not objects velocities are enabled for the G buffer.
  50803. */
  50804. enableVelocity: boolean;
  50805. /**
  50806. * Gets the scene associated with the buffer.
  50807. */
  50808. readonly scene: Scene;
  50809. /**
  50810. * Gets the ratio used by the buffer during its creation.
  50811. * How big is the buffer related to the main canvas.
  50812. */
  50813. readonly ratio: number;
  50814. /**
  50815. * Creates a new G Buffer for the scene
  50816. * @param scene The scene the buffer belongs to
  50817. * @param ratio How big is the buffer related to the main canvas.
  50818. */
  50819. constructor(scene: Scene, ratio?: number);
  50820. /**
  50821. * Checks wether everything is ready to render a submesh to the G buffer.
  50822. * @param subMesh the submesh to check readiness for
  50823. * @param useInstances is the mesh drawn using instance or not
  50824. * @returns true if ready otherwise false
  50825. */
  50826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50827. /**
  50828. * Gets the current underlying G Buffer.
  50829. * @returns the buffer
  50830. */
  50831. getGBuffer(): MultiRenderTarget;
  50832. /**
  50833. * Gets the number of samples used to render the buffer (anti aliasing).
  50834. */
  50835. /**
  50836. * Sets the number of samples used to render the buffer (anti aliasing).
  50837. */
  50838. samples: number;
  50839. /**
  50840. * Disposes the renderer and frees up associated resources.
  50841. */
  50842. dispose(): void;
  50843. protected _createRenderTargets(): void;
  50844. }
  50845. }
  50846. declare module "babylonjs/Shaders/motionBlur.fragment" {
  50847. export var motionBlurPixelShader: {
  50848. name: string;
  50849. shader: string;
  50850. };
  50851. }
  50852. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  50853. import { Nullable } from "babylonjs/types";
  50854. import { Camera } from "babylonjs/Cameras/camera";
  50855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50856. import { Scene } from "babylonjs/scene";
  50857. import "Shaders/motionBlur.fragment";
  50858. import { Engine } from "babylonjs/Engines/engine";
  50859. /**
  50860. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  50861. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  50862. * As an example, all you have to do is to create the post-process:
  50863. * var mb = new BABYLON.MotionBlurPostProcess(
  50864. * 'mb', // The name of the effect.
  50865. * scene, // The scene containing the objects to blur according to their velocity.
  50866. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  50867. * camera // The camera to apply the render pass to.
  50868. * );
  50869. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  50870. */
  50871. export class MotionBlurPostProcess extends PostProcess {
  50872. /**
  50873. * Defines how much the image is blurred by the movement. Default value is equal to 1
  50874. */
  50875. motionStrength: number;
  50876. /**
  50877. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  50878. */
  50879. /**
  50880. * Sets the number of iterations to be used for motion blur quality
  50881. */
  50882. motionBlurSamples: number;
  50883. private _motionBlurSamples;
  50884. private _geometryBufferRenderer;
  50885. /**
  50886. * Creates a new instance MotionBlurPostProcess
  50887. * @param name The name of the effect.
  50888. * @param scene The scene containing the objects to blur according to their velocity.
  50889. * @param options The required width/height ratio to downsize to before computing the render pass.
  50890. * @param camera The camera to apply the render pass to.
  50891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50892. * @param engine The engine which the post process will be applied. (default: current engine)
  50893. * @param reusable If the post process can be reused on the same frame. (default: false)
  50894. * @param textureType Type of textures used when performing the post process. (default: 0)
  50895. * @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)
  50896. */
  50897. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50898. /**
  50899. * Disposes the post process.
  50900. * @param camera The camera to dispose the post process on.
  50901. */
  50902. dispose(camera?: Camera): void;
  50903. }
  50904. }
  50905. declare module "babylonjs/Shaders/refraction.fragment" {
  50906. export var refractionPixelShader: {
  50907. name: string;
  50908. shader: string;
  50909. };
  50910. }
  50911. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  50912. import { Color3 } from "babylonjs/Maths/math";
  50913. import { Camera } from "babylonjs/Cameras/camera";
  50914. import { Texture } from "babylonjs/Materials/Textures/texture";
  50915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50916. import { Engine } from "babylonjs/Engines/engine";
  50917. import "Shaders/refraction.fragment";
  50918. /**
  50919. * Post process which applies a refractin texture
  50920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50921. */
  50922. export class RefractionPostProcess extends PostProcess {
  50923. /** the base color of the refraction (used to taint the rendering) */
  50924. color: Color3;
  50925. /** simulated refraction depth */
  50926. depth: number;
  50927. /** the coefficient of the base color (0 to remove base color tainting) */
  50928. colorLevel: number;
  50929. private _refTexture;
  50930. private _ownRefractionTexture;
  50931. /**
  50932. * Gets or sets the refraction texture
  50933. * Please note that you are responsible for disposing the texture if you set it manually
  50934. */
  50935. refractionTexture: Texture;
  50936. /**
  50937. * Initializes the RefractionPostProcess
  50938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50939. * @param name The name of the effect.
  50940. * @param refractionTextureUrl Url of the refraction texture to use
  50941. * @param color the base color of the refraction (used to taint the rendering)
  50942. * @param depth simulated refraction depth
  50943. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  50944. * @param camera The camera to apply the render pass to.
  50945. * @param options The required width/height ratio to downsize to before computing the render pass.
  50946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50947. * @param engine The engine which the post process will be applied. (default: current engine)
  50948. * @param reusable If the post process can be reused on the same frame. (default: false)
  50949. */
  50950. constructor(name: string, refractionTextureUrl: string,
  50951. /** the base color of the refraction (used to taint the rendering) */
  50952. color: Color3,
  50953. /** simulated refraction depth */
  50954. depth: number,
  50955. /** the coefficient of the base color (0 to remove base color tainting) */
  50956. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50957. /**
  50958. * Disposes of the post process
  50959. * @param camera Camera to dispose post process on
  50960. */
  50961. dispose(camera: Camera): void;
  50962. }
  50963. }
  50964. declare module "babylonjs/Shaders/sharpen.fragment" {
  50965. export var sharpenPixelShader: {
  50966. name: string;
  50967. shader: string;
  50968. };
  50969. }
  50970. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  50971. import { Nullable } from "babylonjs/types";
  50972. import { Camera } from "babylonjs/Cameras/camera";
  50973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50974. import "Shaders/sharpen.fragment";
  50975. import { Engine } from "babylonjs/Engines/engine";
  50976. /**
  50977. * The SharpenPostProcess applies a sharpen kernel to every pixel
  50978. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50979. */
  50980. export class SharpenPostProcess extends PostProcess {
  50981. /**
  50982. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  50983. */
  50984. colorAmount: number;
  50985. /**
  50986. * How much sharpness should be applied (default: 0.3)
  50987. */
  50988. edgeAmount: number;
  50989. /**
  50990. * Creates a new instance ConvolutionPostProcess
  50991. * @param name The name of the effect.
  50992. * @param options The required width/height ratio to downsize to before computing the render pass.
  50993. * @param camera The camera to apply the render pass to.
  50994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50995. * @param engine The engine which the post process will be applied. (default: current engine)
  50996. * @param reusable If the post process can be reused on the same frame. (default: false)
  50997. * @param textureType Type of textures used when performing the post process. (default: 0)
  50998. * @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)
  50999. */
  51000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51001. }
  51002. }
  51003. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  51004. import { Nullable } from "babylonjs/types";
  51005. import { Camera } from "babylonjs/Cameras/camera";
  51006. import { Engine } from "babylonjs/Engines/engine";
  51007. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51008. /**
  51009. * PostProcessRenderPipeline
  51010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51011. */
  51012. export class PostProcessRenderPipeline {
  51013. private engine;
  51014. private _renderEffects;
  51015. private _renderEffectsForIsolatedPass;
  51016. /**
  51017. * @hidden
  51018. */
  51019. protected _cameras: Camera[];
  51020. /** @hidden */
  51021. _name: string;
  51022. /**
  51023. * Initializes a PostProcessRenderPipeline
  51024. * @param engine engine to add the pipeline to
  51025. * @param name name of the pipeline
  51026. */
  51027. constructor(engine: Engine, name: string);
  51028. /**
  51029. * "PostProcessRenderPipeline"
  51030. * @returns "PostProcessRenderPipeline"
  51031. */
  51032. getClassName(): string;
  51033. /**
  51034. * If all the render effects in the pipeline are support
  51035. */
  51036. readonly isSupported: boolean;
  51037. /**
  51038. * Adds an effect to the pipeline
  51039. * @param renderEffect the effect to add
  51040. */
  51041. addEffect(renderEffect: PostProcessRenderEffect): void;
  51042. /** @hidden */
  51043. _rebuild(): void;
  51044. /** @hidden */
  51045. _enableEffect(renderEffectName: string, cameras: Camera): void;
  51046. /** @hidden */
  51047. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  51048. /** @hidden */
  51049. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51050. /** @hidden */
  51051. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51052. /** @hidden */
  51053. _attachCameras(cameras: Camera, unique: boolean): void;
  51054. /** @hidden */
  51055. _attachCameras(cameras: Camera[], unique: boolean): void;
  51056. /** @hidden */
  51057. _detachCameras(cameras: Camera): void;
  51058. /** @hidden */
  51059. _detachCameras(cameras: Nullable<Camera[]>): void;
  51060. /** @hidden */
  51061. _update(): void;
  51062. /** @hidden */
  51063. _reset(): void;
  51064. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  51065. /**
  51066. * Disposes of the pipeline
  51067. */
  51068. dispose(): void;
  51069. }
  51070. }
  51071. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  51072. import { IAnimatable } from "babylonjs/Misc/tools";
  51073. import { Camera } from "babylonjs/Cameras/camera";
  51074. import { IDisposable } from "babylonjs/scene";
  51075. import { Scene } from "babylonjs/scene";
  51076. import { Animation } from "babylonjs/Animations/animation";
  51077. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  51078. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  51079. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  51080. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  51081. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  51082. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  51083. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  51084. /**
  51085. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  51086. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51087. */
  51088. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51089. private _scene;
  51090. private _camerasToBeAttached;
  51091. /**
  51092. * ID of the sharpen post process,
  51093. */
  51094. private readonly SharpenPostProcessId;
  51095. /**
  51096. * @ignore
  51097. * ID of the image processing post process;
  51098. */
  51099. readonly ImageProcessingPostProcessId: string;
  51100. /**
  51101. * @ignore
  51102. * ID of the Fast Approximate Anti-Aliasing post process;
  51103. */
  51104. readonly FxaaPostProcessId: string;
  51105. /**
  51106. * ID of the chromatic aberration post process,
  51107. */
  51108. private readonly ChromaticAberrationPostProcessId;
  51109. /**
  51110. * ID of the grain post process
  51111. */
  51112. private readonly GrainPostProcessId;
  51113. /**
  51114. * Sharpen post process which will apply a sharpen convolution to enhance edges
  51115. */
  51116. sharpen: SharpenPostProcess;
  51117. private _sharpenEffect;
  51118. private bloom;
  51119. /**
  51120. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  51121. */
  51122. depthOfField: DepthOfFieldEffect;
  51123. /**
  51124. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51125. */
  51126. fxaa: FxaaPostProcess;
  51127. /**
  51128. * Image post processing pass used to perform operations such as tone mapping or color grading.
  51129. */
  51130. imageProcessing: ImageProcessingPostProcess;
  51131. /**
  51132. * Chromatic aberration post process which will shift rgb colors in the image
  51133. */
  51134. chromaticAberration: ChromaticAberrationPostProcess;
  51135. private _chromaticAberrationEffect;
  51136. /**
  51137. * Grain post process which add noise to the image
  51138. */
  51139. grain: GrainPostProcess;
  51140. private _grainEffect;
  51141. /**
  51142. * Glow post process which adds a glow to emmisive areas of the image
  51143. */
  51144. private _glowLayer;
  51145. /**
  51146. * Animations which can be used to tweak settings over a period of time
  51147. */
  51148. animations: Animation[];
  51149. private _imageProcessingConfigurationObserver;
  51150. private _sharpenEnabled;
  51151. private _bloomEnabled;
  51152. private _depthOfFieldEnabled;
  51153. private _depthOfFieldBlurLevel;
  51154. private _fxaaEnabled;
  51155. private _imageProcessingEnabled;
  51156. private _defaultPipelineTextureType;
  51157. private _bloomScale;
  51158. private _chromaticAberrationEnabled;
  51159. private _grainEnabled;
  51160. private _buildAllowed;
  51161. /**
  51162. * Enable or disable the sharpen process from the pipeline
  51163. */
  51164. sharpenEnabled: boolean;
  51165. private _resizeObserver;
  51166. private _hardwareScaleLevel;
  51167. private _bloomKernel;
  51168. /**
  51169. * Specifies the size of the bloom blur kernel, relative to the final output size
  51170. */
  51171. bloomKernel: number;
  51172. /**
  51173. * Specifies the weight of the bloom in the final rendering
  51174. */
  51175. private _bloomWeight;
  51176. /**
  51177. * Specifies the luma threshold for the area that will be blurred by the bloom
  51178. */
  51179. private _bloomThreshold;
  51180. private _hdr;
  51181. /**
  51182. * The strength of the bloom.
  51183. */
  51184. bloomWeight: number;
  51185. /**
  51186. * The strength of the bloom.
  51187. */
  51188. bloomThreshold: number;
  51189. /**
  51190. * The scale of the bloom, lower value will provide better performance.
  51191. */
  51192. bloomScale: number;
  51193. /**
  51194. * Enable or disable the bloom from the pipeline
  51195. */
  51196. bloomEnabled: boolean;
  51197. private _rebuildBloom;
  51198. /**
  51199. * If the depth of field is enabled.
  51200. */
  51201. depthOfFieldEnabled: boolean;
  51202. /**
  51203. * Blur level of the depth of field effect. (Higher blur will effect performance)
  51204. */
  51205. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  51206. /**
  51207. * If the anti aliasing is enabled.
  51208. */
  51209. fxaaEnabled: boolean;
  51210. private _samples;
  51211. /**
  51212. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51213. */
  51214. samples: number;
  51215. /**
  51216. * If image processing is enabled.
  51217. */
  51218. imageProcessingEnabled: boolean;
  51219. /**
  51220. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  51221. */
  51222. glowLayerEnabled: boolean;
  51223. /**
  51224. * Enable or disable the chromaticAberration process from the pipeline
  51225. */
  51226. chromaticAberrationEnabled: boolean;
  51227. /**
  51228. * Enable or disable the grain process from the pipeline
  51229. */
  51230. grainEnabled: boolean;
  51231. /**
  51232. * @constructor
  51233. * @param name - The rendering pipeline name (default: "")
  51234. * @param hdr - If high dynamic range textures should be used (default: true)
  51235. * @param scene - The scene linked to this pipeline (default: the last created scene)
  51236. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  51237. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  51238. */
  51239. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  51240. /**
  51241. * Force the compilation of the entire pipeline.
  51242. */
  51243. prepare(): void;
  51244. private _hasCleared;
  51245. private _prevPostProcess;
  51246. private _prevPrevPostProcess;
  51247. private _setAutoClearAndTextureSharing;
  51248. private _depthOfFieldSceneObserver;
  51249. private _buildPipeline;
  51250. private _disposePostProcesses;
  51251. /**
  51252. * Adds a camera to the pipeline
  51253. * @param camera the camera to be added
  51254. */
  51255. addCamera(camera: Camera): void;
  51256. /**
  51257. * Removes a camera from the pipeline
  51258. * @param camera the camera to remove
  51259. */
  51260. removeCamera(camera: Camera): void;
  51261. /**
  51262. * Dispose of the pipeline and stop all post processes
  51263. */
  51264. dispose(): void;
  51265. /**
  51266. * Serialize the rendering pipeline (Used when exporting)
  51267. * @returns the serialized object
  51268. */
  51269. serialize(): any;
  51270. /**
  51271. * Parse the serialized pipeline
  51272. * @param source Source pipeline.
  51273. * @param scene The scene to load the pipeline to.
  51274. * @param rootUrl The URL of the serialized pipeline.
  51275. * @returns An instantiated pipeline from the serialized object.
  51276. */
  51277. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  51278. }
  51279. }
  51280. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  51281. export var lensHighlightsPixelShader: {
  51282. name: string;
  51283. shader: string;
  51284. };
  51285. }
  51286. declare module "babylonjs/Shaders/depthOfField.fragment" {
  51287. export var depthOfFieldPixelShader: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  51293. import { Camera } from "babylonjs/Cameras/camera";
  51294. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  51295. import { Scene } from "babylonjs/scene";
  51296. import "Shaders/chromaticAberration.fragment";
  51297. import "Shaders/lensHighlights.fragment";
  51298. import "Shaders/depthOfField.fragment";
  51299. /**
  51300. * BABYLON.JS Chromatic Aberration GLSL Shader
  51301. * Author: Olivier Guyot
  51302. * Separates very slightly R, G and B colors on the edges of the screen
  51303. * Inspired by Francois Tarlier & Martins Upitis
  51304. */
  51305. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  51306. /**
  51307. * @ignore
  51308. * The chromatic aberration PostProcess id in the pipeline
  51309. */
  51310. LensChromaticAberrationEffect: string;
  51311. /**
  51312. * @ignore
  51313. * The highlights enhancing PostProcess id in the pipeline
  51314. */
  51315. HighlightsEnhancingEffect: string;
  51316. /**
  51317. * @ignore
  51318. * The depth-of-field PostProcess id in the pipeline
  51319. */
  51320. LensDepthOfFieldEffect: string;
  51321. private _scene;
  51322. private _depthTexture;
  51323. private _grainTexture;
  51324. private _chromaticAberrationPostProcess;
  51325. private _highlightsPostProcess;
  51326. private _depthOfFieldPostProcess;
  51327. private _edgeBlur;
  51328. private _grainAmount;
  51329. private _chromaticAberration;
  51330. private _distortion;
  51331. private _highlightsGain;
  51332. private _highlightsThreshold;
  51333. private _dofDistance;
  51334. private _dofAperture;
  51335. private _dofDarken;
  51336. private _dofPentagon;
  51337. private _blurNoise;
  51338. /**
  51339. * @constructor
  51340. *
  51341. * Effect parameters are as follow:
  51342. * {
  51343. * chromatic_aberration: number; // from 0 to x (1 for realism)
  51344. * edge_blur: number; // from 0 to x (1 for realism)
  51345. * distortion: number; // from 0 to x (1 for realism)
  51346. * grain_amount: number; // from 0 to 1
  51347. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  51348. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  51349. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  51350. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  51351. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  51352. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  51353. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  51354. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  51355. * }
  51356. * Note: if an effect parameter is unset, effect is disabled
  51357. *
  51358. * @param name The rendering pipeline name
  51359. * @param parameters - An object containing all parameters (see above)
  51360. * @param scene The scene linked to this pipeline
  51361. * @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)
  51362. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51363. */
  51364. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  51365. /**
  51366. * Sets the amount of blur at the edges
  51367. * @param amount blur amount
  51368. */
  51369. setEdgeBlur(amount: number): void;
  51370. /**
  51371. * Sets edge blur to 0
  51372. */
  51373. disableEdgeBlur(): void;
  51374. /**
  51375. * Sets the amout of grain
  51376. * @param amount Amount of grain
  51377. */
  51378. setGrainAmount(amount: number): void;
  51379. /**
  51380. * Set grain amount to 0
  51381. */
  51382. disableGrain(): void;
  51383. /**
  51384. * Sets the chromatic aberration amount
  51385. * @param amount amount of chromatic aberration
  51386. */
  51387. setChromaticAberration(amount: number): void;
  51388. /**
  51389. * Sets chromatic aberration amount to 0
  51390. */
  51391. disableChromaticAberration(): void;
  51392. /**
  51393. * Sets the EdgeDistortion amount
  51394. * @param amount amount of EdgeDistortion
  51395. */
  51396. setEdgeDistortion(amount: number): void;
  51397. /**
  51398. * Sets edge distortion to 0
  51399. */
  51400. disableEdgeDistortion(): void;
  51401. /**
  51402. * Sets the FocusDistance amount
  51403. * @param amount amount of FocusDistance
  51404. */
  51405. setFocusDistance(amount: number): void;
  51406. /**
  51407. * Disables depth of field
  51408. */
  51409. disableDepthOfField(): void;
  51410. /**
  51411. * Sets the Aperture amount
  51412. * @param amount amount of Aperture
  51413. */
  51414. setAperture(amount: number): void;
  51415. /**
  51416. * Sets the DarkenOutOfFocus amount
  51417. * @param amount amount of DarkenOutOfFocus
  51418. */
  51419. setDarkenOutOfFocus(amount: number): void;
  51420. /**
  51421. * Creates a pentagon bokeh effect
  51422. */
  51423. enablePentagonBokeh(): void;
  51424. /**
  51425. * Disables the pentagon bokeh effect
  51426. */
  51427. disablePentagonBokeh(): void;
  51428. /**
  51429. * Enables noise blur
  51430. */
  51431. enableNoiseBlur(): void;
  51432. /**
  51433. * Disables noise blur
  51434. */
  51435. disableNoiseBlur(): void;
  51436. /**
  51437. * Sets the HighlightsGain amount
  51438. * @param amount amount of HighlightsGain
  51439. */
  51440. setHighlightsGain(amount: number): void;
  51441. /**
  51442. * Sets the HighlightsThreshold amount
  51443. * @param amount amount of HighlightsThreshold
  51444. */
  51445. setHighlightsThreshold(amount: number): void;
  51446. /**
  51447. * Disables highlights
  51448. */
  51449. disableHighlights(): void;
  51450. /**
  51451. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  51452. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  51453. */
  51454. dispose(disableDepthRender?: boolean): void;
  51455. private _createChromaticAberrationPostProcess;
  51456. private _createHighlightsPostProcess;
  51457. private _createDepthOfFieldPostProcess;
  51458. private _createGrainTexture;
  51459. }
  51460. }
  51461. declare module "babylonjs/Shaders/ssao2.fragment" {
  51462. export var ssao2PixelShader: {
  51463. name: string;
  51464. shader: string;
  51465. };
  51466. }
  51467. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  51468. export var ssaoCombinePixelShader: {
  51469. name: string;
  51470. shader: string;
  51471. };
  51472. }
  51473. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  51474. import { Camera } from "babylonjs/Cameras/camera";
  51475. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  51476. import { Scene } from "babylonjs/scene";
  51477. import "Shaders/ssao2.fragment";
  51478. import "Shaders/ssaoCombine.fragment";
  51479. /**
  51480. * Render pipeline to produce ssao effect
  51481. */
  51482. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  51483. /**
  51484. * @ignore
  51485. * The PassPostProcess id in the pipeline that contains the original scene color
  51486. */
  51487. SSAOOriginalSceneColorEffect: string;
  51488. /**
  51489. * @ignore
  51490. * The SSAO PostProcess id in the pipeline
  51491. */
  51492. SSAORenderEffect: string;
  51493. /**
  51494. * @ignore
  51495. * The horizontal blur PostProcess id in the pipeline
  51496. */
  51497. SSAOBlurHRenderEffect: string;
  51498. /**
  51499. * @ignore
  51500. * The vertical blur PostProcess id in the pipeline
  51501. */
  51502. SSAOBlurVRenderEffect: string;
  51503. /**
  51504. * @ignore
  51505. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  51506. */
  51507. SSAOCombineRenderEffect: string;
  51508. /**
  51509. * The output strength of the SSAO post-process. Default value is 1.0.
  51510. */
  51511. totalStrength: number;
  51512. /**
  51513. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  51514. */
  51515. maxZ: number;
  51516. /**
  51517. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  51518. */
  51519. minZAspect: number;
  51520. private _samples;
  51521. /**
  51522. * Number of samples used for the SSAO calculations. Default value is 8
  51523. */
  51524. samples: number;
  51525. private _textureSamples;
  51526. /**
  51527. * Number of samples to use for antialiasing
  51528. */
  51529. textureSamples: number;
  51530. /**
  51531. * Ratio object used for SSAO ratio and blur ratio
  51532. */
  51533. private _ratio;
  51534. /**
  51535. * Dynamically generated sphere sampler.
  51536. */
  51537. private _sampleSphere;
  51538. /**
  51539. * Blur filter offsets
  51540. */
  51541. private _samplerOffsets;
  51542. private _expensiveBlur;
  51543. /**
  51544. * If bilateral blur should be used
  51545. */
  51546. expensiveBlur: boolean;
  51547. /**
  51548. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  51549. */
  51550. radius: number;
  51551. /**
  51552. * The base color of the SSAO post-process
  51553. * The final result is "base + ssao" between [0, 1]
  51554. */
  51555. base: number;
  51556. /**
  51557. * Support test.
  51558. */
  51559. static readonly IsSupported: boolean;
  51560. private _scene;
  51561. private _depthTexture;
  51562. private _normalTexture;
  51563. private _randomTexture;
  51564. private _originalColorPostProcess;
  51565. private _ssaoPostProcess;
  51566. private _blurHPostProcess;
  51567. private _blurVPostProcess;
  51568. private _ssaoCombinePostProcess;
  51569. private _firstUpdate;
  51570. /**
  51571. * @constructor
  51572. * @param name The rendering pipeline name
  51573. * @param scene The scene linked to this pipeline
  51574. * @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 }
  51575. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51576. */
  51577. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51578. /**
  51579. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51580. */
  51581. dispose(disableGeometryBufferRenderer?: boolean): void;
  51582. private _createBlurPostProcess;
  51583. /** @hidden */
  51584. _rebuild(): void;
  51585. private _bits;
  51586. private _radicalInverse_VdC;
  51587. private _hammersley;
  51588. private _hemisphereSample_uniform;
  51589. private _generateHemisphere;
  51590. private _createSSAOPostProcess;
  51591. private _createSSAOCombinePostProcess;
  51592. private _createRandomTexture;
  51593. /**
  51594. * Serialize the rendering pipeline (Used when exporting)
  51595. * @returns the serialized object
  51596. */
  51597. serialize(): any;
  51598. /**
  51599. * Parse the serialized pipeline
  51600. * @param source Source pipeline.
  51601. * @param scene The scene to load the pipeline to.
  51602. * @param rootUrl The URL of the serialized pipeline.
  51603. * @returns An instantiated pipeline from the serialized object.
  51604. */
  51605. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  51606. }
  51607. }
  51608. declare module "babylonjs/Shaders/ssao.fragment" {
  51609. export var ssaoPixelShader: {
  51610. name: string;
  51611. shader: string;
  51612. };
  51613. }
  51614. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  51615. import { Camera } from "babylonjs/Cameras/camera";
  51616. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  51617. import { Scene } from "babylonjs/scene";
  51618. import "Shaders/ssao.fragment";
  51619. import "Shaders/ssaoCombine.fragment";
  51620. /**
  51621. * Render pipeline to produce ssao effect
  51622. */
  51623. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  51624. /**
  51625. * @ignore
  51626. * The PassPostProcess id in the pipeline that contains the original scene color
  51627. */
  51628. SSAOOriginalSceneColorEffect: string;
  51629. /**
  51630. * @ignore
  51631. * The SSAO PostProcess id in the pipeline
  51632. */
  51633. SSAORenderEffect: string;
  51634. /**
  51635. * @ignore
  51636. * The horizontal blur PostProcess id in the pipeline
  51637. */
  51638. SSAOBlurHRenderEffect: string;
  51639. /**
  51640. * @ignore
  51641. * The vertical blur PostProcess id in the pipeline
  51642. */
  51643. SSAOBlurVRenderEffect: string;
  51644. /**
  51645. * @ignore
  51646. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  51647. */
  51648. SSAOCombineRenderEffect: string;
  51649. /**
  51650. * The output strength of the SSAO post-process. Default value is 1.0.
  51651. */
  51652. totalStrength: number;
  51653. /**
  51654. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  51655. */
  51656. radius: number;
  51657. /**
  51658. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  51659. * Must not be equal to fallOff and superior to fallOff.
  51660. * Default value is 0.975
  51661. */
  51662. area: number;
  51663. /**
  51664. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  51665. * Must not be equal to area and inferior to area.
  51666. * Default value is 0.0
  51667. */
  51668. fallOff: number;
  51669. /**
  51670. * The base color of the SSAO post-process
  51671. * The final result is "base + ssao" between [0, 1]
  51672. */
  51673. base: number;
  51674. private _scene;
  51675. private _depthTexture;
  51676. private _randomTexture;
  51677. private _originalColorPostProcess;
  51678. private _ssaoPostProcess;
  51679. private _blurHPostProcess;
  51680. private _blurVPostProcess;
  51681. private _ssaoCombinePostProcess;
  51682. private _firstUpdate;
  51683. /**
  51684. * @constructor
  51685. * @param name - The rendering pipeline name
  51686. * @param scene - The scene linked to this pipeline
  51687. * @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 }
  51688. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  51689. */
  51690. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51691. /**
  51692. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51693. */
  51694. dispose(disableDepthRender?: boolean): void;
  51695. private _createBlurPostProcess;
  51696. /** @hidden */
  51697. _rebuild(): void;
  51698. private _createSSAOPostProcess;
  51699. private _createSSAOCombinePostProcess;
  51700. private _createRandomTexture;
  51701. }
  51702. }
  51703. declare module "babylonjs/Shaders/standard.fragment" {
  51704. export var standardPixelShader: {
  51705. name: string;
  51706. shader: string;
  51707. };
  51708. }
  51709. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  51710. import { Nullable } from "babylonjs/types";
  51711. import { IAnimatable } from "babylonjs/Misc/tools";
  51712. import { Camera } from "babylonjs/Cameras/camera";
  51713. import { Texture } from "babylonjs/Materials/Textures/texture";
  51714. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51715. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  51716. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51717. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  51718. import { IDisposable } from "babylonjs/scene";
  51719. import { SpotLight } from "babylonjs/Lights/spotLight";
  51720. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  51721. import { Scene } from "babylonjs/scene";
  51722. import { Animation } from "babylonjs/Animations/animation";
  51723. import "Shaders/standard.fragment";
  51724. /**
  51725. * Standard rendering pipeline
  51726. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51727. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51728. */
  51729. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51730. /**
  51731. * Public members
  51732. */
  51733. /**
  51734. * Post-process which contains the original scene color before the pipeline applies all the effects
  51735. */
  51736. originalPostProcess: Nullable<PostProcess>;
  51737. /**
  51738. * Post-process used to down scale an image x4
  51739. */
  51740. downSampleX4PostProcess: Nullable<PostProcess>;
  51741. /**
  51742. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51743. */
  51744. brightPassPostProcess: Nullable<PostProcess>;
  51745. /**
  51746. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51747. */
  51748. blurHPostProcesses: PostProcess[];
  51749. /**
  51750. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51751. */
  51752. blurVPostProcesses: PostProcess[];
  51753. /**
  51754. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51755. */
  51756. textureAdderPostProcess: Nullable<PostProcess>;
  51757. /**
  51758. * Post-process used to create volumetric lighting effect
  51759. */
  51760. volumetricLightPostProcess: Nullable<PostProcess>;
  51761. /**
  51762. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51763. */
  51764. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51765. /**
  51766. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51767. */
  51768. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51769. /**
  51770. * Post-process used to merge the volumetric light effect and the real scene color
  51771. */
  51772. volumetricLightMergePostProces: Nullable<PostProcess>;
  51773. /**
  51774. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51775. */
  51776. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51777. /**
  51778. * Base post-process used to calculate the average luminance of the final image for HDR
  51779. */
  51780. luminancePostProcess: Nullable<PostProcess>;
  51781. /**
  51782. * Post-processes used to create down sample post-processes in order to get
  51783. * the average luminance of the final image for HDR
  51784. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51785. */
  51786. luminanceDownSamplePostProcesses: PostProcess[];
  51787. /**
  51788. * Post-process used to create a HDR effect (light adaptation)
  51789. */
  51790. hdrPostProcess: Nullable<PostProcess>;
  51791. /**
  51792. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51793. */
  51794. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51795. /**
  51796. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51797. */
  51798. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51799. /**
  51800. * Post-process used to merge the final HDR post-process and the real scene color
  51801. */
  51802. hdrFinalPostProcess: Nullable<PostProcess>;
  51803. /**
  51804. * Post-process used to create a lens flare effect
  51805. */
  51806. lensFlarePostProcess: Nullable<PostProcess>;
  51807. /**
  51808. * Post-process that merges the result of the lens flare post-process and the real scene color
  51809. */
  51810. lensFlareComposePostProcess: Nullable<PostProcess>;
  51811. /**
  51812. * Post-process used to create a motion blur effect
  51813. */
  51814. motionBlurPostProcess: Nullable<PostProcess>;
  51815. /**
  51816. * Post-process used to create a depth of field effect
  51817. */
  51818. depthOfFieldPostProcess: Nullable<PostProcess>;
  51819. /**
  51820. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51821. */
  51822. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51823. /**
  51824. * Represents the brightness threshold in order to configure the illuminated surfaces
  51825. */
  51826. brightThreshold: number;
  51827. /**
  51828. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51829. */
  51830. blurWidth: number;
  51831. /**
  51832. * Sets if the blur for highlighted surfaces must be only horizontal
  51833. */
  51834. horizontalBlur: boolean;
  51835. /**
  51836. * Sets the overall exposure used by the pipeline
  51837. */
  51838. exposure: number;
  51839. /**
  51840. * Texture used typically to simulate "dirty" on camera lens
  51841. */
  51842. lensTexture: Nullable<Texture>;
  51843. /**
  51844. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51845. */
  51846. volumetricLightCoefficient: number;
  51847. /**
  51848. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51849. */
  51850. volumetricLightPower: number;
  51851. /**
  51852. * Used the set the blur intensity to smooth the volumetric lights
  51853. */
  51854. volumetricLightBlurScale: number;
  51855. /**
  51856. * Light (spot or directional) used to generate the volumetric lights rays
  51857. * The source light must have a shadow generate so the pipeline can get its
  51858. * depth map
  51859. */
  51860. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51861. /**
  51862. * For eye adaptation, represents the minimum luminance the eye can see
  51863. */
  51864. hdrMinimumLuminance: number;
  51865. /**
  51866. * For eye adaptation, represents the decrease luminance speed
  51867. */
  51868. hdrDecreaseRate: number;
  51869. /**
  51870. * For eye adaptation, represents the increase luminance speed
  51871. */
  51872. hdrIncreaseRate: number;
  51873. /**
  51874. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51875. */
  51876. lensColorTexture: Nullable<Texture>;
  51877. /**
  51878. * The overall strengh for the lens flare effect
  51879. */
  51880. lensFlareStrength: number;
  51881. /**
  51882. * Dispersion coefficient for lens flare ghosts
  51883. */
  51884. lensFlareGhostDispersal: number;
  51885. /**
  51886. * Main lens flare halo width
  51887. */
  51888. lensFlareHaloWidth: number;
  51889. /**
  51890. * Based on the lens distortion effect, defines how much the lens flare result
  51891. * is distorted
  51892. */
  51893. lensFlareDistortionStrength: number;
  51894. /**
  51895. * Lens star texture must be used to simulate rays on the flares and is available
  51896. * in the documentation
  51897. */
  51898. lensStarTexture: Nullable<Texture>;
  51899. /**
  51900. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51901. * flare effect by taking account of the dirt texture
  51902. */
  51903. lensFlareDirtTexture: Nullable<Texture>;
  51904. /**
  51905. * Represents the focal length for the depth of field effect
  51906. */
  51907. depthOfFieldDistance: number;
  51908. /**
  51909. * Represents the blur intensity for the blurred part of the depth of field effect
  51910. */
  51911. depthOfFieldBlurWidth: number;
  51912. /**
  51913. * For motion blur, defines how much the image is blurred by the movement
  51914. */
  51915. motionStrength: number;
  51916. /**
  51917. * List of animations for the pipeline (IAnimatable implementation)
  51918. */
  51919. animations: Animation[];
  51920. /**
  51921. * Private members
  51922. */
  51923. private _scene;
  51924. private _currentDepthOfFieldSource;
  51925. private _basePostProcess;
  51926. private _hdrCurrentLuminance;
  51927. private _floatTextureType;
  51928. private _ratio;
  51929. private _bloomEnabled;
  51930. private _depthOfFieldEnabled;
  51931. private _vlsEnabled;
  51932. private _lensFlareEnabled;
  51933. private _hdrEnabled;
  51934. private _motionBlurEnabled;
  51935. private _fxaaEnabled;
  51936. private _motionBlurSamples;
  51937. private _volumetricLightStepsCount;
  51938. private _samples;
  51939. /**
  51940. * @ignore
  51941. * Specifies if the bloom pipeline is enabled
  51942. */
  51943. BloomEnabled: boolean;
  51944. /**
  51945. * @ignore
  51946. * Specifies if the depth of field pipeline is enabed
  51947. */
  51948. DepthOfFieldEnabled: boolean;
  51949. /**
  51950. * @ignore
  51951. * Specifies if the lens flare pipeline is enabed
  51952. */
  51953. LensFlareEnabled: boolean;
  51954. /**
  51955. * @ignore
  51956. * Specifies if the HDR pipeline is enabled
  51957. */
  51958. HDREnabled: boolean;
  51959. /**
  51960. * @ignore
  51961. * Specifies if the volumetric lights scattering effect is enabled
  51962. */
  51963. VLSEnabled: boolean;
  51964. /**
  51965. * @ignore
  51966. * Specifies if the motion blur effect is enabled
  51967. */
  51968. MotionBlurEnabled: boolean;
  51969. /**
  51970. * Specifies if anti-aliasing is enabled
  51971. */
  51972. fxaaEnabled: boolean;
  51973. /**
  51974. * Specifies the number of steps used to calculate the volumetric lights
  51975. * Typically in interval [50, 200]
  51976. */
  51977. volumetricLightStepsCount: number;
  51978. /**
  51979. * Specifies the number of samples used for the motion blur effect
  51980. * Typically in interval [16, 64]
  51981. */
  51982. motionBlurSamples: number;
  51983. /**
  51984. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51985. */
  51986. samples: number;
  51987. /**
  51988. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51989. * @constructor
  51990. * @param name The rendering pipeline name
  51991. * @param scene The scene linked to this pipeline
  51992. * @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)
  51993. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51994. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51995. */
  51996. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51997. private _buildPipeline;
  51998. private _createDownSampleX4PostProcess;
  51999. private _createBrightPassPostProcess;
  52000. private _createBlurPostProcesses;
  52001. private _createTextureAdderPostProcess;
  52002. private _createVolumetricLightPostProcess;
  52003. private _createLuminancePostProcesses;
  52004. private _createHdrPostProcess;
  52005. private _createLensFlarePostProcess;
  52006. private _createDepthOfFieldPostProcess;
  52007. private _createMotionBlurPostProcess;
  52008. private _getDepthTexture;
  52009. private _disposePostProcesses;
  52010. /**
  52011. * Dispose of the pipeline and stop all post processes
  52012. */
  52013. dispose(): void;
  52014. /**
  52015. * Serialize the rendering pipeline (Used when exporting)
  52016. * @returns the serialized object
  52017. */
  52018. serialize(): any;
  52019. /**
  52020. * Parse the serialized pipeline
  52021. * @param source Source pipeline.
  52022. * @param scene The scene to load the pipeline to.
  52023. * @param rootUrl The URL of the serialized pipeline.
  52024. * @returns An instantiated pipeline from the serialized object.
  52025. */
  52026. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  52027. /**
  52028. * Luminance steps
  52029. */
  52030. static LuminanceSteps: number;
  52031. }
  52032. }
  52033. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  52034. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  52035. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  52036. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  52037. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  52038. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  52039. }
  52040. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  52041. import { Camera } from "babylonjs/Cameras/camera";
  52042. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52043. /**
  52044. * PostProcessRenderPipelineManager class
  52045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52046. */
  52047. export class PostProcessRenderPipelineManager {
  52048. private _renderPipelines;
  52049. /**
  52050. * Initializes a PostProcessRenderPipelineManager
  52051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52052. */
  52053. constructor();
  52054. /**
  52055. * Adds a pipeline to the manager
  52056. * @param renderPipeline The pipeline to add
  52057. */
  52058. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52059. /**
  52060. * Attaches a camera to the pipeline
  52061. * @param renderPipelineName The name of the pipeline to attach to
  52062. * @param cameras the camera to attach
  52063. * @param unique if the camera can be attached multiple times to the pipeline
  52064. */
  52065. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52066. /**
  52067. * Detaches a camera from the pipeline
  52068. * @param renderPipelineName The name of the pipeline to detach from
  52069. * @param cameras the camera to detach
  52070. */
  52071. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52072. /**
  52073. * Enables an effect by name on a pipeline
  52074. * @param renderPipelineName the name of the pipeline to enable the effect in
  52075. * @param renderEffectName the name of the effect to enable
  52076. * @param cameras the cameras that the effect should be enabled on
  52077. */
  52078. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52079. /**
  52080. * Disables an effect by name on a pipeline
  52081. * @param renderPipelineName the name of the pipeline to disable the effect in
  52082. * @param renderEffectName the name of the effect to disable
  52083. * @param cameras the cameras that the effect should be disabled on
  52084. */
  52085. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52086. /**
  52087. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52088. */
  52089. update(): void;
  52090. /** @hidden */
  52091. _rebuild(): void;
  52092. /**
  52093. * Disposes of the manager and pipelines
  52094. */
  52095. dispose(): void;
  52096. }
  52097. }
  52098. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  52099. import { ISceneComponent } from "babylonjs/sceneComponent";
  52100. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  52101. import { Scene } from "babylonjs/scene";
  52102. module "babylonjs/scene" {
  52103. interface Scene {
  52104. /** @hidden (Backing field) */
  52105. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52106. /**
  52107. * Gets the postprocess render pipeline manager
  52108. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52109. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52110. */
  52111. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52112. }
  52113. }
  52114. /**
  52115. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52116. */
  52117. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52118. /**
  52119. * The component name helpfull to identify the component in the list of scene components.
  52120. */
  52121. readonly name: string;
  52122. /**
  52123. * The scene the component belongs to.
  52124. */
  52125. scene: Scene;
  52126. /**
  52127. * Creates a new instance of the component for the given scene
  52128. * @param scene Defines the scene to register the component in
  52129. */
  52130. constructor(scene: Scene);
  52131. /**
  52132. * Registers the component in a given scene
  52133. */
  52134. register(): void;
  52135. /**
  52136. * Rebuilds the elements related to this component in case of
  52137. * context lost for instance.
  52138. */
  52139. rebuild(): void;
  52140. /**
  52141. * Disposes the component and the associated ressources
  52142. */
  52143. dispose(): void;
  52144. private _gatherRenderTargets;
  52145. }
  52146. }
  52147. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  52148. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  52149. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52150. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52151. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  52152. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  52153. }
  52154. declare module "babylonjs/Shaders/tonemap.fragment" {
  52155. export var tonemapPixelShader: {
  52156. name: string;
  52157. shader: string;
  52158. };
  52159. }
  52160. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  52161. import { Camera } from "babylonjs/Cameras/camera";
  52162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52163. import "Shaders/tonemap.fragment";
  52164. import { Engine } from "babylonjs/Engines/engine";
  52165. /** Defines operator used for tonemapping */
  52166. export enum TonemappingOperator {
  52167. /** Hable */
  52168. Hable = 0,
  52169. /** Reinhard */
  52170. Reinhard = 1,
  52171. /** HejiDawson */
  52172. HejiDawson = 2,
  52173. /** Photographic */
  52174. Photographic = 3
  52175. }
  52176. /**
  52177. * Defines a post process to apply tone mapping
  52178. */
  52179. export class TonemapPostProcess extends PostProcess {
  52180. private _operator;
  52181. /** Defines the required exposure adjustement */
  52182. exposureAdjustment: number;
  52183. /**
  52184. * Creates a new TonemapPostProcess
  52185. * @param name defines the name of the postprocess
  52186. * @param _operator defines the operator to use
  52187. * @param exposureAdjustment defines the required exposure adjustement
  52188. * @param camera defines the camera to use (can be null)
  52189. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  52190. * @param engine defines the hosting engine (can be ignore if camera is set)
  52191. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52192. */
  52193. constructor(name: string, _operator: TonemappingOperator,
  52194. /** Defines the required exposure adjustement */
  52195. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  52196. }
  52197. }
  52198. declare module "babylonjs/Shaders/depth.vertex" {
  52199. import "Shaders/ShadersInclude/bonesDeclaration";
  52200. import "Shaders/ShadersInclude/instancesDeclaration";
  52201. import "Shaders/ShadersInclude/instancesVertex";
  52202. import "Shaders/ShadersInclude/bonesVertex";
  52203. export var depthVertexShader: {
  52204. name: string;
  52205. shader: string;
  52206. };
  52207. }
  52208. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  52209. export var volumetricLightScatteringPixelShader: {
  52210. name: string;
  52211. shader: string;
  52212. };
  52213. }
  52214. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  52215. export var volumetricLightScatteringPassPixelShader: {
  52216. name: string;
  52217. shader: string;
  52218. };
  52219. }
  52220. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  52221. import { Vector3 } from "babylonjs/Maths/math";
  52222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52223. import { Mesh } from "babylonjs/Meshes/mesh";
  52224. import { Camera } from "babylonjs/Cameras/camera";
  52225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52226. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52227. import { Scene } from "babylonjs/scene";
  52228. import "Shaders/depth.vertex";
  52229. import "Shaders/volumetricLightScattering.fragment";
  52230. import "Shaders/volumetricLightScatteringPass.fragment";
  52231. import { Engine } from "babylonjs/Engines/engine";
  52232. /**
  52233. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  52234. */
  52235. export class VolumetricLightScatteringPostProcess extends PostProcess {
  52236. private _volumetricLightScatteringPass;
  52237. private _volumetricLightScatteringRTT;
  52238. private _viewPort;
  52239. private _screenCoordinates;
  52240. private _cachedDefines;
  52241. /**
  52242. * If not undefined, the mesh position is computed from the attached node position
  52243. */
  52244. attachedNode: {
  52245. position: Vector3;
  52246. };
  52247. /**
  52248. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  52249. */
  52250. customMeshPosition: Vector3;
  52251. /**
  52252. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  52253. */
  52254. useCustomMeshPosition: boolean;
  52255. /**
  52256. * If the post-process should inverse the light scattering direction
  52257. */
  52258. invert: boolean;
  52259. /**
  52260. * The internal mesh used by the post-process
  52261. */
  52262. mesh: Mesh;
  52263. /**
  52264. * @hidden
  52265. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  52266. */
  52267. useDiffuseColor: boolean;
  52268. /**
  52269. * Array containing the excluded meshes not rendered in the internal pass
  52270. */
  52271. excludedMeshes: AbstractMesh[];
  52272. /**
  52273. * Controls the overall intensity of the post-process
  52274. */
  52275. exposure: number;
  52276. /**
  52277. * Dissipates each sample's contribution in range [0, 1]
  52278. */
  52279. decay: number;
  52280. /**
  52281. * Controls the overall intensity of each sample
  52282. */
  52283. weight: number;
  52284. /**
  52285. * Controls the density of each sample
  52286. */
  52287. density: number;
  52288. /**
  52289. * @constructor
  52290. * @param name The post-process name
  52291. * @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)
  52292. * @param camera The camera that the post-process will be attached to
  52293. * @param mesh The mesh used to create the light scattering
  52294. * @param samples The post-process quality, default 100
  52295. * @param samplingModeThe post-process filtering mode
  52296. * @param engine The babylon engine
  52297. * @param reusable If the post-process is reusable
  52298. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  52299. */
  52300. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  52301. /**
  52302. * Returns the string "VolumetricLightScatteringPostProcess"
  52303. * @returns "VolumetricLightScatteringPostProcess"
  52304. */
  52305. getClassName(): string;
  52306. private _isReady;
  52307. /**
  52308. * Sets the new light position for light scattering effect
  52309. * @param position The new custom light position
  52310. */
  52311. setCustomMeshPosition(position: Vector3): void;
  52312. /**
  52313. * Returns the light position for light scattering effect
  52314. * @return Vector3 The custom light position
  52315. */
  52316. getCustomMeshPosition(): Vector3;
  52317. /**
  52318. * Disposes the internal assets and detaches the post-process from the camera
  52319. */
  52320. dispose(camera: Camera): void;
  52321. /**
  52322. * Returns the render target texture used by the post-process
  52323. * @return the render target texture used by the post-process
  52324. */
  52325. getPass(): RenderTargetTexture;
  52326. private _meshExcluded;
  52327. private _createPass;
  52328. private _updateMeshScreenCoordinates;
  52329. /**
  52330. * Creates a default mesh for the Volumeric Light Scattering post-process
  52331. * @param name The mesh name
  52332. * @param scene The scene where to create the mesh
  52333. * @return the default mesh
  52334. */
  52335. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  52336. }
  52337. }
  52338. declare module "babylonjs/PostProcesses/index" {
  52339. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  52340. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  52341. export * from "babylonjs/PostProcesses/bloomEffect";
  52342. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  52343. export * from "babylonjs/PostProcesses/blurPostProcess";
  52344. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52345. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  52346. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  52347. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  52348. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52349. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  52350. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  52351. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  52352. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52353. export * from "babylonjs/PostProcesses/filterPostProcess";
  52354. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  52355. export * from "babylonjs/PostProcesses/grainPostProcess";
  52356. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  52357. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52358. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  52359. export * from "babylonjs/PostProcesses/passPostProcess";
  52360. export * from "babylonjs/PostProcesses/postProcess";
  52361. export * from "babylonjs/PostProcesses/postProcessManager";
  52362. export * from "babylonjs/PostProcesses/refractionPostProcess";
  52363. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  52364. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  52365. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  52366. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  52367. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  52368. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  52369. }
  52370. declare module "babylonjs/Probes/index" {
  52371. export * from "babylonjs/Probes/reflectionProbe";
  52372. }
  52373. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  52374. import { Scene } from "babylonjs/scene";
  52375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52376. import { Color3 } from "babylonjs/Maths/math";
  52377. import { SmartArray } from "babylonjs/Misc/smartArray";
  52378. import { ISceneComponent } from "babylonjs/sceneComponent";
  52379. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  52380. import "Shaders/color.fragment";
  52381. import "Shaders/color.vertex";
  52382. module "babylonjs/scene" {
  52383. interface Scene {
  52384. /** @hidden (Backing field) */
  52385. _boundingBoxRenderer: BoundingBoxRenderer;
  52386. /** @hidden (Backing field) */
  52387. _forceShowBoundingBoxes: boolean;
  52388. /**
  52389. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  52390. */
  52391. forceShowBoundingBoxes: boolean;
  52392. /**
  52393. * Gets the bounding box renderer associated with the scene
  52394. * @returns a BoundingBoxRenderer
  52395. */
  52396. getBoundingBoxRenderer(): BoundingBoxRenderer;
  52397. }
  52398. }
  52399. module "babylonjs/Meshes/abstractMesh" {
  52400. interface AbstractMesh {
  52401. /** @hidden (Backing field) */
  52402. _showBoundingBox: boolean;
  52403. /**
  52404. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  52405. */
  52406. showBoundingBox: boolean;
  52407. }
  52408. }
  52409. /**
  52410. * Component responsible of rendering the bounding box of the meshes in a scene.
  52411. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  52412. */
  52413. export class BoundingBoxRenderer implements ISceneComponent {
  52414. /**
  52415. * The component name helpfull to identify the component in the list of scene components.
  52416. */
  52417. readonly name: string;
  52418. /**
  52419. * The scene the component belongs to.
  52420. */
  52421. scene: Scene;
  52422. /**
  52423. * Color of the bounding box lines placed in front of an object
  52424. */
  52425. frontColor: Color3;
  52426. /**
  52427. * Color of the bounding box lines placed behind an object
  52428. */
  52429. backColor: Color3;
  52430. /**
  52431. * Defines if the renderer should show the back lines or not
  52432. */
  52433. showBackLines: boolean;
  52434. /**
  52435. * @hidden
  52436. */
  52437. renderList: SmartArray<BoundingBox>;
  52438. private _colorShader;
  52439. private _vertexBuffers;
  52440. private _indexBuffer;
  52441. /**
  52442. * Instantiates a new bounding box renderer in a scene.
  52443. * @param scene the scene the renderer renders in
  52444. */
  52445. constructor(scene: Scene);
  52446. /**
  52447. * Registers the component in a given scene
  52448. */
  52449. register(): void;
  52450. private _evaluateSubMesh;
  52451. private _activeMesh;
  52452. private _prepareRessources;
  52453. private _createIndexBuffer;
  52454. /**
  52455. * Rebuilds the elements related to this component in case of
  52456. * context lost for instance.
  52457. */
  52458. rebuild(): void;
  52459. /**
  52460. * @hidden
  52461. */
  52462. reset(): void;
  52463. /**
  52464. * Render the bounding boxes of a specific rendering group
  52465. * @param renderingGroupId defines the rendering group to render
  52466. */
  52467. render(renderingGroupId: number): void;
  52468. /**
  52469. * In case of occlusion queries, we can render the occlusion bounding box through this method
  52470. * @param mesh Define the mesh to render the occlusion bounding box for
  52471. */
  52472. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  52473. /**
  52474. * Dispose and release the resources attached to this renderer.
  52475. */
  52476. dispose(): void;
  52477. }
  52478. }
  52479. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  52480. import { Nullable } from "babylonjs/types";
  52481. import { Scene } from "babylonjs/scene";
  52482. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  52483. import { Camera } from "babylonjs/Cameras/camera";
  52484. import { ISceneComponent } from "babylonjs/sceneComponent";
  52485. module "babylonjs/scene" {
  52486. interface Scene {
  52487. /** @hidden (Backing field) */
  52488. _depthRenderer: {
  52489. [id: string]: DepthRenderer;
  52490. };
  52491. /**
  52492. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  52493. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  52494. * @returns the created depth renderer
  52495. */
  52496. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  52497. /**
  52498. * Disables a depth renderer for a given camera
  52499. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  52500. */
  52501. disableDepthRenderer(camera?: Nullable<Camera>): void;
  52502. }
  52503. }
  52504. /**
  52505. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  52506. * in several rendering techniques.
  52507. */
  52508. export class DepthRendererSceneComponent implements ISceneComponent {
  52509. /**
  52510. * The component name helpfull to identify the component in the list of scene components.
  52511. */
  52512. readonly name: string;
  52513. /**
  52514. * The scene the component belongs to.
  52515. */
  52516. scene: Scene;
  52517. /**
  52518. * Creates a new instance of the component for the given scene
  52519. * @param scene Defines the scene to register the component in
  52520. */
  52521. constructor(scene: Scene);
  52522. /**
  52523. * Registers the component in a given scene
  52524. */
  52525. register(): void;
  52526. /**
  52527. * Rebuilds the elements related to this component in case of
  52528. * context lost for instance.
  52529. */
  52530. rebuild(): void;
  52531. /**
  52532. * Disposes the component and the associated ressources
  52533. */
  52534. dispose(): void;
  52535. private _gatherRenderTargets;
  52536. private _gatherActiveCameraRenderTargets;
  52537. }
  52538. }
  52539. declare module "babylonjs/Shaders/depth.fragment" {
  52540. export var depthPixelShader: {
  52541. name: string;
  52542. shader: string;
  52543. };
  52544. }
  52545. declare module "babylonjs/Rendering/depthRenderer" {
  52546. import { Nullable } from "babylonjs/types";
  52547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52548. import { Scene } from "babylonjs/scene";
  52549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52550. import { Camera } from "babylonjs/Cameras/camera";
  52551. import "Shaders/depth.fragment";
  52552. import "Shaders/depth.vertex";
  52553. /**
  52554. * This represents a depth renderer in Babylon.
  52555. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  52556. */
  52557. export class DepthRenderer {
  52558. private _scene;
  52559. private _depthMap;
  52560. private _effect;
  52561. private _cachedDefines;
  52562. private _camera;
  52563. /**
  52564. * Specifiess that the depth renderer will only be used within
  52565. * the camera it is created for.
  52566. * This can help forcing its rendering during the camera processing.
  52567. */
  52568. useOnlyInActiveCamera: boolean;
  52569. /**
  52570. * Instantiates a depth renderer
  52571. * @param scene The scene the renderer belongs to
  52572. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  52573. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  52574. */
  52575. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  52576. /**
  52577. * Creates the depth rendering effect and checks if the effect is ready.
  52578. * @param subMesh The submesh to be used to render the depth map of
  52579. * @param useInstances If multiple world instances should be used
  52580. * @returns if the depth renderer is ready to render the depth map
  52581. */
  52582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52583. /**
  52584. * Gets the texture which the depth map will be written to.
  52585. * @returns The depth map texture
  52586. */
  52587. getDepthMap(): RenderTargetTexture;
  52588. /**
  52589. * Disposes of the depth renderer.
  52590. */
  52591. dispose(): void;
  52592. }
  52593. }
  52594. declare module "babylonjs/Shaders/outline.fragment" {
  52595. import "Shaders/ShadersInclude/logDepthDeclaration";
  52596. import "Shaders/ShadersInclude/logDepthFragment";
  52597. export var outlinePixelShader: {
  52598. name: string;
  52599. shader: string;
  52600. };
  52601. }
  52602. declare module "babylonjs/Shaders/outline.vertex" {
  52603. import "Shaders/ShadersInclude/bonesDeclaration";
  52604. import "Shaders/ShadersInclude/instancesDeclaration";
  52605. import "Shaders/ShadersInclude/logDepthDeclaration";
  52606. import "Shaders/ShadersInclude/instancesVertex";
  52607. import "Shaders/ShadersInclude/bonesVertex";
  52608. import "Shaders/ShadersInclude/logDepthVertex";
  52609. export var outlineVertexShader: {
  52610. name: string;
  52611. shader: string;
  52612. };
  52613. }
  52614. declare module "babylonjs/Rendering/outlineRenderer" {
  52615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52616. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  52617. import { Scene } from "babylonjs/scene";
  52618. import { ISceneComponent } from "babylonjs/sceneComponent";
  52619. import "Shaders/outline.fragment";
  52620. import "Shaders/outline.vertex";
  52621. module "babylonjs/scene" {
  52622. interface Scene {
  52623. /** @hidden */
  52624. _outlineRenderer: OutlineRenderer;
  52625. /**
  52626. * Gets the outline renderer associated with the scene
  52627. * @returns a OutlineRenderer
  52628. */
  52629. getOutlineRenderer(): OutlineRenderer;
  52630. }
  52631. }
  52632. module "babylonjs/Meshes/abstractMesh" {
  52633. interface AbstractMesh {
  52634. /** @hidden (Backing field) */
  52635. _renderOutline: boolean;
  52636. /**
  52637. * Gets or sets a boolean indicating if the outline must be rendered as well
  52638. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  52639. */
  52640. renderOutline: boolean;
  52641. /** @hidden (Backing field) */
  52642. _renderOverlay: boolean;
  52643. /**
  52644. * Gets or sets a boolean indicating if the overlay must be rendered as well
  52645. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  52646. */
  52647. renderOverlay: boolean;
  52648. }
  52649. }
  52650. /**
  52651. * This class is responsible to draw bothe outline/overlay of meshes.
  52652. * It should not be used directly but through the available method on mesh.
  52653. */
  52654. export class OutlineRenderer implements ISceneComponent {
  52655. /**
  52656. * The name of the component. Each component must have a unique name.
  52657. */
  52658. name: string;
  52659. /**
  52660. * The scene the component belongs to.
  52661. */
  52662. scene: Scene;
  52663. /**
  52664. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  52665. */
  52666. zOffset: number;
  52667. private _engine;
  52668. private _effect;
  52669. private _cachedDefines;
  52670. private _savedDepthWrite;
  52671. /**
  52672. * Instantiates a new outline renderer. (There could be only one per scene).
  52673. * @param scene Defines the scene it belongs to
  52674. */
  52675. constructor(scene: Scene);
  52676. /**
  52677. * Register the component to one instance of a scene.
  52678. */
  52679. register(): void;
  52680. /**
  52681. * Rebuilds the elements related to this component in case of
  52682. * context lost for instance.
  52683. */
  52684. rebuild(): void;
  52685. /**
  52686. * Disposes the component and the associated ressources.
  52687. */
  52688. dispose(): void;
  52689. /**
  52690. * Renders the outline in the canvas.
  52691. * @param subMesh Defines the sumesh to render
  52692. * @param batch Defines the batch of meshes in case of instances
  52693. * @param useOverlay Defines if the rendering is for the overlay or the outline
  52694. */
  52695. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  52696. /**
  52697. * Returns whether or not the outline renderer is ready for a given submesh.
  52698. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  52699. * @param subMesh Defines the submesh to check readyness for
  52700. * @param useInstances Defines wheter wee are trying to render instances or not
  52701. * @returns true if ready otherwise false
  52702. */
  52703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52704. private _beforeRenderingMesh;
  52705. private _afterRenderingMesh;
  52706. }
  52707. }
  52708. declare module "babylonjs/Rendering/index" {
  52709. export * from "babylonjs/Rendering/boundingBoxRenderer";
  52710. export * from "babylonjs/Rendering/depthRenderer";
  52711. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  52712. export * from "babylonjs/Rendering/edgesRenderer";
  52713. export * from "babylonjs/Rendering/geometryBufferRenderer";
  52714. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  52715. export * from "babylonjs/Rendering/outlineRenderer";
  52716. export * from "babylonjs/Rendering/renderingGroup";
  52717. export * from "babylonjs/Rendering/renderingManager";
  52718. export * from "babylonjs/Rendering/utilityLayerRenderer";
  52719. }
  52720. declare module "babylonjs/Sprites/index" {
  52721. export * from "babylonjs/Sprites/sprite";
  52722. export * from "babylonjs/Sprites/spriteManager";
  52723. export * from "babylonjs/Sprites/spriteSceneComponent";
  52724. }
  52725. declare module "babylonjs/Misc/assetsManager" {
  52726. import { Scene } from "babylonjs/scene";
  52727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52728. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52729. import { Skeleton } from "babylonjs/Bones/skeleton";
  52730. import { Observable } from "babylonjs/Misc/observable";
  52731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52732. import { Texture } from "babylonjs/Materials/Textures/texture";
  52733. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52734. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  52735. /**
  52736. * Defines the list of states available for a task inside a AssetsManager
  52737. */
  52738. export enum AssetTaskState {
  52739. /**
  52740. * Initialization
  52741. */
  52742. INIT = 0,
  52743. /**
  52744. * Running
  52745. */
  52746. RUNNING = 1,
  52747. /**
  52748. * Done
  52749. */
  52750. DONE = 2,
  52751. /**
  52752. * Error
  52753. */
  52754. ERROR = 3
  52755. }
  52756. /**
  52757. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  52758. */
  52759. export abstract class AbstractAssetTask {
  52760. /**
  52761. * Task name
  52762. */ name: string;
  52763. /**
  52764. * Callback called when the task is successful
  52765. */
  52766. onSuccess: (task: any) => void;
  52767. /**
  52768. * Callback called when the task is not successful
  52769. */
  52770. onError: (task: any, message?: string, exception?: any) => void;
  52771. /**
  52772. * Creates a new AssetsManager
  52773. * @param name defines the name of the task
  52774. */
  52775. constructor(
  52776. /**
  52777. * Task name
  52778. */ name: string);
  52779. private _isCompleted;
  52780. private _taskState;
  52781. private _errorObject;
  52782. /**
  52783. * Get if the task is completed
  52784. */
  52785. readonly isCompleted: boolean;
  52786. /**
  52787. * Gets the current state of the task
  52788. */
  52789. readonly taskState: AssetTaskState;
  52790. /**
  52791. * Gets the current error object (if task is in error)
  52792. */
  52793. readonly errorObject: {
  52794. message?: string;
  52795. exception?: any;
  52796. };
  52797. /**
  52798. * Internal only
  52799. * @hidden
  52800. */
  52801. _setErrorObject(message?: string, exception?: any): void;
  52802. /**
  52803. * Execute the current task
  52804. * @param scene defines the scene where you want your assets to be loaded
  52805. * @param onSuccess is a callback called when the task is successfully executed
  52806. * @param onError is a callback called if an error occurs
  52807. */
  52808. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52809. /**
  52810. * Execute the current task
  52811. * @param scene defines the scene where you want your assets to be loaded
  52812. * @param onSuccess is a callback called when the task is successfully executed
  52813. * @param onError is a callback called if an error occurs
  52814. */
  52815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52816. /**
  52817. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  52818. * This can be used with failed tasks that have the reason for failure fixed.
  52819. */
  52820. reset(): void;
  52821. private onErrorCallback;
  52822. private onDoneCallback;
  52823. }
  52824. /**
  52825. * Define the interface used by progress events raised during assets loading
  52826. */
  52827. export interface IAssetsProgressEvent {
  52828. /**
  52829. * Defines the number of remaining tasks to process
  52830. */
  52831. remainingCount: number;
  52832. /**
  52833. * Defines the total number of tasks
  52834. */
  52835. totalCount: number;
  52836. /**
  52837. * Defines the task that was just processed
  52838. */
  52839. task: AbstractAssetTask;
  52840. }
  52841. /**
  52842. * Class used to share progress information about assets loading
  52843. */
  52844. export class AssetsProgressEvent implements IAssetsProgressEvent {
  52845. /**
  52846. * Defines the number of remaining tasks to process
  52847. */
  52848. remainingCount: number;
  52849. /**
  52850. * Defines the total number of tasks
  52851. */
  52852. totalCount: number;
  52853. /**
  52854. * Defines the task that was just processed
  52855. */
  52856. task: AbstractAssetTask;
  52857. /**
  52858. * Creates a AssetsProgressEvent
  52859. * @param remainingCount defines the number of remaining tasks to process
  52860. * @param totalCount defines the total number of tasks
  52861. * @param task defines the task that was just processed
  52862. */
  52863. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  52864. }
  52865. /**
  52866. * Define a task used by AssetsManager to load meshes
  52867. */
  52868. export class MeshAssetTask extends AbstractAssetTask {
  52869. /**
  52870. * Defines the name of the task
  52871. */
  52872. name: string;
  52873. /**
  52874. * Defines the list of mesh's names you want to load
  52875. */
  52876. meshesNames: any;
  52877. /**
  52878. * Defines the root url to use as a base to load your meshes and associated resources
  52879. */
  52880. rootUrl: string;
  52881. /**
  52882. * Defines the filename of the scene to load from
  52883. */
  52884. sceneFilename: string;
  52885. /**
  52886. * Gets the list of loaded meshes
  52887. */
  52888. loadedMeshes: Array<AbstractMesh>;
  52889. /**
  52890. * Gets the list of loaded particle systems
  52891. */
  52892. loadedParticleSystems: Array<IParticleSystem>;
  52893. /**
  52894. * Gets the list of loaded skeletons
  52895. */
  52896. loadedSkeletons: Array<Skeleton>;
  52897. /**
  52898. * Callback called when the task is successful
  52899. */
  52900. onSuccess: (task: MeshAssetTask) => void;
  52901. /**
  52902. * Callback called when the task is successful
  52903. */
  52904. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  52905. /**
  52906. * Creates a new MeshAssetTask
  52907. * @param name defines the name of the task
  52908. * @param meshesNames defines the list of mesh's names you want to load
  52909. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  52910. * @param sceneFilename defines the filename of the scene to load from
  52911. */
  52912. constructor(
  52913. /**
  52914. * Defines the name of the task
  52915. */
  52916. name: string,
  52917. /**
  52918. * Defines the list of mesh's names you want to load
  52919. */
  52920. meshesNames: any,
  52921. /**
  52922. * Defines the root url to use as a base to load your meshes and associated resources
  52923. */
  52924. rootUrl: string,
  52925. /**
  52926. * Defines the filename of the scene to load from
  52927. */
  52928. sceneFilename: string);
  52929. /**
  52930. * Execute the current task
  52931. * @param scene defines the scene where you want your assets to be loaded
  52932. * @param onSuccess is a callback called when the task is successfully executed
  52933. * @param onError is a callback called if an error occurs
  52934. */
  52935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52936. }
  52937. /**
  52938. * Define a task used by AssetsManager to load text content
  52939. */
  52940. export class TextFileAssetTask extends AbstractAssetTask {
  52941. /**
  52942. * Defines the name of the task
  52943. */
  52944. name: string;
  52945. /**
  52946. * Defines the location of the file to load
  52947. */
  52948. url: string;
  52949. /**
  52950. * Gets the loaded text string
  52951. */
  52952. text: string;
  52953. /**
  52954. * Callback called when the task is successful
  52955. */
  52956. onSuccess: (task: TextFileAssetTask) => void;
  52957. /**
  52958. * Callback called when the task is successful
  52959. */
  52960. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  52961. /**
  52962. * Creates a new TextFileAssetTask object
  52963. * @param name defines the name of the task
  52964. * @param url defines the location of the file to load
  52965. */
  52966. constructor(
  52967. /**
  52968. * Defines the name of the task
  52969. */
  52970. name: string,
  52971. /**
  52972. * Defines the location of the file to load
  52973. */
  52974. url: string);
  52975. /**
  52976. * Execute the current task
  52977. * @param scene defines the scene where you want your assets to be loaded
  52978. * @param onSuccess is a callback called when the task is successfully executed
  52979. * @param onError is a callback called if an error occurs
  52980. */
  52981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52982. }
  52983. /**
  52984. * Define a task used by AssetsManager to load binary data
  52985. */
  52986. export class BinaryFileAssetTask extends AbstractAssetTask {
  52987. /**
  52988. * Defines the name of the task
  52989. */
  52990. name: string;
  52991. /**
  52992. * Defines the location of the file to load
  52993. */
  52994. url: string;
  52995. /**
  52996. * Gets the lodaded data (as an array buffer)
  52997. */
  52998. data: ArrayBuffer;
  52999. /**
  53000. * Callback called when the task is successful
  53001. */
  53002. onSuccess: (task: BinaryFileAssetTask) => void;
  53003. /**
  53004. * Callback called when the task is successful
  53005. */
  53006. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  53007. /**
  53008. * Creates a new BinaryFileAssetTask object
  53009. * @param name defines the name of the new task
  53010. * @param url defines the location of the file to load
  53011. */
  53012. constructor(
  53013. /**
  53014. * Defines the name of the task
  53015. */
  53016. name: string,
  53017. /**
  53018. * Defines the location of the file to load
  53019. */
  53020. url: string);
  53021. /**
  53022. * Execute the current task
  53023. * @param scene defines the scene where you want your assets to be loaded
  53024. * @param onSuccess is a callback called when the task is successfully executed
  53025. * @param onError is a callback called if an error occurs
  53026. */
  53027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53028. }
  53029. /**
  53030. * Define a task used by AssetsManager to load images
  53031. */
  53032. export class ImageAssetTask extends AbstractAssetTask {
  53033. /**
  53034. * Defines the name of the task
  53035. */
  53036. name: string;
  53037. /**
  53038. * Defines the location of the image to load
  53039. */
  53040. url: string;
  53041. /**
  53042. * Gets the loaded images
  53043. */
  53044. image: HTMLImageElement;
  53045. /**
  53046. * Callback called when the task is successful
  53047. */
  53048. onSuccess: (task: ImageAssetTask) => void;
  53049. /**
  53050. * Callback called when the task is successful
  53051. */
  53052. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  53053. /**
  53054. * Creates a new ImageAssetTask
  53055. * @param name defines the name of the task
  53056. * @param url defines the location of the image to load
  53057. */
  53058. constructor(
  53059. /**
  53060. * Defines the name of the task
  53061. */
  53062. name: string,
  53063. /**
  53064. * Defines the location of the image to load
  53065. */
  53066. url: string);
  53067. /**
  53068. * Execute the current task
  53069. * @param scene defines the scene where you want your assets to be loaded
  53070. * @param onSuccess is a callback called when the task is successfully executed
  53071. * @param onError is a callback called if an error occurs
  53072. */
  53073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53074. }
  53075. /**
  53076. * Defines the interface used by texture loading tasks
  53077. */
  53078. export interface ITextureAssetTask<TEX extends BaseTexture> {
  53079. /**
  53080. * Gets the loaded texture
  53081. */
  53082. texture: TEX;
  53083. }
  53084. /**
  53085. * Define a task used by AssetsManager to load 2D textures
  53086. */
  53087. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  53088. /**
  53089. * Defines the name of the task
  53090. */
  53091. name: string;
  53092. /**
  53093. * Defines the location of the file to load
  53094. */
  53095. url: string;
  53096. /**
  53097. * Defines if mipmap should not be generated (default is false)
  53098. */
  53099. noMipmap?: boolean | undefined;
  53100. /**
  53101. * Defines if texture must be inverted on Y axis (default is false)
  53102. */
  53103. invertY?: boolean | undefined;
  53104. /**
  53105. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53106. */
  53107. samplingMode: number;
  53108. /**
  53109. * Gets the loaded texture
  53110. */
  53111. texture: Texture;
  53112. /**
  53113. * Callback called when the task is successful
  53114. */
  53115. onSuccess: (task: TextureAssetTask) => void;
  53116. /**
  53117. * Callback called when the task is successful
  53118. */
  53119. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  53120. /**
  53121. * Creates a new TextureAssetTask object
  53122. * @param name defines the name of the task
  53123. * @param url defines the location of the file to load
  53124. * @param noMipmap defines if mipmap should not be generated (default is false)
  53125. * @param invertY defines if texture must be inverted on Y axis (default is false)
  53126. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53127. */
  53128. constructor(
  53129. /**
  53130. * Defines the name of the task
  53131. */
  53132. name: string,
  53133. /**
  53134. * Defines the location of the file to load
  53135. */
  53136. url: string,
  53137. /**
  53138. * Defines if mipmap should not be generated (default is false)
  53139. */
  53140. noMipmap?: boolean | undefined,
  53141. /**
  53142. * Defines if texture must be inverted on Y axis (default is false)
  53143. */
  53144. invertY?: boolean | undefined,
  53145. /**
  53146. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53147. */
  53148. samplingMode?: number);
  53149. /**
  53150. * Execute the current task
  53151. * @param scene defines the scene where you want your assets to be loaded
  53152. * @param onSuccess is a callback called when the task is successfully executed
  53153. * @param onError is a callback called if an error occurs
  53154. */
  53155. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53156. }
  53157. /**
  53158. * Define a task used by AssetsManager to load cube textures
  53159. */
  53160. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  53161. /**
  53162. * Defines the name of the task
  53163. */
  53164. name: string;
  53165. /**
  53166. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  53167. */
  53168. url: string;
  53169. /**
  53170. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53171. */
  53172. extensions?: string[] | undefined;
  53173. /**
  53174. * Defines if mipmaps should not be generated (default is false)
  53175. */
  53176. noMipmap?: boolean | undefined;
  53177. /**
  53178. * Defines the explicit list of files (undefined by default)
  53179. */
  53180. files?: string[] | undefined;
  53181. /**
  53182. * Gets the loaded texture
  53183. */
  53184. texture: CubeTexture;
  53185. /**
  53186. * Callback called when the task is successful
  53187. */
  53188. onSuccess: (task: CubeTextureAssetTask) => void;
  53189. /**
  53190. * Callback called when the task is successful
  53191. */
  53192. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  53193. /**
  53194. * Creates a new CubeTextureAssetTask
  53195. * @param name defines the name of the task
  53196. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  53197. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53198. * @param noMipmap defines if mipmaps should not be generated (default is false)
  53199. * @param files defines the explicit list of files (undefined by default)
  53200. */
  53201. constructor(
  53202. /**
  53203. * Defines the name of the task
  53204. */
  53205. name: string,
  53206. /**
  53207. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  53208. */
  53209. url: string,
  53210. /**
  53211. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53212. */
  53213. extensions?: string[] | undefined,
  53214. /**
  53215. * Defines if mipmaps should not be generated (default is false)
  53216. */
  53217. noMipmap?: boolean | undefined,
  53218. /**
  53219. * Defines the explicit list of files (undefined by default)
  53220. */
  53221. files?: string[] | undefined);
  53222. /**
  53223. * Execute the current task
  53224. * @param scene defines the scene where you want your assets to be loaded
  53225. * @param onSuccess is a callback called when the task is successfully executed
  53226. * @param onError is a callback called if an error occurs
  53227. */
  53228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53229. }
  53230. /**
  53231. * Define a task used by AssetsManager to load HDR cube textures
  53232. */
  53233. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  53234. /**
  53235. * Defines the name of the task
  53236. */
  53237. name: string;
  53238. /**
  53239. * Defines the location of the file to load
  53240. */
  53241. url: string;
  53242. /**
  53243. * Defines the desired size (the more it increases the longer the generation will be)
  53244. */
  53245. size: number;
  53246. /**
  53247. * Defines if mipmaps should not be generated (default is false)
  53248. */
  53249. noMipmap: boolean;
  53250. /**
  53251. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53252. */
  53253. generateHarmonics: boolean;
  53254. /**
  53255. * 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)
  53256. */
  53257. gammaSpace: boolean;
  53258. /**
  53259. * Internal Use Only
  53260. */
  53261. reserved: boolean;
  53262. /**
  53263. * Gets the loaded texture
  53264. */
  53265. texture: HDRCubeTexture;
  53266. /**
  53267. * Callback called when the task is successful
  53268. */
  53269. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  53270. /**
  53271. * Callback called when the task is successful
  53272. */
  53273. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  53274. /**
  53275. * Creates a new HDRCubeTextureAssetTask object
  53276. * @param name defines the name of the task
  53277. * @param url defines the location of the file to load
  53278. * @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.
  53279. * @param noMipmap defines if mipmaps should not be generated (default is false)
  53280. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53281. * @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)
  53282. * @param reserved Internal use only
  53283. */
  53284. constructor(
  53285. /**
  53286. * Defines the name of the task
  53287. */
  53288. name: string,
  53289. /**
  53290. * Defines the location of the file to load
  53291. */
  53292. url: string,
  53293. /**
  53294. * Defines the desired size (the more it increases the longer the generation will be)
  53295. */
  53296. size: number,
  53297. /**
  53298. * Defines if mipmaps should not be generated (default is false)
  53299. */
  53300. noMipmap?: boolean,
  53301. /**
  53302. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53303. */
  53304. generateHarmonics?: boolean,
  53305. /**
  53306. * 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)
  53307. */
  53308. gammaSpace?: boolean,
  53309. /**
  53310. * Internal Use Only
  53311. */
  53312. reserved?: boolean);
  53313. /**
  53314. * Execute the current task
  53315. * @param scene defines the scene where you want your assets to be loaded
  53316. * @param onSuccess is a callback called when the task is successfully executed
  53317. * @param onError is a callback called if an error occurs
  53318. */
  53319. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53320. }
  53321. /**
  53322. * This class can be used to easily import assets into a scene
  53323. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  53324. */
  53325. export class AssetsManager {
  53326. private _scene;
  53327. private _isLoading;
  53328. protected _tasks: AbstractAssetTask[];
  53329. protected _waitingTasksCount: number;
  53330. protected _totalTasksCount: number;
  53331. /**
  53332. * Callback called when all tasks are processed
  53333. */
  53334. onFinish: (tasks: AbstractAssetTask[]) => void;
  53335. /**
  53336. * Callback called when a task is successful
  53337. */
  53338. onTaskSuccess: (task: AbstractAssetTask) => void;
  53339. /**
  53340. * Callback called when a task had an error
  53341. */
  53342. onTaskError: (task: AbstractAssetTask) => void;
  53343. /**
  53344. * Callback called when a task is done (whatever the result is)
  53345. */
  53346. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  53347. /**
  53348. * Observable called when all tasks are processed
  53349. */
  53350. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  53351. /**
  53352. * Observable called when a task had an error
  53353. */
  53354. onTaskErrorObservable: Observable<AbstractAssetTask>;
  53355. /**
  53356. * Observable called when a task is successful
  53357. */
  53358. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  53359. /**
  53360. * Observable called when a task is done (whatever the result is)
  53361. */
  53362. onProgressObservable: Observable<IAssetsProgressEvent>;
  53363. /**
  53364. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  53365. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  53366. */
  53367. useDefaultLoadingScreen: boolean;
  53368. /**
  53369. * Creates a new AssetsManager
  53370. * @param scene defines the scene to work on
  53371. */
  53372. constructor(scene: Scene);
  53373. /**
  53374. * Add a MeshAssetTask to the list of active tasks
  53375. * @param taskName defines the name of the new task
  53376. * @param meshesNames defines the name of meshes to load
  53377. * @param rootUrl defines the root url to use to locate files
  53378. * @param sceneFilename defines the filename of the scene file
  53379. * @returns a new MeshAssetTask object
  53380. */
  53381. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  53382. /**
  53383. * Add a TextFileAssetTask to the list of active tasks
  53384. * @param taskName defines the name of the new task
  53385. * @param url defines the url of the file to load
  53386. * @returns a new TextFileAssetTask object
  53387. */
  53388. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  53389. /**
  53390. * Add a BinaryFileAssetTask to the list of active tasks
  53391. * @param taskName defines the name of the new task
  53392. * @param url defines the url of the file to load
  53393. * @returns a new BinaryFileAssetTask object
  53394. */
  53395. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  53396. /**
  53397. * Add a ImageAssetTask to the list of active tasks
  53398. * @param taskName defines the name of the new task
  53399. * @param url defines the url of the file to load
  53400. * @returns a new ImageAssetTask object
  53401. */
  53402. addImageTask(taskName: string, url: string): ImageAssetTask;
  53403. /**
  53404. * Add a TextureAssetTask to the list of active tasks
  53405. * @param taskName defines the name of the new task
  53406. * @param url defines the url of the file to load
  53407. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53408. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  53409. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53410. * @returns a new TextureAssetTask object
  53411. */
  53412. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  53413. /**
  53414. * Add a CubeTextureAssetTask to the list of active tasks
  53415. * @param taskName defines the name of the new task
  53416. * @param url defines the url of the file to load
  53417. * @param extensions defines the extension to use to load the cube map (can be null)
  53418. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53419. * @param files defines the list of files to load (can be null)
  53420. * @returns a new CubeTextureAssetTask object
  53421. */
  53422. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  53423. /**
  53424. *
  53425. * Add a HDRCubeTextureAssetTask to the list of active tasks
  53426. * @param taskName defines the name of the new task
  53427. * @param url defines the url of the file to load
  53428. * @param size defines the size you want for the cubemap (can be null)
  53429. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53430. * @param generateHarmonics defines if you want to automatically generate (true by default)
  53431. * @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)
  53432. * @param reserved Internal use only
  53433. * @returns a new HDRCubeTextureAssetTask object
  53434. */
  53435. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  53436. /**
  53437. * Remove a task from the assets manager.
  53438. * @param task the task to remove
  53439. */
  53440. removeTask(task: AbstractAssetTask): void;
  53441. private _decreaseWaitingTasksCount;
  53442. private _runTask;
  53443. /**
  53444. * Reset the AssetsManager and remove all tasks
  53445. * @return the current instance of the AssetsManager
  53446. */
  53447. reset(): AssetsManager;
  53448. /**
  53449. * Start the loading process
  53450. * @return the current instance of the AssetsManager
  53451. */
  53452. load(): AssetsManager;
  53453. }
  53454. }
  53455. declare module "babylonjs/Misc/deferred" {
  53456. /**
  53457. * Wrapper class for promise with external resolve and reject.
  53458. */
  53459. export class Deferred<T> {
  53460. /**
  53461. * The promise associated with this deferred object.
  53462. */
  53463. readonly promise: Promise<T>;
  53464. private _resolve;
  53465. private _reject;
  53466. /**
  53467. * The resolve method of the promise associated with this deferred object.
  53468. */
  53469. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  53470. /**
  53471. * The reject method of the promise associated with this deferred object.
  53472. */
  53473. readonly reject: (reason?: any) => void;
  53474. /**
  53475. * Constructor for this deferred object.
  53476. */
  53477. constructor();
  53478. }
  53479. }
  53480. declare module "babylonjs/Misc/HighDynamicRange/index" {
  53481. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  53482. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  53483. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53484. }
  53485. declare module "babylonjs/Misc/sceneOptimizer" {
  53486. import { Scene, IDisposable } from "babylonjs/scene";
  53487. import { Observable } from "babylonjs/Misc/observable";
  53488. /**
  53489. * Defines the root class used to create scene optimization to use with SceneOptimizer
  53490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53491. */
  53492. export class SceneOptimization {
  53493. /**
  53494. * Defines the priority of this optimization (0 by default which means first in the list)
  53495. */
  53496. priority: number;
  53497. /**
  53498. * Gets a string describing the action executed by the current optimization
  53499. * @returns description string
  53500. */
  53501. getDescription(): string;
  53502. /**
  53503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53504. * @param scene defines the current scene where to apply this optimization
  53505. * @param optimizer defines the current optimizer
  53506. * @returns true if everything that can be done was applied
  53507. */
  53508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53509. /**
  53510. * Creates the SceneOptimization object
  53511. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53512. * @param desc defines the description associated with the optimization
  53513. */
  53514. constructor(
  53515. /**
  53516. * Defines the priority of this optimization (0 by default which means first in the list)
  53517. */
  53518. priority?: number);
  53519. }
  53520. /**
  53521. * Defines an optimization used to reduce the size of render target textures
  53522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53523. */
  53524. export class TextureOptimization extends SceneOptimization {
  53525. /**
  53526. * Defines the priority of this optimization (0 by default which means first in the list)
  53527. */
  53528. priority: number;
  53529. /**
  53530. * 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
  53531. */
  53532. maximumSize: number;
  53533. /**
  53534. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53535. */
  53536. step: number;
  53537. /**
  53538. * Gets a string describing the action executed by the current optimization
  53539. * @returns description string
  53540. */
  53541. getDescription(): string;
  53542. /**
  53543. * Creates the TextureOptimization object
  53544. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53545. * @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
  53546. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53547. */
  53548. constructor(
  53549. /**
  53550. * Defines the priority of this optimization (0 by default which means first in the list)
  53551. */
  53552. priority?: number,
  53553. /**
  53554. * 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
  53555. */
  53556. maximumSize?: number,
  53557. /**
  53558. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53559. */
  53560. step?: number);
  53561. /**
  53562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53563. * @param scene defines the current scene where to apply this optimization
  53564. * @param optimizer defines the current optimizer
  53565. * @returns true if everything that can be done was applied
  53566. */
  53567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53568. }
  53569. /**
  53570. * Defines an optimization used to increase or decrease the rendering resolution
  53571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53572. */
  53573. export class HardwareScalingOptimization extends SceneOptimization {
  53574. /**
  53575. * Defines the priority of this optimization (0 by default which means first in the list)
  53576. */
  53577. priority: number;
  53578. /**
  53579. * Defines the maximum scale to use (2 by default)
  53580. */
  53581. maximumScale: number;
  53582. /**
  53583. * Defines the step to use between two passes (0.5 by default)
  53584. */
  53585. step: number;
  53586. private _currentScale;
  53587. private _directionOffset;
  53588. /**
  53589. * Gets a string describing the action executed by the current optimization
  53590. * @return description string
  53591. */
  53592. getDescription(): string;
  53593. /**
  53594. * Creates the HardwareScalingOptimization object
  53595. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53596. * @param maximumScale defines the maximum scale to use (2 by default)
  53597. * @param step defines the step to use between two passes (0.5 by default)
  53598. */
  53599. constructor(
  53600. /**
  53601. * Defines the priority of this optimization (0 by default which means first in the list)
  53602. */
  53603. priority?: number,
  53604. /**
  53605. * Defines the maximum scale to use (2 by default)
  53606. */
  53607. maximumScale?: number,
  53608. /**
  53609. * Defines the step to use between two passes (0.5 by default)
  53610. */
  53611. step?: number);
  53612. /**
  53613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53614. * @param scene defines the current scene where to apply this optimization
  53615. * @param optimizer defines the current optimizer
  53616. * @returns true if everything that can be done was applied
  53617. */
  53618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53619. }
  53620. /**
  53621. * Defines an optimization used to remove shadows
  53622. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53623. */
  53624. export class ShadowsOptimization extends SceneOptimization {
  53625. /**
  53626. * Gets a string describing the action executed by the current optimization
  53627. * @return description string
  53628. */
  53629. getDescription(): string;
  53630. /**
  53631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53632. * @param scene defines the current scene where to apply this optimization
  53633. * @param optimizer defines the current optimizer
  53634. * @returns true if everything that can be done was applied
  53635. */
  53636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53637. }
  53638. /**
  53639. * Defines an optimization used to turn post-processes off
  53640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53641. */
  53642. export class PostProcessesOptimization extends SceneOptimization {
  53643. /**
  53644. * Gets a string describing the action executed by the current optimization
  53645. * @return description string
  53646. */
  53647. getDescription(): string;
  53648. /**
  53649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53650. * @param scene defines the current scene where to apply this optimization
  53651. * @param optimizer defines the current optimizer
  53652. * @returns true if everything that can be done was applied
  53653. */
  53654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53655. }
  53656. /**
  53657. * Defines an optimization used to turn lens flares off
  53658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53659. */
  53660. export class LensFlaresOptimization extends SceneOptimization {
  53661. /**
  53662. * Gets a string describing the action executed by the current optimization
  53663. * @return description string
  53664. */
  53665. getDescription(): string;
  53666. /**
  53667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53668. * @param scene defines the current scene where to apply this optimization
  53669. * @param optimizer defines the current optimizer
  53670. * @returns true if everything that can be done was applied
  53671. */
  53672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53673. }
  53674. /**
  53675. * Defines an optimization based on user defined callback.
  53676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53677. */
  53678. export class CustomOptimization extends SceneOptimization {
  53679. /**
  53680. * Callback called to apply the custom optimization.
  53681. */
  53682. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  53683. /**
  53684. * Callback called to get custom description
  53685. */
  53686. onGetDescription: () => string;
  53687. /**
  53688. * Gets a string describing the action executed by the current optimization
  53689. * @returns description string
  53690. */
  53691. getDescription(): string;
  53692. /**
  53693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53694. * @param scene defines the current scene where to apply this optimization
  53695. * @param optimizer defines the current optimizer
  53696. * @returns true if everything that can be done was applied
  53697. */
  53698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53699. }
  53700. /**
  53701. * Defines an optimization used to turn particles off
  53702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53703. */
  53704. export class ParticlesOptimization extends SceneOptimization {
  53705. /**
  53706. * Gets a string describing the action executed by the current optimization
  53707. * @return description string
  53708. */
  53709. getDescription(): string;
  53710. /**
  53711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53712. * @param scene defines the current scene where to apply this optimization
  53713. * @param optimizer defines the current optimizer
  53714. * @returns true if everything that can be done was applied
  53715. */
  53716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53717. }
  53718. /**
  53719. * Defines an optimization used to turn render targets off
  53720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53721. */
  53722. export class RenderTargetsOptimization extends SceneOptimization {
  53723. /**
  53724. * Gets a string describing the action executed by the current optimization
  53725. * @return description string
  53726. */
  53727. getDescription(): string;
  53728. /**
  53729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53730. * @param scene defines the current scene where to apply this optimization
  53731. * @param optimizer defines the current optimizer
  53732. * @returns true if everything that can be done was applied
  53733. */
  53734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53735. }
  53736. /**
  53737. * Defines an optimization used to merge meshes with compatible materials
  53738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53739. */
  53740. export class MergeMeshesOptimization extends SceneOptimization {
  53741. private static _UpdateSelectionTree;
  53742. /**
  53743. * Gets or sets a boolean which defines if optimization octree has to be updated
  53744. */
  53745. /**
  53746. * Gets or sets a boolean which defines if optimization octree has to be updated
  53747. */
  53748. static UpdateSelectionTree: boolean;
  53749. /**
  53750. * Gets a string describing the action executed by the current optimization
  53751. * @return description string
  53752. */
  53753. getDescription(): string;
  53754. private _canBeMerged;
  53755. /**
  53756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53757. * @param scene defines the current scene where to apply this optimization
  53758. * @param optimizer defines the current optimizer
  53759. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  53760. * @returns true if everything that can be done was applied
  53761. */
  53762. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  53763. }
  53764. /**
  53765. * Defines a list of options used by SceneOptimizer
  53766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53767. */
  53768. export class SceneOptimizerOptions {
  53769. /**
  53770. * Defines the target frame rate to reach (60 by default)
  53771. */
  53772. targetFrameRate: number;
  53773. /**
  53774. * Defines the interval between two checkes (2000ms by default)
  53775. */
  53776. trackerDuration: number;
  53777. /**
  53778. * Gets the list of optimizations to apply
  53779. */
  53780. optimizations: SceneOptimization[];
  53781. /**
  53782. * Creates a new list of options used by SceneOptimizer
  53783. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  53784. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  53785. */
  53786. constructor(
  53787. /**
  53788. * Defines the target frame rate to reach (60 by default)
  53789. */
  53790. targetFrameRate?: number,
  53791. /**
  53792. * Defines the interval between two checkes (2000ms by default)
  53793. */
  53794. trackerDuration?: number);
  53795. /**
  53796. * Add a new optimization
  53797. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  53798. * @returns the current SceneOptimizerOptions
  53799. */
  53800. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  53801. /**
  53802. * Add a new custom optimization
  53803. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  53804. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  53805. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53806. * @returns the current SceneOptimizerOptions
  53807. */
  53808. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  53809. /**
  53810. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  53811. * @param targetFrameRate defines the target frame rate (60 by default)
  53812. * @returns a SceneOptimizerOptions object
  53813. */
  53814. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53815. /**
  53816. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  53817. * @param targetFrameRate defines the target frame rate (60 by default)
  53818. * @returns a SceneOptimizerOptions object
  53819. */
  53820. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53821. /**
  53822. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  53823. * @param targetFrameRate defines the target frame rate (60 by default)
  53824. * @returns a SceneOptimizerOptions object
  53825. */
  53826. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53827. }
  53828. /**
  53829. * Class used to run optimizations in order to reach a target frame rate
  53830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53831. */
  53832. export class SceneOptimizer implements IDisposable {
  53833. private _isRunning;
  53834. private _options;
  53835. private _scene;
  53836. private _currentPriorityLevel;
  53837. private _targetFrameRate;
  53838. private _trackerDuration;
  53839. private _currentFrameRate;
  53840. private _sceneDisposeObserver;
  53841. private _improvementMode;
  53842. /**
  53843. * Defines an observable called when the optimizer reaches the target frame rate
  53844. */
  53845. onSuccessObservable: Observable<SceneOptimizer>;
  53846. /**
  53847. * Defines an observable called when the optimizer enables an optimization
  53848. */
  53849. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  53850. /**
  53851. * Defines an observable called when the optimizer is not able to reach the target frame rate
  53852. */
  53853. onFailureObservable: Observable<SceneOptimizer>;
  53854. /**
  53855. * Gets a boolean indicating if the optimizer is in improvement mode
  53856. */
  53857. readonly isInImprovementMode: boolean;
  53858. /**
  53859. * Gets the current priority level (0 at start)
  53860. */
  53861. readonly currentPriorityLevel: number;
  53862. /**
  53863. * Gets the current frame rate checked by the SceneOptimizer
  53864. */
  53865. readonly currentFrameRate: number;
  53866. /**
  53867. * Gets or sets the current target frame rate (60 by default)
  53868. */
  53869. /**
  53870. * Gets or sets the current target frame rate (60 by default)
  53871. */
  53872. targetFrameRate: number;
  53873. /**
  53874. * Gets or sets the current interval between two checks (every 2000ms by default)
  53875. */
  53876. /**
  53877. * Gets or sets the current interval between two checks (every 2000ms by default)
  53878. */
  53879. trackerDuration: number;
  53880. /**
  53881. * Gets the list of active optimizations
  53882. */
  53883. readonly optimizations: SceneOptimization[];
  53884. /**
  53885. * Creates a new SceneOptimizer
  53886. * @param scene defines the scene to work on
  53887. * @param options defines the options to use with the SceneOptimizer
  53888. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  53889. * @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)
  53890. */
  53891. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  53892. /**
  53893. * Stops the current optimizer
  53894. */
  53895. stop(): void;
  53896. /**
  53897. * Reset the optimizer to initial step (current priority level = 0)
  53898. */
  53899. reset(): void;
  53900. /**
  53901. * Start the optimizer. By default it will try to reach a specific framerate
  53902. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  53903. */
  53904. start(): void;
  53905. private _checkCurrentState;
  53906. /**
  53907. * Release all resources
  53908. */
  53909. dispose(): void;
  53910. /**
  53911. * Helper function to create a SceneOptimizer with one single line of code
  53912. * @param scene defines the scene to work on
  53913. * @param options defines the options to use with the SceneOptimizer
  53914. * @param onSuccess defines a callback to call on success
  53915. * @param onFailure defines a callback to call on failure
  53916. * @returns the new SceneOptimizer object
  53917. */
  53918. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  53919. }
  53920. }
  53921. declare module "babylonjs/Misc/sceneSerializer" {
  53922. import { Scene } from "babylonjs/scene";
  53923. /**
  53924. * Class used to serialize a scene into a string
  53925. */
  53926. export class SceneSerializer {
  53927. /**
  53928. * Clear cache used by a previous serialization
  53929. */
  53930. static ClearCache(): void;
  53931. /**
  53932. * Serialize a scene into a JSON compatible object
  53933. * @param scene defines the scene to serialize
  53934. * @returns a JSON compatible object
  53935. */
  53936. static Serialize(scene: Scene): any;
  53937. /**
  53938. * Serialize a mesh into a JSON compatible object
  53939. * @param toSerialize defines the mesh to serialize
  53940. * @param withParents defines if parents must be serialized as well
  53941. * @param withChildren defines if children must be serialized as well
  53942. * @returns a JSON compatible object
  53943. */
  53944. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  53945. }
  53946. }
  53947. declare module "babylonjs/Misc/videoRecorder" {
  53948. import { Nullable } from "babylonjs/types";
  53949. import { Engine } from "babylonjs/Engines/engine";
  53950. /**
  53951. * This represents the different options avilable for the video capture.
  53952. */
  53953. export interface VideoRecorderOptions {
  53954. /** Defines the mime type of the video */
  53955. mimeType: string;
  53956. /** Defines the video the video should be recorded at */
  53957. fps: number;
  53958. /** Defines the chunk size for the recording data */
  53959. recordChunckSize: number;
  53960. }
  53961. /**
  53962. * This can helps recording videos from BabylonJS.
  53963. * This is based on the available WebRTC functionalities of the browser.
  53964. *
  53965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  53966. */
  53967. export class VideoRecorder {
  53968. private static readonly _defaultOptions;
  53969. /**
  53970. * Returns wehther or not the VideoRecorder is available in your browser.
  53971. * @param engine Defines the Babylon Engine to check the support for
  53972. * @returns true if supported otherwise false
  53973. */
  53974. static IsSupported(engine: Engine): boolean;
  53975. private readonly _options;
  53976. private _canvas;
  53977. private _mediaRecorder;
  53978. private _recordedChunks;
  53979. private _fileName;
  53980. private _resolve;
  53981. private _reject;
  53982. /**
  53983. * True wether a recording is already in progress.
  53984. */
  53985. readonly isRecording: boolean;
  53986. /**
  53987. * Create a new VideoCapture object which can help converting what you see in Babylon to
  53988. * a video file.
  53989. * @param engine Defines the BabylonJS Engine you wish to record
  53990. * @param options Defines options that can be used to customized the capture
  53991. */
  53992. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  53993. /**
  53994. * Stops the current recording before the default capture timeout passed in the startRecording
  53995. * functions.
  53996. */
  53997. stopRecording(): void;
  53998. /**
  53999. * Starts recording the canvas for a max duration specified in parameters.
  54000. * @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.
  54001. * @param maxDuration Defines the maximum recording time in seconds.
  54002. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  54003. * @return a promise callback at the end of the recording with the video data in Blob.
  54004. */
  54005. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  54006. /**
  54007. * Releases internal resources used during the recording.
  54008. */
  54009. dispose(): void;
  54010. private _handleDataAvailable;
  54011. private _handleError;
  54012. private _handleStop;
  54013. }
  54014. }
  54015. declare module "babylonjs/Misc/workerPool" {
  54016. import { IDisposable } from "babylonjs/scene";
  54017. /**
  54018. * Helper class to push actions to a pool of workers.
  54019. */
  54020. export class WorkerPool implements IDisposable {
  54021. private _workerInfos;
  54022. private _pendingActions;
  54023. /**
  54024. * Constructor
  54025. * @param workers Array of workers to use for actions
  54026. */
  54027. constructor(workers: Array<Worker>);
  54028. /**
  54029. * Terminates all workers and clears any pending actions.
  54030. */
  54031. dispose(): void;
  54032. /**
  54033. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54034. * pended until a worker has completed its action.
  54035. * @param action The action to perform. Call onComplete when the action is complete.
  54036. */
  54037. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54038. private _execute;
  54039. }
  54040. }
  54041. declare module "babylonjs/Misc/index" {
  54042. export * from "babylonjs/Misc/andOrNotEvaluator";
  54043. export * from "babylonjs/Misc/assetsManager";
  54044. export * from "babylonjs/Misc/dds";
  54045. export * from "babylonjs/Misc/decorators";
  54046. export * from "babylonjs/Misc/deferred";
  54047. export * from "babylonjs/Misc/environmentTextureTools";
  54048. export * from "babylonjs/Misc/filesInput";
  54049. export * from "babylonjs/Misc/HighDynamicRange/index";
  54050. export * from "babylonjs/Misc/khronosTextureContainer";
  54051. export * from "babylonjs/Misc/observable";
  54052. export * from "babylonjs/Misc/performanceMonitor";
  54053. export * from "babylonjs/Misc/promise";
  54054. export * from "babylonjs/Misc/sceneOptimizer";
  54055. export * from "babylonjs/Misc/sceneSerializer";
  54056. export * from "babylonjs/Misc/smartArray";
  54057. export * from "babylonjs/Misc/stringDictionary";
  54058. export * from "babylonjs/Misc/tags";
  54059. export * from "babylonjs/Misc/textureTools";
  54060. export * from "babylonjs/Misc/tga";
  54061. export * from "babylonjs/Misc/tools";
  54062. export * from "babylonjs/Misc/videoRecorder";
  54063. export * from "babylonjs/Misc/virtualJoystick";
  54064. export * from "babylonjs/Misc/workerPool";
  54065. }
  54066. declare module "babylonjs/index" {
  54067. export * from "babylonjs/abstractScene";
  54068. export * from "babylonjs/Actions/index";
  54069. export * from "babylonjs/Animations/index";
  54070. export * from "babylonjs/assetContainer";
  54071. export * from "babylonjs/Audio/index";
  54072. export * from "babylonjs/Behaviors/index";
  54073. export * from "babylonjs/Bones/index";
  54074. export * from "babylonjs/Cameras/index";
  54075. export * from "babylonjs/Collisions/index";
  54076. export * from "babylonjs/Culling/index";
  54077. export * from "babylonjs/Debug/index";
  54078. export * from "babylonjs/Engines/index";
  54079. export * from "babylonjs/Events/index";
  54080. export * from "babylonjs/Gamepads/index";
  54081. export * from "babylonjs/Gizmos/index";
  54082. export * from "babylonjs/Helpers/index";
  54083. export * from "babylonjs/Instrumentation/index";
  54084. export * from "babylonjs/Layers/index";
  54085. export * from "babylonjs/LensFlares/index";
  54086. export * from "babylonjs/Lights/index";
  54087. export * from "babylonjs/Loading/index";
  54088. export * from "babylonjs/Materials/index";
  54089. export * from "babylonjs/Maths/index";
  54090. export * from "babylonjs/Meshes/index";
  54091. export * from "babylonjs/Morph/index";
  54092. export * from "babylonjs/node";
  54093. export * from "babylonjs/Offline/index";
  54094. export * from "babylonjs/Particles/index";
  54095. export * from "babylonjs/Physics/index";
  54096. export * from "babylonjs/PostProcesses/index";
  54097. export * from "babylonjs/Probes/index";
  54098. export * from "babylonjs/Rendering/index";
  54099. export * from "babylonjs/scene";
  54100. export * from "babylonjs/sceneComponent";
  54101. export * from "babylonjs/Sprites/index";
  54102. export * from "babylonjs/States/index";
  54103. export * from "babylonjs/Misc/index";
  54104. export * from "babylonjs/types";
  54105. }
  54106. interface Window {
  54107. mozIndexedDB: IDBFactory;
  54108. webkitIndexedDB: IDBFactory;
  54109. msIndexedDB: IDBFactory;
  54110. webkitURL: typeof URL;
  54111. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  54112. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  54113. WebGLRenderingContext: WebGLRenderingContext;
  54114. MSGesture: MSGesture;
  54115. CANNON: any;
  54116. AudioContext: AudioContext;
  54117. webkitAudioContext: AudioContext;
  54118. PointerEvent: any;
  54119. Math: Math;
  54120. Uint8Array: Uint8ArrayConstructor;
  54121. Float32Array: Float32ArrayConstructor;
  54122. mozURL: typeof URL;
  54123. msURL: typeof URL;
  54124. VRFrameData: any;
  54125. DracoDecoderModule: any;
  54126. setImmediate(handler: (...args: any[]) => void): number;
  54127. }
  54128. interface WebGLProgram {
  54129. context?: WebGLRenderingContext;
  54130. vertexShader?: WebGLShader;
  54131. fragmentShader?: WebGLShader;
  54132. isParallelCompiled: boolean;
  54133. onCompiled?: () => void;
  54134. }
  54135. interface WebGLRenderingContext {
  54136. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  54137. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  54138. vertexAttribDivisor(index: number, divisor: number): void;
  54139. createVertexArray(): any;
  54140. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  54141. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  54142. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  54143. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  54144. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  54145. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  54146. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  54147. createQuery(): WebGLQuery;
  54148. deleteQuery(query: WebGLQuery): void;
  54149. beginQuery(target: number, query: WebGLQuery): void;
  54150. endQuery(target: number): void;
  54151. getQueryParameter(query: WebGLQuery, pname: number): any;
  54152. getQuery(target: number, pname: number): any;
  54153. MAX_SAMPLES: number;
  54154. RGBA8: number;
  54155. READ_FRAMEBUFFER: number;
  54156. DRAW_FRAMEBUFFER: number;
  54157. UNIFORM_BUFFER: number;
  54158. HALF_FLOAT_OES: number;
  54159. RGBA16F: number;
  54160. RGBA32F: number;
  54161. R32F: number;
  54162. RG32F: number;
  54163. RGB32F: number;
  54164. R16F: number;
  54165. RG16F: number;
  54166. RGB16F: number;
  54167. RED: number;
  54168. RG: number;
  54169. R8: number;
  54170. RG8: number;
  54171. UNSIGNED_INT_24_8: number;
  54172. DEPTH24_STENCIL8: number;
  54173. drawBuffers(buffers: number[]): void;
  54174. readBuffer(src: number): void;
  54175. readonly COLOR_ATTACHMENT0: number;
  54176. readonly COLOR_ATTACHMENT1: number;
  54177. readonly COLOR_ATTACHMENT2: number;
  54178. readonly COLOR_ATTACHMENT3: number;
  54179. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  54180. ANY_SAMPLES_PASSED: number;
  54181. QUERY_RESULT_AVAILABLE: number;
  54182. QUERY_RESULT: number;
  54183. }
  54184. interface Document {
  54185. mozCancelFullScreen(): void;
  54186. msCancelFullScreen(): void;
  54187. webkitCancelFullScreen(): void;
  54188. requestPointerLock(): void;
  54189. exitPointerLock(): void;
  54190. mozFullScreen: boolean;
  54191. msIsFullScreen: boolean;
  54192. readonly webkitIsFullScreen: boolean;
  54193. readonly pointerLockElement: Element;
  54194. mozPointerLockElement: HTMLElement;
  54195. msPointerLockElement: HTMLElement;
  54196. webkitPointerLockElement: HTMLElement;
  54197. }
  54198. interface HTMLCanvasElement {
  54199. requestPointerLock(): void;
  54200. msRequestPointerLock?(): void;
  54201. mozRequestPointerLock?(): void;
  54202. webkitRequestPointerLock?(): void;
  54203. /** Track wether a record is in progress */
  54204. isRecording: boolean;
  54205. /** Capture Stream method defined by some browsers */
  54206. captureStream(fps?: number): MediaStream;
  54207. }
  54208. interface CanvasRenderingContext2D {
  54209. msImageSmoothingEnabled: boolean;
  54210. }
  54211. interface WebGLBuffer {
  54212. references: number;
  54213. capacity: number;
  54214. is32Bits: boolean;
  54215. }
  54216. interface WebGLProgram {
  54217. transformFeedback?: WebGLTransformFeedback | null;
  54218. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  54219. }
  54220. interface MouseEvent {
  54221. mozMovementX: number;
  54222. mozMovementY: number;
  54223. webkitMovementX: number;
  54224. webkitMovementY: number;
  54225. msMovementX: number;
  54226. msMovementY: number;
  54227. }
  54228. interface Navigator {
  54229. mozGetVRDevices: (any: any) => any;
  54230. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  54231. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  54232. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  54233. webkitGetGamepads(): Gamepad[];
  54234. msGetGamepads(): Gamepad[];
  54235. webkitGamepads(): Gamepad[];
  54236. }
  54237. interface HTMLVideoElement {
  54238. mozSrcObject: any;
  54239. }
  54240. interface Math {
  54241. fround(x: number): number;
  54242. imul(a: number, b: number): number;
  54243. }
  54244. interface EXT_disjoint_timer_query {
  54245. QUERY_COUNTER_BITS_EXT: number;
  54246. TIME_ELAPSED_EXT: number;
  54247. TIMESTAMP_EXT: number;
  54248. GPU_DISJOINT_EXT: number;
  54249. QUERY_RESULT_EXT: number;
  54250. QUERY_RESULT_AVAILABLE_EXT: number;
  54251. queryCounterEXT(query: WebGLQuery, target: number): void;
  54252. createQueryEXT(): WebGLQuery;
  54253. beginQueryEXT(target: number, query: WebGLQuery): void;
  54254. endQueryEXT(target: number): void;
  54255. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  54256. deleteQueryEXT(query: WebGLQuery): void;
  54257. }
  54258. interface WebGLUniformLocation {
  54259. _currentState: any;
  54260. }
  54261. interface XRDevice {
  54262. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  54263. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  54264. }
  54265. interface XRSession {
  54266. getInputSources(): Array<any>;
  54267. baseLayer: XRWebGLLayer;
  54268. requestFrameOfReference(type: string): Promise<void>;
  54269. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  54270. end(): Promise<void>;
  54271. requestAnimationFrame: Function;
  54272. addEventListener: Function;
  54273. }
  54274. interface XRSessionCreationOptions {
  54275. outputContext?: WebGLRenderingContext | null;
  54276. immersive?: boolean;
  54277. environmentIntegration?: boolean;
  54278. }
  54279. interface XRLayer {
  54280. getViewport: Function;
  54281. framebufferWidth: number;
  54282. framebufferHeight: number;
  54283. }
  54284. interface XRView {
  54285. projectionMatrix: Float32Array;
  54286. }
  54287. interface XRFrame {
  54288. getDevicePose: Function;
  54289. getInputPose: Function;
  54290. views: Array<XRView>;
  54291. baseLayer: XRLayer;
  54292. }
  54293. interface XRFrameOfReference {
  54294. }
  54295. interface XRWebGLLayer extends XRLayer {
  54296. framebuffer: WebGLFramebuffer;
  54297. }
  54298. declare var XRWebGLLayer: {
  54299. prototype: XRWebGLLayer;
  54300. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  54301. };
  54302. interface VRDisplay extends EventTarget {
  54303. /**
  54304. * Dictionary of capabilities describing the VRDisplay.
  54305. */
  54306. readonly capabilities: VRDisplayCapabilities;
  54307. /**
  54308. * z-depth defining the far plane of the eye view frustum
  54309. * enables mapping of values in the render target depth
  54310. * attachment to scene coordinates. Initially set to 10000.0.
  54311. */
  54312. depthFar: number;
  54313. /**
  54314. * z-depth defining the near plane of the eye view frustum
  54315. * enables mapping of values in the render target depth
  54316. * attachment to scene coordinates. Initially set to 0.01.
  54317. */
  54318. depthNear: number;
  54319. /**
  54320. * An identifier for this distinct VRDisplay. Used as an
  54321. * association point in the Gamepad API.
  54322. */
  54323. readonly displayId: number;
  54324. /**
  54325. * A display name, a user-readable name identifying it.
  54326. */
  54327. readonly displayName: string;
  54328. readonly isConnected: boolean;
  54329. readonly isPresenting: boolean;
  54330. /**
  54331. * If this VRDisplay supports room-scale experiences, the optional
  54332. * stage attribute contains details on the room-scale parameters.
  54333. */
  54334. readonly stageParameters: VRStageParameters | null;
  54335. /**
  54336. * Passing the value returned by `requestAnimationFrame` to
  54337. * `cancelAnimationFrame` will unregister the callback.
  54338. * @param handle Define the hanle of the request to cancel
  54339. */
  54340. cancelAnimationFrame(handle: number): void;
  54341. /**
  54342. * Stops presenting to the VRDisplay.
  54343. * @returns a promise to know when it stopped
  54344. */
  54345. exitPresent(): Promise<void>;
  54346. /**
  54347. * Return the current VREyeParameters for the given eye.
  54348. * @param whichEye Define the eye we want the parameter for
  54349. * @returns the eye parameters
  54350. */
  54351. getEyeParameters(whichEye: string): VREyeParameters;
  54352. /**
  54353. * Populates the passed VRFrameData with the information required to render
  54354. * the current frame.
  54355. * @param frameData Define the data structure to populate
  54356. * @returns true if ok otherwise false
  54357. */
  54358. getFrameData(frameData: VRFrameData): boolean;
  54359. /**
  54360. * Get the layers currently being presented.
  54361. * @returns the list of VR layers
  54362. */
  54363. getLayers(): VRLayer[];
  54364. /**
  54365. * Return a VRPose containing the future predicted pose of the VRDisplay
  54366. * when the current frame will be presented. The value returned will not
  54367. * change until JavaScript has returned control to the browser.
  54368. *
  54369. * The VRPose will contain the position, orientation, velocity,
  54370. * and acceleration of each of these properties.
  54371. * @returns the pose object
  54372. */
  54373. getPose(): VRPose;
  54374. /**
  54375. * Return the current instantaneous pose of the VRDisplay, with no
  54376. * prediction applied.
  54377. * @returns the current instantaneous pose
  54378. */
  54379. getImmediatePose(): VRPose;
  54380. /**
  54381. * The callback passed to `requestAnimationFrame` will be called
  54382. * any time a new frame should be rendered. When the VRDisplay is
  54383. * presenting the callback will be called at the native refresh
  54384. * rate of the HMD. When not presenting this function acts
  54385. * identically to how window.requestAnimationFrame acts. Content should
  54386. * make no assumptions of frame rate or vsync behavior as the HMD runs
  54387. * asynchronously from other displays and at differing refresh rates.
  54388. * @param callback Define the eaction to run next frame
  54389. * @returns the request handle it
  54390. */
  54391. requestAnimationFrame(callback: FrameRequestCallback): number;
  54392. /**
  54393. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  54394. * Repeat calls while already presenting will update the VRLayers being displayed.
  54395. * @param layers Define the list of layer to present
  54396. * @returns a promise to know when the request has been fulfilled
  54397. */
  54398. requestPresent(layers: VRLayer[]): Promise<void>;
  54399. /**
  54400. * Reset the pose for this display, treating its current position and
  54401. * orientation as the "origin/zero" values. VRPose.position,
  54402. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  54403. * updated when calling resetPose(). This should be called in only
  54404. * sitting-space experiences.
  54405. */
  54406. resetPose(): void;
  54407. /**
  54408. * The VRLayer provided to the VRDisplay will be captured and presented
  54409. * in the HMD. Calling this function has the same effect on the source
  54410. * canvas as any other operation that uses its source image, and canvases
  54411. * created without preserveDrawingBuffer set to true will be cleared.
  54412. * @param pose Define the pose to submit
  54413. */
  54414. submitFrame(pose?: VRPose): void;
  54415. }
  54416. declare var VRDisplay: {
  54417. prototype: VRDisplay;
  54418. new (): VRDisplay;
  54419. };
  54420. interface VRLayer {
  54421. leftBounds?: number[] | Float32Array | null;
  54422. rightBounds?: number[] | Float32Array | null;
  54423. source?: HTMLCanvasElement | null;
  54424. }
  54425. interface VRDisplayCapabilities {
  54426. readonly canPresent: boolean;
  54427. readonly hasExternalDisplay: boolean;
  54428. readonly hasOrientation: boolean;
  54429. readonly hasPosition: boolean;
  54430. readonly maxLayers: number;
  54431. }
  54432. interface VREyeParameters {
  54433. /** @deprecated */
  54434. readonly fieldOfView: VRFieldOfView;
  54435. readonly offset: Float32Array;
  54436. readonly renderHeight: number;
  54437. readonly renderWidth: number;
  54438. }
  54439. interface VRFieldOfView {
  54440. readonly downDegrees: number;
  54441. readonly leftDegrees: number;
  54442. readonly rightDegrees: number;
  54443. readonly upDegrees: number;
  54444. }
  54445. interface VRFrameData {
  54446. readonly leftProjectionMatrix: Float32Array;
  54447. readonly leftViewMatrix: Float32Array;
  54448. readonly pose: VRPose;
  54449. readonly rightProjectionMatrix: Float32Array;
  54450. readonly rightViewMatrix: Float32Array;
  54451. readonly timestamp: number;
  54452. }
  54453. interface VRPose {
  54454. readonly angularAcceleration: Float32Array | null;
  54455. readonly angularVelocity: Float32Array | null;
  54456. readonly linearAcceleration: Float32Array | null;
  54457. readonly linearVelocity: Float32Array | null;
  54458. readonly orientation: Float32Array | null;
  54459. readonly position: Float32Array | null;
  54460. readonly timestamp: number;
  54461. }
  54462. interface VRStageParameters {
  54463. sittingToStandingTransform?: Float32Array;
  54464. sizeX?: number;
  54465. sizeY?: number;
  54466. }
  54467. interface Navigator {
  54468. getVRDisplays(): Promise<VRDisplay[]>;
  54469. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  54470. }
  54471. interface Window {
  54472. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  54473. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  54474. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  54475. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  54476. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  54477. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  54478. }
  54479. interface Gamepad {
  54480. readonly displayId: number;
  54481. }
  54482. interface WebGLRenderingContext {
  54483. readonly RASTERIZER_DISCARD: number;
  54484. readonly DEPTH_COMPONENT24: number;
  54485. readonly TEXTURE_3D: number;
  54486. readonly TEXTURE_2D_ARRAY: number;
  54487. readonly TEXTURE_COMPARE_FUNC: number;
  54488. readonly TEXTURE_COMPARE_MODE: number;
  54489. readonly COMPARE_REF_TO_TEXTURE: number;
  54490. readonly TEXTURE_WRAP_R: number;
  54491. readonly HALF_FLOAT: number;
  54492. readonly RGB8: number;
  54493. readonly RED_INTEGER: number;
  54494. readonly RG_INTEGER: number;
  54495. readonly RGB_INTEGER: number;
  54496. readonly RGBA_INTEGER: number;
  54497. readonly R8_SNORM: number;
  54498. readonly RG8_SNORM: number;
  54499. readonly RGB8_SNORM: number;
  54500. readonly RGBA8_SNORM: number;
  54501. readonly R8I: number;
  54502. readonly RG8I: number;
  54503. readonly RGB8I: number;
  54504. readonly RGBA8I: number;
  54505. readonly R8UI: number;
  54506. readonly RG8UI: number;
  54507. readonly RGB8UI: number;
  54508. readonly RGBA8UI: number;
  54509. readonly R16I: number;
  54510. readonly RG16I: number;
  54511. readonly RGB16I: number;
  54512. readonly RGBA16I: number;
  54513. readonly R16UI: number;
  54514. readonly RG16UI: number;
  54515. readonly RGB16UI: number;
  54516. readonly RGBA16UI: number;
  54517. readonly R32I: number;
  54518. readonly RG32I: number;
  54519. readonly RGB32I: number;
  54520. readonly RGBA32I: number;
  54521. readonly R32UI: number;
  54522. readonly RG32UI: number;
  54523. readonly RGB32UI: number;
  54524. readonly RGBA32UI: number;
  54525. readonly RGB10_A2UI: number;
  54526. readonly R11F_G11F_B10F: number;
  54527. readonly RGB9_E5: number;
  54528. readonly RGB10_A2: number;
  54529. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  54530. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  54531. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  54532. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  54533. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  54534. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  54535. 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;
  54536. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  54537. readonly TRANSFORM_FEEDBACK: number;
  54538. readonly INTERLEAVED_ATTRIBS: number;
  54539. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  54540. createTransformFeedback(): WebGLTransformFeedback;
  54541. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  54542. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  54543. beginTransformFeedback(primitiveMode: number): void;
  54544. endTransformFeedback(): void;
  54545. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  54546. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54547. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54548. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54549. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  54550. }
  54551. interface ImageBitmap {
  54552. readonly width: number;
  54553. readonly height: number;
  54554. close(): void;
  54555. }
  54556. interface WebGLQuery extends WebGLObject {
  54557. }
  54558. declare var WebGLQuery: {
  54559. prototype: WebGLQuery;
  54560. new (): WebGLQuery;
  54561. };
  54562. interface WebGLSampler extends WebGLObject {
  54563. }
  54564. declare var WebGLSampler: {
  54565. prototype: WebGLSampler;
  54566. new (): WebGLSampler;
  54567. };
  54568. interface WebGLSync extends WebGLObject {
  54569. }
  54570. declare var WebGLSync: {
  54571. prototype: WebGLSync;
  54572. new (): WebGLSync;
  54573. };
  54574. interface WebGLTransformFeedback extends WebGLObject {
  54575. }
  54576. declare var WebGLTransformFeedback: {
  54577. prototype: WebGLTransformFeedback;
  54578. new (): WebGLTransformFeedback;
  54579. };
  54580. interface WebGLVertexArrayObject extends WebGLObject {
  54581. }
  54582. declare var WebGLVertexArrayObject: {
  54583. prototype: WebGLVertexArrayObject;
  54584. new (): WebGLVertexArrayObject;
  54585. };
  54586. declare module "babylonjs/Legacy/legacy" {
  54587. export * from "babylonjs/index";
  54588. }
  54589. declare module "babylonjs/Shaders/blur.fragment" {
  54590. export var blurPixelShader: {
  54591. name: string;
  54592. shader: string;
  54593. };
  54594. }
  54595. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  54596. export var bones300Declaration: {
  54597. name: string;
  54598. shader: string;
  54599. };
  54600. }
  54601. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  54602. export var instances300Declaration: {
  54603. name: string;
  54604. shader: string;
  54605. };
  54606. }
  54607. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  54608. export var pointCloudVertexDeclaration: {
  54609. name: string;
  54610. shader: string;
  54611. };
  54612. }
  54613. declare module "babylonjs/Shaders/ShadersInclude/index" {
  54614. export * from "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54615. export * from "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54616. export * from "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54617. export * from "babylonjs/Shaders/ShadersInclude/bones300Declaration";
  54618. export * from "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54619. export * from "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54620. export * from "babylonjs/Shaders/ShadersInclude/bumpFragment";
  54621. export * from "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  54622. export * from "babylonjs/Shaders/ShadersInclude/bumpVertex";
  54623. export * from "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  54624. export * from "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54625. export * from "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54626. export * from "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  54627. export * from "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54628. export * from "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54629. export * from "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  54630. export * from "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  54631. export * from "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  54632. export * from "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  54633. export * from "babylonjs/Shaders/ShadersInclude/depthPrePass";
  54634. export * from "babylonjs/Shaders/ShadersInclude/fogFragment";
  54635. export * from "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54636. export * from "babylonjs/Shaders/ShadersInclude/fogVertex";
  54637. export * from "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54638. export * from "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  54639. export * from "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  54640. export * from "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54641. export * from "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54642. export * from "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54643. export * from "babylonjs/Shaders/ShadersInclude/instances300Declaration";
  54644. export * from "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54645. export * from "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54646. export * from "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  54647. export * from "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  54648. export * from "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  54649. export * from "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  54650. export * from "babylonjs/Shaders/ShadersInclude/lightFragment";
  54651. export * from "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54652. export * from "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54653. export * from "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54654. export * from "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54655. export * from "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54656. export * from "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54657. export * from "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54658. export * from "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54659. export * from "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54660. export * from "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54661. export * from "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  54662. export * from "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  54663. export * from "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  54664. export * from "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  54665. export * from "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  54666. export * from "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  54667. export * from "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration";
  54668. export * from "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54669. export * from "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54670. export * from "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54671. }
  54672. declare module "babylonjs/Shaders/index" {
  54673. export * from "babylonjs/Shaders/anaglyph.fragment";
  54674. export * from "babylonjs/Shaders/background.fragment";
  54675. export * from "babylonjs/Shaders/background.vertex";
  54676. export * from "babylonjs/Shaders/blackAndWhite.fragment";
  54677. export * from "babylonjs/Shaders/bloomMerge.fragment";
  54678. export * from "babylonjs/Shaders/blur.fragment";
  54679. export * from "babylonjs/Shaders/chromaticAberration.fragment";
  54680. export * from "babylonjs/Shaders/circleOfConfusion.fragment";
  54681. export * from "babylonjs/Shaders/color.fragment";
  54682. export * from "babylonjs/Shaders/color.vertex";
  54683. export * from "babylonjs/Shaders/colorCorrection.fragment";
  54684. export * from "babylonjs/Shaders/convolution.fragment";
  54685. export * from "babylonjs/Shaders/default.fragment";
  54686. export * from "babylonjs/Shaders/default.vertex";
  54687. export * from "babylonjs/Shaders/depth.fragment";
  54688. export * from "babylonjs/Shaders/depth.vertex";
  54689. export * from "babylonjs/Shaders/depthBoxBlur.fragment";
  54690. export * from "babylonjs/Shaders/depthOfField.fragment";
  54691. export * from "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54692. export * from "babylonjs/Shaders/displayPass.fragment";
  54693. export * from "babylonjs/Shaders/extractHighlights.fragment";
  54694. export * from "babylonjs/Shaders/filter.fragment";
  54695. export * from "babylonjs/Shaders/fxaa.fragment";
  54696. export * from "babylonjs/Shaders/fxaa.vertex";
  54697. export * from "babylonjs/Shaders/geometry.fragment";
  54698. export * from "babylonjs/Shaders/geometry.vertex";
  54699. export * from "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54700. export * from "babylonjs/Shaders/glowMapGeneration.fragment";
  54701. export * from "babylonjs/Shaders/glowMapGeneration.vertex";
  54702. export * from "babylonjs/Shaders/glowMapMerge.fragment";
  54703. export * from "babylonjs/Shaders/glowMapMerge.vertex";
  54704. export * from "babylonjs/Shaders/gpuRenderParticles.fragment";
  54705. export * from "babylonjs/Shaders/gpuRenderParticles.vertex";
  54706. export * from "babylonjs/Shaders/gpuUpdateParticles.fragment";
  54707. export * from "babylonjs/Shaders/gpuUpdateParticles.vertex";
  54708. export * from "babylonjs/Shaders/grain.fragment";
  54709. export * from "babylonjs/Shaders/highlights.fragment";
  54710. export * from "babylonjs/Shaders/imageProcessing.fragment";
  54711. export * from "babylonjs/Shaders/kernelBlur.fragment";
  54712. export * from "babylonjs/Shaders/kernelBlur.vertex";
  54713. export * from "babylonjs/Shaders/layer.fragment";
  54714. export * from "babylonjs/Shaders/layer.vertex";
  54715. export * from "babylonjs/Shaders/lensFlare.fragment";
  54716. export * from "babylonjs/Shaders/lensFlare.vertex";
  54717. export * from "babylonjs/Shaders/lensHighlights.fragment";
  54718. export * from "babylonjs/Shaders/line.fragment";
  54719. export * from "babylonjs/Shaders/line.vertex";
  54720. export * from "babylonjs/Shaders/motionBlur.fragment";
  54721. export * from "babylonjs/Shaders/noise.fragment";
  54722. export * from "babylonjs/Shaders/outline.fragment";
  54723. export * from "babylonjs/Shaders/outline.vertex";
  54724. export * from "babylonjs/Shaders/particles.fragment";
  54725. export * from "babylonjs/Shaders/particles.vertex";
  54726. export * from "babylonjs/Shaders/pass.fragment";
  54727. export * from "babylonjs/Shaders/pbr.fragment";
  54728. export * from "babylonjs/Shaders/pbr.vertex";
  54729. export * from "babylonjs/Shaders/postprocess.vertex";
  54730. export * from "babylonjs/Shaders/procedural.vertex";
  54731. export * from "babylonjs/Shaders/refraction.fragment";
  54732. export * from "babylonjs/Shaders/rgbdDecode.fragment";
  54733. export * from "babylonjs/Shaders/rgbdEncode.fragment";
  54734. export * from "babylonjs/Shaders/ShadersInclude/index";
  54735. export * from "babylonjs/Shaders/shadowMap.fragment";
  54736. export * from "babylonjs/Shaders/shadowMap.vertex";
  54737. export * from "babylonjs/Shaders/sharpen.fragment";
  54738. export * from "babylonjs/Shaders/sprites.fragment";
  54739. export * from "babylonjs/Shaders/sprites.vertex";
  54740. export * from "babylonjs/Shaders/ssao.fragment";
  54741. export * from "babylonjs/Shaders/ssao2.fragment";
  54742. export * from "babylonjs/Shaders/ssaoCombine.fragment";
  54743. export * from "babylonjs/Shaders/standard.fragment";
  54744. export * from "babylonjs/Shaders/stereoscopicInterlace.fragment";
  54745. export * from "babylonjs/Shaders/tonemap.fragment";
  54746. export * from "babylonjs/Shaders/volumetricLightScattering.fragment";
  54747. export * from "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54748. export * from "babylonjs/Shaders/vrDistortionCorrection.fragment";
  54749. }
  54750. declare module "babylonjs" {
  54751. export * from "babylonjs/Legacy/legacy";
  54752. }