babylon.module.d.ts 2.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module "babylonjs/Offline/IOfflineProvider" {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module "babylonjs/Misc/observable" {
  4199. import { Nullable } from "babylonjs/types";
  4200. /**
  4201. * A class serves as a medium between the observable and its observers
  4202. */
  4203. export class EventState {
  4204. /**
  4205. * Create a new EventState
  4206. * @param mask defines the mask associated with this state
  4207. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4208. * @param target defines the original target of the state
  4209. * @param currentTarget defines the current target of the state
  4210. */
  4211. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4212. /**
  4213. * Initialize the current event state
  4214. * @param mask defines the mask associated with this state
  4215. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4216. * @param target defines the original target of the state
  4217. * @param currentTarget defines the current target of the state
  4218. * @returns the current event state
  4219. */
  4220. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4221. /**
  4222. * An Observer can set this property to true to prevent subsequent observers of being notified
  4223. */
  4224. skipNextObservers: boolean;
  4225. /**
  4226. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4227. */
  4228. mask: number;
  4229. /**
  4230. * The object that originally notified the event
  4231. */
  4232. target?: any;
  4233. /**
  4234. * The current object in the bubbling phase
  4235. */
  4236. currentTarget?: any;
  4237. /**
  4238. * This will be populated with the return value of the last function that was executed.
  4239. * If it is the first function in the callback chain it will be the event data.
  4240. */
  4241. lastReturnValue?: any;
  4242. }
  4243. /**
  4244. * Represent an Observer registered to a given Observable object.
  4245. */
  4246. export class Observer<T> {
  4247. /**
  4248. * Defines the callback to call when the observer is notified
  4249. */
  4250. callback: (eventData: T, eventState: EventState) => void;
  4251. /**
  4252. * Defines the mask of the observer (used to filter notifications)
  4253. */
  4254. mask: number;
  4255. /**
  4256. * Defines the current scope used to restore the JS context
  4257. */
  4258. scope: any;
  4259. /** @hidden */
  4260. _willBeUnregistered: boolean;
  4261. /**
  4262. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4263. */
  4264. unregisterOnNextCall: boolean;
  4265. /**
  4266. * Creates a new observer
  4267. * @param callback defines the callback to call when the observer is notified
  4268. * @param mask defines the mask of the observer (used to filter notifications)
  4269. * @param scope defines the current scope used to restore the JS context
  4270. */
  4271. constructor(
  4272. /**
  4273. * Defines the callback to call when the observer is notified
  4274. */
  4275. callback: (eventData: T, eventState: EventState) => void,
  4276. /**
  4277. * Defines the mask of the observer (used to filter notifications)
  4278. */
  4279. mask: number,
  4280. /**
  4281. * Defines the current scope used to restore the JS context
  4282. */
  4283. scope?: any);
  4284. }
  4285. /**
  4286. * Represent a list of observers registered to multiple Observables object.
  4287. */
  4288. export class MultiObserver<T> {
  4289. private _observers;
  4290. private _observables;
  4291. /**
  4292. * Release associated resources
  4293. */
  4294. dispose(): void;
  4295. /**
  4296. * Raise a callback when one of the observable will notify
  4297. * @param observables defines a list of observables to watch
  4298. * @param callback defines the callback to call on notification
  4299. * @param mask defines the mask used to filter notifications
  4300. * @param scope defines the current scope used to restore the JS context
  4301. * @returns the new MultiObserver
  4302. */
  4303. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4304. }
  4305. /**
  4306. * The Observable class is a simple implementation of the Observable pattern.
  4307. *
  4308. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4309. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4310. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4311. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4312. */
  4313. export class Observable<T> {
  4314. private _observers;
  4315. private _eventState;
  4316. private _onObserverAdded;
  4317. /**
  4318. * Creates a new observable
  4319. * @param onObserverAdded defines a callback to call when a new observer is added
  4320. */
  4321. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4322. /**
  4323. * Create a new Observer with the specified callback
  4324. * @param callback the callback that will be executed for that Observer
  4325. * @param mask the mask used to filter observers
  4326. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4327. * @param scope optional scope for the callback to be called from
  4328. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4329. * @returns the new observer created for the callback
  4330. */
  4331. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4332. /**
  4333. * Create a new Observer with the specified callback and unregisters after the next notification
  4334. * @param callback the callback that will be executed for that Observer
  4335. * @returns the new observer created for the callback
  4336. */
  4337. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4338. /**
  4339. * Remove an Observer from the Observable object
  4340. * @param observer the instance of the Observer to remove
  4341. * @returns false if it doesn't belong to this Observable
  4342. */
  4343. remove(observer: Nullable<Observer<T>>): boolean;
  4344. /**
  4345. * Remove a callback from the Observable object
  4346. * @param callback the callback to remove
  4347. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4348. * @returns false if it doesn't belong to this Observable
  4349. */
  4350. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4351. private _deferUnregister;
  4352. private _remove;
  4353. /**
  4354. * Notify all Observers by calling their respective callback with the given data
  4355. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4356. * @param eventData defines the data to send to all observers
  4357. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4358. * @param target defines the original target of the state
  4359. * @param currentTarget defines the current target of the state
  4360. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4361. */
  4362. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4363. /**
  4364. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4365. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4366. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4367. * and it is crucial that all callbacks will be executed.
  4368. * The order of the callbacks is kept, callbacks are not executed parallel.
  4369. *
  4370. * @param eventData The data to be sent to each callback
  4371. * @param mask is used to filter observers defaults to -1
  4372. * @param target defines the callback target (see EventState)
  4373. * @param currentTarget defines he current object in the bubbling phase
  4374. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4375. */
  4376. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4377. /**
  4378. * Notify a specific observer
  4379. * @param observer defines the observer to notify
  4380. * @param eventData defines the data to be sent to each callback
  4381. * @param mask is used to filter observers defaults to -1
  4382. */
  4383. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4384. /**
  4385. * Gets a boolean indicating if the observable has at least one observer
  4386. * @returns true is the Observable has at least one Observer registered
  4387. */
  4388. hasObservers(): boolean;
  4389. /**
  4390. * Clear the list of observers
  4391. */
  4392. clear(): void;
  4393. /**
  4394. * Clone the current observable
  4395. * @returns a new observable
  4396. */
  4397. clone(): Observable<T>;
  4398. /**
  4399. * Does this observable handles observer registered with a given mask
  4400. * @param mask defines the mask to be tested
  4401. * @return whether or not one observer registered with the given mask is handeled
  4402. **/
  4403. hasSpecificMask(mask?: number): boolean;
  4404. }
  4405. }
  4406. declare module "babylonjs/Misc/filesInputStore" {
  4407. /**
  4408. * Class used to help managing file picking and drag'n'drop
  4409. * File Storage
  4410. */
  4411. export class FilesInputStore {
  4412. /**
  4413. * List of files ready to be loaded
  4414. */
  4415. static FilesToLoad: {
  4416. [key: string]: File;
  4417. };
  4418. }
  4419. }
  4420. declare module "babylonjs/Engines/constants" {
  4421. /** Defines the cross module used constants to avoid circular dependncies */
  4422. export class Constants {
  4423. /** Defines that alpha blending is disabled */
  4424. static readonly ALPHA_DISABLE: number;
  4425. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4426. static readonly ALPHA_ADD: number;
  4427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4428. static readonly ALPHA_COMBINE: number;
  4429. /** Defines that alpha blending to DEST - SRC * DEST */
  4430. static readonly ALPHA_SUBTRACT: number;
  4431. /** Defines that alpha blending to SRC * DEST */
  4432. static readonly ALPHA_MULTIPLY: number;
  4433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4434. static readonly ALPHA_MAXIMIZED: number;
  4435. /** Defines that alpha blending to SRC + DEST */
  4436. static readonly ALPHA_ONEONE: number;
  4437. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4438. static readonly ALPHA_PREMULTIPLIED: number;
  4439. /**
  4440. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4441. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4442. */
  4443. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4444. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4445. static readonly ALPHA_INTERPOLATE: number;
  4446. /**
  4447. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4448. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4449. */
  4450. static readonly ALPHA_SCREENMODE: number;
  4451. /** Defines that the ressource is not delayed*/
  4452. static readonly DELAYLOADSTATE_NONE: number;
  4453. /** Defines that the ressource was successfully delay loaded */
  4454. static readonly DELAYLOADSTATE_LOADED: number;
  4455. /** Defines that the ressource is currently delay loading */
  4456. static readonly DELAYLOADSTATE_LOADING: number;
  4457. /** Defines that the ressource is delayed and has not started loading */
  4458. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4460. static readonly NEVER: number;
  4461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4462. static readonly ALWAYS: number;
  4463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4464. static readonly LESS: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4466. static readonly EQUAL: number;
  4467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4468. static readonly LEQUAL: number;
  4469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4470. static readonly GREATER: number;
  4471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4472. static readonly GEQUAL: number;
  4473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4474. static readonly NOTEQUAL: number;
  4475. /** Passed to stencilOperation to specify that stencil value must be kept */
  4476. static readonly KEEP: number;
  4477. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4478. static readonly REPLACE: number;
  4479. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4480. static readonly INCR: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4482. static readonly DECR: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4484. static readonly INVERT: number;
  4485. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4486. static readonly INCR_WRAP: number;
  4487. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4488. static readonly DECR_WRAP: number;
  4489. /** Texture is not repeating outside of 0..1 UVs */
  4490. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4491. /** Texture is repeating outside of 0..1 UVs */
  4492. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4493. /** Texture is repeating and mirrored */
  4494. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4495. /** ALPHA */
  4496. static readonly TEXTUREFORMAT_ALPHA: number;
  4497. /** LUMINANCE */
  4498. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4499. /** LUMINANCE_ALPHA */
  4500. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4501. /** RGB */
  4502. static readonly TEXTUREFORMAT_RGB: number;
  4503. /** RGBA */
  4504. static readonly TEXTUREFORMAT_RGBA: number;
  4505. /** RED */
  4506. static readonly TEXTUREFORMAT_RED: number;
  4507. /** RED (2nd reference) */
  4508. static readonly TEXTUREFORMAT_R: number;
  4509. /** RG */
  4510. static readonly TEXTUREFORMAT_RG: number;
  4511. /** RED_INTEGER */
  4512. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4513. /** RED_INTEGER (2nd reference) */
  4514. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4515. /** RG_INTEGER */
  4516. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4517. /** RGB_INTEGER */
  4518. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4519. /** RGBA_INTEGER */
  4520. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4521. /** UNSIGNED_BYTE */
  4522. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4523. /** UNSIGNED_BYTE (2nd reference) */
  4524. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4525. /** FLOAT */
  4526. static readonly TEXTURETYPE_FLOAT: number;
  4527. /** HALF_FLOAT */
  4528. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4529. /** BYTE */
  4530. static readonly TEXTURETYPE_BYTE: number;
  4531. /** SHORT */
  4532. static readonly TEXTURETYPE_SHORT: number;
  4533. /** UNSIGNED_SHORT */
  4534. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4535. /** INT */
  4536. static readonly TEXTURETYPE_INT: number;
  4537. /** UNSIGNED_INT */
  4538. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4539. /** UNSIGNED_SHORT_4_4_4_4 */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4541. /** UNSIGNED_SHORT_5_5_5_1 */
  4542. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4543. /** UNSIGNED_SHORT_5_6_5 */
  4544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4545. /** UNSIGNED_INT_2_10_10_10_REV */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4547. /** UNSIGNED_INT_24_8 */
  4548. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4549. /** UNSIGNED_INT_10F_11F_11F_REV */
  4550. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4551. /** UNSIGNED_INT_5_9_9_9_REV */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4553. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4554. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4555. /** nearest is mag = nearest and min = nearest and mip = linear */
  4556. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4558. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4559. /** Trilinear is mag = linear and min = linear and mip = linear */
  4560. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4561. /** nearest is mag = nearest and min = nearest and mip = linear */
  4562. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4564. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4565. /** Trilinear is mag = linear and min = linear and mip = linear */
  4566. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4567. /** mag = nearest and min = nearest and mip = nearest */
  4568. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4569. /** mag = nearest and min = linear and mip = nearest */
  4570. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4571. /** mag = nearest and min = linear and mip = linear */
  4572. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4573. /** mag = nearest and min = linear and mip = none */
  4574. static readonly TEXTURE_NEAREST_LINEAR: number;
  4575. /** mag = nearest and min = nearest and mip = none */
  4576. static readonly TEXTURE_NEAREST_NEAREST: number;
  4577. /** mag = linear and min = nearest and mip = nearest */
  4578. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4579. /** mag = linear and min = nearest and mip = linear */
  4580. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4581. /** mag = linear and min = linear and mip = none */
  4582. static readonly TEXTURE_LINEAR_LINEAR: number;
  4583. /** mag = linear and min = nearest and mip = none */
  4584. static readonly TEXTURE_LINEAR_NEAREST: number;
  4585. /** Explicit coordinates mode */
  4586. static readonly TEXTURE_EXPLICIT_MODE: number;
  4587. /** Spherical coordinates mode */
  4588. static readonly TEXTURE_SPHERICAL_MODE: number;
  4589. /** Planar coordinates mode */
  4590. static readonly TEXTURE_PLANAR_MODE: number;
  4591. /** Cubic coordinates mode */
  4592. static readonly TEXTURE_CUBIC_MODE: number;
  4593. /** Projection coordinates mode */
  4594. static readonly TEXTURE_PROJECTION_MODE: number;
  4595. /** Skybox coordinates mode */
  4596. static readonly TEXTURE_SKYBOX_MODE: number;
  4597. /** Inverse Cubic coordinates mode */
  4598. static readonly TEXTURE_INVCUBIC_MODE: number;
  4599. /** Equirectangular coordinates mode */
  4600. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4601. /** Equirectangular Fixed coordinates mode */
  4602. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4603. /** Equirectangular Fixed Mirrored coordinates mode */
  4604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4605. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4606. static readonly SCALEMODE_FLOOR: number;
  4607. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4608. static readonly SCALEMODE_NEAREST: number;
  4609. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4610. static readonly SCALEMODE_CEILING: number;
  4611. /**
  4612. * The dirty texture flag value
  4613. */
  4614. static readonly MATERIAL_TextureDirtyFlag: number;
  4615. /**
  4616. * The dirty light flag value
  4617. */
  4618. static readonly MATERIAL_LightDirtyFlag: number;
  4619. /**
  4620. * The dirty fresnel flag value
  4621. */
  4622. static readonly MATERIAL_FresnelDirtyFlag: number;
  4623. /**
  4624. * The dirty attribute flag value
  4625. */
  4626. static readonly MATERIAL_AttributesDirtyFlag: number;
  4627. /**
  4628. * The dirty misc flag value
  4629. */
  4630. static readonly MATERIAL_MiscDirtyFlag: number;
  4631. /**
  4632. * The all dirty flag value
  4633. */
  4634. static readonly MATERIAL_AllDirtyFlag: number;
  4635. /**
  4636. * Returns the triangle fill mode
  4637. */
  4638. static readonly MATERIAL_TriangleFillMode: number;
  4639. /**
  4640. * Returns the wireframe mode
  4641. */
  4642. static readonly MATERIAL_WireFrameFillMode: number;
  4643. /**
  4644. * Returns the point fill mode
  4645. */
  4646. static readonly MATERIAL_PointFillMode: number;
  4647. /**
  4648. * Returns the point list draw mode
  4649. */
  4650. static readonly MATERIAL_PointListDrawMode: number;
  4651. /**
  4652. * Returns the line list draw mode
  4653. */
  4654. static readonly MATERIAL_LineListDrawMode: number;
  4655. /**
  4656. * Returns the line loop draw mode
  4657. */
  4658. static readonly MATERIAL_LineLoopDrawMode: number;
  4659. /**
  4660. * Returns the line strip draw mode
  4661. */
  4662. static readonly MATERIAL_LineStripDrawMode: number;
  4663. /**
  4664. * Returns the triangle strip draw mode
  4665. */
  4666. static readonly MATERIAL_TriangleStripDrawMode: number;
  4667. /**
  4668. * Returns the triangle fan draw mode
  4669. */
  4670. static readonly MATERIAL_TriangleFanDrawMode: number;
  4671. /**
  4672. * Stores the clock-wise side orientation
  4673. */
  4674. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4675. /**
  4676. * Stores the counter clock-wise side orientation
  4677. */
  4678. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4679. /**
  4680. * Nothing
  4681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4682. */
  4683. static readonly ACTION_NothingTrigger: number;
  4684. /**
  4685. * On pick
  4686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4687. */
  4688. static readonly ACTION_OnPickTrigger: number;
  4689. /**
  4690. * On left pick
  4691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4692. */
  4693. static readonly ACTION_OnLeftPickTrigger: number;
  4694. /**
  4695. * On right pick
  4696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4697. */
  4698. static readonly ACTION_OnRightPickTrigger: number;
  4699. /**
  4700. * On center pick
  4701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4702. */
  4703. static readonly ACTION_OnCenterPickTrigger: number;
  4704. /**
  4705. * On pick down
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_OnPickDownTrigger: number;
  4709. /**
  4710. * On double pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnDoublePickTrigger: number;
  4714. /**
  4715. * On pick up
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnPickUpTrigger: number;
  4719. /**
  4720. * On pick out.
  4721. * This trigger will only be raised if you also declared a OnPickDown
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnPickOutTrigger: number;
  4725. /**
  4726. * On long press
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnLongPressTrigger: number;
  4730. /**
  4731. * On pointer over
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_OnPointerOverTrigger: number;
  4735. /**
  4736. * On pointer out
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPointerOutTrigger: number;
  4740. /**
  4741. * On every frame
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnEveryFrameTrigger: number;
  4745. /**
  4746. * On intersection enter
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4750. /**
  4751. * On intersection exit
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnIntersectionExitTrigger: number;
  4755. /**
  4756. * On key down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnKeyDownTrigger: number;
  4760. /**
  4761. * On key up
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnKeyUpTrigger: number;
  4765. /**
  4766. * Billboard mode will only apply to Y axis
  4767. */
  4768. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4769. /**
  4770. * Billboard mode will apply to all axes
  4771. */
  4772. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4773. /**
  4774. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4775. */
  4776. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4777. /**
  4778. * Gets or sets base Assets URL
  4779. */
  4780. static readonly PARTICLES_BaseAssetsUrl: string;
  4781. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4782. * Test order :
  4783. * Is the bounding sphere outside the frustum ?
  4784. * If not, are the bounding box vertices outside the frustum ?
  4785. * It not, then the cullable object is in the frustum.
  4786. */
  4787. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4788. /** Culling strategy : Bounding Sphere Only.
  4789. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4790. * It's also less accurate than the standard because some not visible objects can still be selected.
  4791. * Test : is the bounding sphere outside the frustum ?
  4792. * If not, then the cullable object is in the frustum.
  4793. */
  4794. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4795. /** Culling strategy : Optimistic Inclusion.
  4796. * This in an inclusion test first, then the standard exclusion test.
  4797. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4798. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4799. * Anyway, it's as accurate as the standard strategy.
  4800. * Test :
  4801. * Is the cullable object bounding sphere center in the frustum ?
  4802. * If not, apply the default culling strategy.
  4803. */
  4804. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4805. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4806. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4807. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4808. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4809. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4810. * Test :
  4811. * Is the cullable object bounding sphere center in the frustum ?
  4812. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4813. */
  4814. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4815. /**
  4816. * No logging while loading
  4817. */
  4818. static readonly SCENELOADER_NO_LOGGING: number;
  4819. /**
  4820. * Minimal logging while loading
  4821. */
  4822. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4823. /**
  4824. * Summary logging while loading
  4825. */
  4826. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4827. /**
  4828. * Detailled logging while loading
  4829. */
  4830. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4831. }
  4832. }
  4833. declare module "babylonjs/Misc/domManagement" {
  4834. /**
  4835. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4836. * Babylon.js
  4837. */
  4838. export class DomManagement {
  4839. /**
  4840. * Checks if the window object exists
  4841. * @returns true if the window object exists
  4842. */
  4843. static IsWindowObjectExist(): boolean;
  4844. /**
  4845. * Extracts text content from a DOM element hierarchy
  4846. * @param element defines the root element
  4847. * @returns a string
  4848. */
  4849. static GetDOMTextContent(element: HTMLElement): string;
  4850. }
  4851. }
  4852. declare module "babylonjs/Misc/logger" {
  4853. /**
  4854. * Logger used througouht the application to allow configuration of
  4855. * the log level required for the messages.
  4856. */
  4857. export class Logger {
  4858. /**
  4859. * No log
  4860. */
  4861. static readonly NoneLogLevel: number;
  4862. /**
  4863. * Only message logs
  4864. */
  4865. static readonly MessageLogLevel: number;
  4866. /**
  4867. * Only warning logs
  4868. */
  4869. static readonly WarningLogLevel: number;
  4870. /**
  4871. * Only error logs
  4872. */
  4873. static readonly ErrorLogLevel: number;
  4874. /**
  4875. * All logs
  4876. */
  4877. static readonly AllLogLevel: number;
  4878. private static _LogCache;
  4879. /**
  4880. * Gets a value indicating the number of loading errors
  4881. * @ignorenaming
  4882. */
  4883. static errorsCount: number;
  4884. /**
  4885. * Callback called when a new log is added
  4886. */
  4887. static OnNewCacheEntry: (entry: string) => void;
  4888. private static _AddLogEntry;
  4889. private static _FormatMessage;
  4890. private static _LogDisabled;
  4891. private static _LogEnabled;
  4892. private static _WarnDisabled;
  4893. private static _WarnEnabled;
  4894. private static _ErrorDisabled;
  4895. private static _ErrorEnabled;
  4896. /**
  4897. * Log a message to the console
  4898. */
  4899. static Log: (message: string) => void;
  4900. /**
  4901. * Write a warning message to the console
  4902. */
  4903. static Warn: (message: string) => void;
  4904. /**
  4905. * Write an error message to the console
  4906. */
  4907. static Error: (message: string) => void;
  4908. /**
  4909. * Gets current log cache (list of logs)
  4910. */
  4911. static readonly LogCache: string;
  4912. /**
  4913. * Clears the log cache
  4914. */
  4915. static ClearLogCache(): void;
  4916. /**
  4917. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4918. */
  4919. static LogLevels: number;
  4920. }
  4921. }
  4922. declare module "babylonjs/Misc/typeStore" {
  4923. /** @hidden */
  4924. export class _TypeStore {
  4925. /** @hidden */
  4926. static RegisteredTypes: {
  4927. [key: string]: Object;
  4928. };
  4929. /** @hidden */
  4930. static GetClass(fqdn: string): any;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/deepCopier" {
  4934. /**
  4935. * Class containing a set of static utilities functions for deep copy.
  4936. */
  4937. export class DeepCopier {
  4938. /**
  4939. * Tries to copy an object by duplicating every property
  4940. * @param source defines the source object
  4941. * @param destination defines the target object
  4942. * @param doNotCopyList defines a list of properties to avoid
  4943. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4944. */
  4945. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4946. }
  4947. }
  4948. declare module "babylonjs/Misc/precisionDate" {
  4949. /**
  4950. * Class containing a set of static utilities functions for precision date
  4951. */
  4952. export class PrecisionDate {
  4953. /**
  4954. * Gets either window.performance.now() if supported or Date.now() else
  4955. */
  4956. static readonly Now: number;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4960. /**
  4961. * Class used to evalaute queries containing `and` and `or` operators
  4962. */
  4963. export class AndOrNotEvaluator {
  4964. /**
  4965. * Evaluate a query
  4966. * @param query defines the query to evaluate
  4967. * @param evaluateCallback defines the callback used to filter result
  4968. * @returns true if the query matches
  4969. */
  4970. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4971. private static _HandleParenthesisContent;
  4972. private static _SimplifyNegation;
  4973. }
  4974. }
  4975. declare module "babylonjs/Misc/tags" {
  4976. /**
  4977. * Class used to store custom tags
  4978. */
  4979. export class Tags {
  4980. /**
  4981. * Adds support for tags on the given object
  4982. * @param obj defines the object to use
  4983. */
  4984. static EnableFor(obj: any): void;
  4985. /**
  4986. * Removes tags support
  4987. * @param obj defines the object to use
  4988. */
  4989. static DisableFor(obj: any): void;
  4990. /**
  4991. * Gets a boolean indicating if the given object has tags
  4992. * @param obj defines the object to use
  4993. * @returns a boolean
  4994. */
  4995. static HasTags(obj: any): boolean;
  4996. /**
  4997. * Gets the tags available on a given object
  4998. * @param obj defines the object to use
  4999. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5000. * @returns the tags
  5001. */
  5002. static GetTags(obj: any, asString?: boolean): any;
  5003. /**
  5004. * Adds tags to an object
  5005. * @param obj defines the object to use
  5006. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5007. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5008. */
  5009. static AddTagsTo(obj: any, tagsString: string): void;
  5010. /**
  5011. * @hidden
  5012. */
  5013. static _AddTagTo(obj: any, tag: string): void;
  5014. /**
  5015. * Removes specific tags from a specific object
  5016. * @param obj defines the object to use
  5017. * @param tagsString defines the tags to remove
  5018. */
  5019. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5020. /**
  5021. * @hidden
  5022. */
  5023. static _RemoveTagFrom(obj: any, tag: string): void;
  5024. /**
  5025. * Defines if tags hosted on an object match a given query
  5026. * @param obj defines the object to use
  5027. * @param tagsQuery defines the tag query
  5028. * @returns a boolean
  5029. */
  5030. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5031. }
  5032. }
  5033. declare module "babylonjs/Materials/materialDefines" {
  5034. /**
  5035. * Manages the defines for the Material
  5036. */
  5037. export class MaterialDefines {
  5038. private _keys;
  5039. private _isDirty;
  5040. /** @hidden */
  5041. _renderId: number;
  5042. /** @hidden */
  5043. _areLightsDirty: boolean;
  5044. /** @hidden */
  5045. _areAttributesDirty: boolean;
  5046. /** @hidden */
  5047. _areTexturesDirty: boolean;
  5048. /** @hidden */
  5049. _areFresnelDirty: boolean;
  5050. /** @hidden */
  5051. _areMiscDirty: boolean;
  5052. /** @hidden */
  5053. _areImageProcessingDirty: boolean;
  5054. /** @hidden */
  5055. _normals: boolean;
  5056. /** @hidden */
  5057. _uvs: boolean;
  5058. /** @hidden */
  5059. _needNormals: boolean;
  5060. /** @hidden */
  5061. _needUVs: boolean;
  5062. /**
  5063. * Specifies if the material needs to be re-calculated
  5064. */
  5065. readonly isDirty: boolean;
  5066. /**
  5067. * Marks the material to indicate that it has been re-calculated
  5068. */
  5069. markAsProcessed(): void;
  5070. /**
  5071. * Marks the material to indicate that it needs to be re-calculated
  5072. */
  5073. markAsUnprocessed(): void;
  5074. /**
  5075. * Marks the material to indicate all of its defines need to be re-calculated
  5076. */
  5077. markAllAsDirty(): void;
  5078. /**
  5079. * Marks the material to indicate that image processing needs to be re-calculated
  5080. */
  5081. markAsImageProcessingDirty(): void;
  5082. /**
  5083. * Marks the material to indicate the lights need to be re-calculated
  5084. */
  5085. markAsLightDirty(): void;
  5086. /**
  5087. * Marks the attribute state as changed
  5088. */
  5089. markAsAttributesDirty(): void;
  5090. /**
  5091. * Marks the texture state as changed
  5092. */
  5093. markAsTexturesDirty(): void;
  5094. /**
  5095. * Marks the fresnel state as changed
  5096. */
  5097. markAsFresnelDirty(): void;
  5098. /**
  5099. * Marks the misc state as changed
  5100. */
  5101. markAsMiscDirty(): void;
  5102. /**
  5103. * Rebuilds the material defines
  5104. */
  5105. rebuild(): void;
  5106. /**
  5107. * Specifies if two material defines are equal
  5108. * @param other - A material define instance to compare to
  5109. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5110. */
  5111. isEqual(other: MaterialDefines): boolean;
  5112. /**
  5113. * Clones this instance's defines to another instance
  5114. * @param other - material defines to clone values to
  5115. */
  5116. cloneTo(other: MaterialDefines): void;
  5117. /**
  5118. * Resets the material define values
  5119. */
  5120. reset(): void;
  5121. /**
  5122. * Converts the material define values to a string
  5123. * @returns - String of material define information
  5124. */
  5125. toString(): string;
  5126. }
  5127. }
  5128. declare module "babylonjs/Misc/performanceMonitor" {
  5129. /**
  5130. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5131. */
  5132. export class PerformanceMonitor {
  5133. private _enabled;
  5134. private _rollingFrameTime;
  5135. private _lastFrameTimeMs;
  5136. /**
  5137. * constructor
  5138. * @param frameSampleSize The number of samples required to saturate the sliding window
  5139. */
  5140. constructor(frameSampleSize?: number);
  5141. /**
  5142. * Samples current frame
  5143. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5144. */
  5145. sampleFrame(timeMs?: number): void;
  5146. /**
  5147. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5148. */
  5149. readonly averageFrameTime: number;
  5150. /**
  5151. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5152. */
  5153. readonly averageFrameTimeVariance: number;
  5154. /**
  5155. * Returns the frame time of the most recent frame
  5156. */
  5157. readonly instantaneousFrameTime: number;
  5158. /**
  5159. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5160. */
  5161. readonly averageFPS: number;
  5162. /**
  5163. * Returns the average framerate in frames per second using the most recent frame time
  5164. */
  5165. readonly instantaneousFPS: number;
  5166. /**
  5167. * Returns true if enough samples have been taken to completely fill the sliding window
  5168. */
  5169. readonly isSaturated: boolean;
  5170. /**
  5171. * Enables contributions to the sliding window sample set
  5172. */
  5173. enable(): void;
  5174. /**
  5175. * Disables contributions to the sliding window sample set
  5176. * Samples will not be interpolated over the disabled period
  5177. */
  5178. disable(): void;
  5179. /**
  5180. * Returns true if sampling is enabled
  5181. */
  5182. readonly isEnabled: boolean;
  5183. /**
  5184. * Resets performance monitor
  5185. */
  5186. reset(): void;
  5187. }
  5188. /**
  5189. * RollingAverage
  5190. *
  5191. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5192. */
  5193. export class RollingAverage {
  5194. /**
  5195. * Current average
  5196. */
  5197. average: number;
  5198. /**
  5199. * Current variance
  5200. */
  5201. variance: number;
  5202. protected _samples: Array<number>;
  5203. protected _sampleCount: number;
  5204. protected _pos: number;
  5205. protected _m2: number;
  5206. /**
  5207. * constructor
  5208. * @param length The number of samples required to saturate the sliding window
  5209. */
  5210. constructor(length: number);
  5211. /**
  5212. * Adds a sample to the sample set
  5213. * @param v The sample value
  5214. */
  5215. add(v: number): void;
  5216. /**
  5217. * Returns previously added values or null if outside of history or outside the sliding window domain
  5218. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5219. * @return Value previously recorded with add() or null if outside of range
  5220. */
  5221. history(i: number): number;
  5222. /**
  5223. * Returns true if enough samples have been taken to completely fill the sliding window
  5224. * @return true if sample-set saturated
  5225. */
  5226. isSaturated(): boolean;
  5227. /**
  5228. * Resets the rolling average (equivalent to 0 samples taken so far)
  5229. */
  5230. reset(): void;
  5231. /**
  5232. * Wraps a value around the sample range boundaries
  5233. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5234. * @return Wrapped position in sample range
  5235. */
  5236. protected _wrapPosition(i: number): number;
  5237. }
  5238. }
  5239. declare module "babylonjs/Misc/stringDictionary" {
  5240. import { Nullable } from "babylonjs/types";
  5241. /**
  5242. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5243. * The underlying implementation relies on an associative array to ensure the best performances.
  5244. * The value can be anything including 'null' but except 'undefined'
  5245. */
  5246. export class StringDictionary<T> {
  5247. /**
  5248. * This will clear this dictionary and copy the content from the 'source' one.
  5249. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5250. * @param source the dictionary to take the content from and copy to this dictionary
  5251. */
  5252. copyFrom(source: StringDictionary<T>): void;
  5253. /**
  5254. * Get a value based from its key
  5255. * @param key the given key to get the matching value from
  5256. * @return the value if found, otherwise undefined is returned
  5257. */
  5258. get(key: string): T | undefined;
  5259. /**
  5260. * Get a value from its key or add it if it doesn't exist.
  5261. * This method will ensure you that a given key/data will be present in the dictionary.
  5262. * @param key the given key to get the matching value from
  5263. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5264. * The factory will only be invoked if there's no data for the given key.
  5265. * @return the value corresponding to the key.
  5266. */
  5267. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5268. /**
  5269. * Get a value from its key if present in the dictionary otherwise add it
  5270. * @param key the key to get the value from
  5271. * @param val if there's no such key/value pair in the dictionary add it with this value
  5272. * @return the value corresponding to the key
  5273. */
  5274. getOrAdd(key: string, val: T): T;
  5275. /**
  5276. * Check if there's a given key in the dictionary
  5277. * @param key the key to check for
  5278. * @return true if the key is present, false otherwise
  5279. */
  5280. contains(key: string): boolean;
  5281. /**
  5282. * Add a new key and its corresponding value
  5283. * @param key the key to add
  5284. * @param value the value corresponding to the key
  5285. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5286. */
  5287. add(key: string, value: T): boolean;
  5288. /**
  5289. * Update a specific value associated to a key
  5290. * @param key defines the key to use
  5291. * @param value defines the value to store
  5292. * @returns true if the value was updated (or false if the key was not found)
  5293. */
  5294. set(key: string, value: T): boolean;
  5295. /**
  5296. * Get the element of the given key and remove it from the dictionary
  5297. * @param key defines the key to search
  5298. * @returns the value associated with the key or null if not found
  5299. */
  5300. getAndRemove(key: string): Nullable<T>;
  5301. /**
  5302. * Remove a key/value from the dictionary.
  5303. * @param key the key to remove
  5304. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5305. */
  5306. remove(key: string): boolean;
  5307. /**
  5308. * Clear the whole content of the dictionary
  5309. */
  5310. clear(): void;
  5311. /**
  5312. * Gets the current count
  5313. */
  5314. readonly count: number;
  5315. /**
  5316. * Execute a callback on each key/val of the dictionary.
  5317. * Note that you can remove any element in this dictionary in the callback implementation
  5318. * @param callback the callback to execute on a given key/value pair
  5319. */
  5320. forEach(callback: (key: string, val: T) => void): void;
  5321. /**
  5322. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5323. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5326. * @returns the first item
  5327. */
  5328. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5329. private _count;
  5330. private _data;
  5331. }
  5332. }
  5333. declare module "babylonjs/Misc/promise" {
  5334. /**
  5335. * Helper class that provides a small promise polyfill
  5336. */
  5337. export class PromisePolyfill {
  5338. /**
  5339. * Static function used to check if the polyfill is required
  5340. * If this is the case then the function will inject the polyfill to window.Promise
  5341. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5342. */
  5343. static Apply(force?: boolean): void;
  5344. }
  5345. }
  5346. declare module "babylonjs/Meshes/buffer" {
  5347. import { Nullable, DataArray } from "babylonjs/types";
  5348. /**
  5349. * Class used to store data that will be store in GPU memory
  5350. */
  5351. export class Buffer {
  5352. private _engine;
  5353. private _buffer;
  5354. /** @hidden */
  5355. _data: Nullable<DataArray>;
  5356. private _updatable;
  5357. private _instanced;
  5358. /**
  5359. * Gets the byte stride.
  5360. */
  5361. readonly byteStride: number;
  5362. /**
  5363. * Constructor
  5364. * @param engine the engine
  5365. * @param data the data to use for this buffer
  5366. * @param updatable whether the data is updatable
  5367. * @param stride the stride (optional)
  5368. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5369. * @param instanced whether the buffer is instanced (optional)
  5370. * @param useBytes set to true if the stride in in bytes (optional)
  5371. */
  5372. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5373. /**
  5374. * Create a new VertexBuffer based on the current buffer
  5375. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5376. * @param offset defines offset in the buffer (0 by default)
  5377. * @param size defines the size in floats of attributes (position is 3 for instance)
  5378. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5379. * @param instanced defines if the vertex buffer contains indexed data
  5380. * @param useBytes defines if the offset and stride are in bytes
  5381. * @returns the new vertex buffer
  5382. */
  5383. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5384. /**
  5385. * Gets a boolean indicating if the Buffer is updatable?
  5386. * @returns true if the buffer is updatable
  5387. */
  5388. isUpdatable(): boolean;
  5389. /**
  5390. * Gets current buffer's data
  5391. * @returns a DataArray or null
  5392. */
  5393. getData(): Nullable<DataArray>;
  5394. /**
  5395. * Gets underlying native buffer
  5396. * @returns underlying native buffer
  5397. */
  5398. getBuffer(): Nullable<WebGLBuffer>;
  5399. /**
  5400. * Gets the stride in float32 units (i.e. byte stride / 4).
  5401. * May not be an integer if the byte stride is not divisible by 4.
  5402. * DEPRECATED. Use byteStride instead.
  5403. * @returns the stride in float32 units
  5404. */
  5405. getStrideSize(): number;
  5406. /**
  5407. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5408. * @param data defines the data to store
  5409. */
  5410. create(data?: Nullable<DataArray>): void;
  5411. /** @hidden */
  5412. _rebuild(): void;
  5413. /**
  5414. * Update current buffer data
  5415. * @param data defines the data to store
  5416. */
  5417. update(data: DataArray): void;
  5418. /**
  5419. * Updates the data directly.
  5420. * @param data the new data
  5421. * @param offset the new offset
  5422. * @param vertexCount the vertex count (optional)
  5423. * @param useBytes set to true if the offset is in bytes
  5424. */
  5425. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5426. /**
  5427. * Release all resources
  5428. */
  5429. dispose(): void;
  5430. }
  5431. /**
  5432. * Specialized buffer used to store vertex data
  5433. */
  5434. export class VertexBuffer {
  5435. /** @hidden */
  5436. _buffer: Buffer;
  5437. private _kind;
  5438. private _size;
  5439. private _ownsBuffer;
  5440. private _instanced;
  5441. private _instanceDivisor;
  5442. /**
  5443. * The byte type.
  5444. */
  5445. static readonly BYTE: number;
  5446. /**
  5447. * The unsigned byte type.
  5448. */
  5449. static readonly UNSIGNED_BYTE: number;
  5450. /**
  5451. * The short type.
  5452. */
  5453. static readonly SHORT: number;
  5454. /**
  5455. * The unsigned short type.
  5456. */
  5457. static readonly UNSIGNED_SHORT: number;
  5458. /**
  5459. * The integer type.
  5460. */
  5461. static readonly INT: number;
  5462. /**
  5463. * The unsigned integer type.
  5464. */
  5465. static readonly UNSIGNED_INT: number;
  5466. /**
  5467. * The float type.
  5468. */
  5469. static readonly FLOAT: number;
  5470. /**
  5471. * Gets or sets the instance divisor when in instanced mode
  5472. */
  5473. instanceDivisor: number;
  5474. /**
  5475. * Gets the byte stride.
  5476. */
  5477. readonly byteStride: number;
  5478. /**
  5479. * Gets the byte offset.
  5480. */
  5481. readonly byteOffset: number;
  5482. /**
  5483. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5484. */
  5485. readonly normalized: boolean;
  5486. /**
  5487. * Gets the data type of each component in the array.
  5488. */
  5489. readonly type: number;
  5490. /**
  5491. * Constructor
  5492. * @param engine the engine
  5493. * @param data the data to use for this vertex buffer
  5494. * @param kind the vertex buffer kind
  5495. * @param updatable whether the data is updatable
  5496. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5497. * @param stride the stride (optional)
  5498. * @param instanced whether the buffer is instanced (optional)
  5499. * @param offset the offset of the data (optional)
  5500. * @param size the number of components (optional)
  5501. * @param type the type of the component (optional)
  5502. * @param normalized whether the data contains normalized data (optional)
  5503. * @param useBytes set to true if stride and offset are in bytes (optional)
  5504. */
  5505. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5506. /** @hidden */
  5507. _rebuild(): void;
  5508. /**
  5509. * Returns the kind of the VertexBuffer (string)
  5510. * @returns a string
  5511. */
  5512. getKind(): string;
  5513. /**
  5514. * Gets a boolean indicating if the VertexBuffer is updatable?
  5515. * @returns true if the buffer is updatable
  5516. */
  5517. isUpdatable(): boolean;
  5518. /**
  5519. * Gets current buffer's data
  5520. * @returns a DataArray or null
  5521. */
  5522. getData(): Nullable<DataArray>;
  5523. /**
  5524. * Gets underlying native buffer
  5525. * @returns underlying native buffer
  5526. */
  5527. getBuffer(): Nullable<WebGLBuffer>;
  5528. /**
  5529. * Gets the stride in float32 units (i.e. byte stride / 4).
  5530. * May not be an integer if the byte stride is not divisible by 4.
  5531. * DEPRECATED. Use byteStride instead.
  5532. * @returns the stride in float32 units
  5533. */
  5534. getStrideSize(): number;
  5535. /**
  5536. * Returns the offset as a multiple of the type byte length.
  5537. * DEPRECATED. Use byteOffset instead.
  5538. * @returns the offset in bytes
  5539. */
  5540. getOffset(): number;
  5541. /**
  5542. * Returns the number of components per vertex attribute (integer)
  5543. * @returns the size in float
  5544. */
  5545. getSize(): number;
  5546. /**
  5547. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5548. * @returns true if this buffer is instanced
  5549. */
  5550. getIsInstanced(): boolean;
  5551. /**
  5552. * Returns the instancing divisor, zero for non-instanced (integer).
  5553. * @returns a number
  5554. */
  5555. getInstanceDivisor(): number;
  5556. /**
  5557. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5558. * @param data defines the data to store
  5559. */
  5560. create(data?: DataArray): void;
  5561. /**
  5562. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5563. * This function will create a new buffer if the current one is not updatable
  5564. * @param data defines the data to store
  5565. */
  5566. update(data: DataArray): void;
  5567. /**
  5568. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5569. * Returns the directly updated WebGLBuffer.
  5570. * @param data the new data
  5571. * @param offset the new offset
  5572. * @param useBytes set to true if the offset is in bytes
  5573. */
  5574. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5575. /**
  5576. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5577. */
  5578. dispose(): void;
  5579. /**
  5580. * Enumerates each value of this vertex buffer as numbers.
  5581. * @param count the number of values to enumerate
  5582. * @param callback the callback function called for each value
  5583. */
  5584. forEach(count: number, callback: (value: number, index: number) => void): void;
  5585. /**
  5586. * Positions
  5587. */
  5588. static readonly PositionKind: string;
  5589. /**
  5590. * Normals
  5591. */
  5592. static readonly NormalKind: string;
  5593. /**
  5594. * Tangents
  5595. */
  5596. static readonly TangentKind: string;
  5597. /**
  5598. * Texture coordinates
  5599. */
  5600. static readonly UVKind: string;
  5601. /**
  5602. * Texture coordinates 2
  5603. */
  5604. static readonly UV2Kind: string;
  5605. /**
  5606. * Texture coordinates 3
  5607. */
  5608. static readonly UV3Kind: string;
  5609. /**
  5610. * Texture coordinates 4
  5611. */
  5612. static readonly UV4Kind: string;
  5613. /**
  5614. * Texture coordinates 5
  5615. */
  5616. static readonly UV5Kind: string;
  5617. /**
  5618. * Texture coordinates 6
  5619. */
  5620. static readonly UV6Kind: string;
  5621. /**
  5622. * Colors
  5623. */
  5624. static readonly ColorKind: string;
  5625. /**
  5626. * Matrix indices (for bones)
  5627. */
  5628. static readonly MatricesIndicesKind: string;
  5629. /**
  5630. * Matrix weights (for bones)
  5631. */
  5632. static readonly MatricesWeightsKind: string;
  5633. /**
  5634. * Additional matrix indices (for bones)
  5635. */
  5636. static readonly MatricesIndicesExtraKind: string;
  5637. /**
  5638. * Additional matrix weights (for bones)
  5639. */
  5640. static readonly MatricesWeightsExtraKind: string;
  5641. /**
  5642. * Deduces the stride given a kind.
  5643. * @param kind The kind string to deduce
  5644. * @returns The deduced stride
  5645. */
  5646. static DeduceStride(kind: string): number;
  5647. /**
  5648. * Gets the byte length of the given type.
  5649. * @param type the type
  5650. * @returns the number of bytes
  5651. */
  5652. static GetTypeByteLength(type: number): number;
  5653. /**
  5654. * Enumerates each value of the given parameters as numbers.
  5655. * @param data the data to enumerate
  5656. * @param byteOffset the byte offset of the data
  5657. * @param byteStride the byte stride of the data
  5658. * @param componentCount the number of components per element
  5659. * @param componentType the type of the component
  5660. * @param count the total number of components
  5661. * @param normalized whether the data is normalized
  5662. * @param callback the callback function called for each value
  5663. */
  5664. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5665. private static _GetFloatValue;
  5666. }
  5667. }
  5668. declare module "babylonjs/Maths/sphericalPolynomial" {
  5669. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5670. /**
  5671. * Class representing spherical polynomial coefficients to the 3rd degree
  5672. */
  5673. export class SphericalPolynomial {
  5674. /**
  5675. * The x coefficients of the spherical polynomial
  5676. */
  5677. x: Vector3;
  5678. /**
  5679. * The y coefficients of the spherical polynomial
  5680. */
  5681. y: Vector3;
  5682. /**
  5683. * The z coefficients of the spherical polynomial
  5684. */
  5685. z: Vector3;
  5686. /**
  5687. * The xx coefficients of the spherical polynomial
  5688. */
  5689. xx: Vector3;
  5690. /**
  5691. * The yy coefficients of the spherical polynomial
  5692. */
  5693. yy: Vector3;
  5694. /**
  5695. * The zz coefficients of the spherical polynomial
  5696. */
  5697. zz: Vector3;
  5698. /**
  5699. * The xy coefficients of the spherical polynomial
  5700. */
  5701. xy: Vector3;
  5702. /**
  5703. * The yz coefficients of the spherical polynomial
  5704. */
  5705. yz: Vector3;
  5706. /**
  5707. * The zx coefficients of the spherical polynomial
  5708. */
  5709. zx: Vector3;
  5710. /**
  5711. * Adds an ambient color to the spherical polynomial
  5712. * @param color the color to add
  5713. */
  5714. addAmbient(color: Color3): void;
  5715. /**
  5716. * Scales the spherical polynomial by the given amount
  5717. * @param scale the amount to scale
  5718. */
  5719. scale(scale: number): void;
  5720. /**
  5721. * Gets the spherical polynomial from harmonics
  5722. * @param harmonics the spherical harmonics
  5723. * @returns the spherical polynomial
  5724. */
  5725. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5726. /**
  5727. * Constructs a spherical polynomial from an array.
  5728. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5729. * @returns the spherical polynomial
  5730. */
  5731. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5732. }
  5733. /**
  5734. * Class representing spherical harmonics coefficients to the 3rd degree
  5735. */
  5736. export class SphericalHarmonics {
  5737. /**
  5738. * The l0,0 coefficients of the spherical harmonics
  5739. */
  5740. l00: Vector3;
  5741. /**
  5742. * The l1,-1 coefficients of the spherical harmonics
  5743. */
  5744. l1_1: Vector3;
  5745. /**
  5746. * The l1,0 coefficients of the spherical harmonics
  5747. */
  5748. l10: Vector3;
  5749. /**
  5750. * The l1,1 coefficients of the spherical harmonics
  5751. */
  5752. l11: Vector3;
  5753. /**
  5754. * The l2,-2 coefficients of the spherical harmonics
  5755. */
  5756. l2_2: Vector3;
  5757. /**
  5758. * The l2,-1 coefficients of the spherical harmonics
  5759. */
  5760. l2_1: Vector3;
  5761. /**
  5762. * The l2,0 coefficients of the spherical harmonics
  5763. */
  5764. l20: Vector3;
  5765. /**
  5766. * The l2,1 coefficients of the spherical harmonics
  5767. */
  5768. l21: Vector3;
  5769. /**
  5770. * The l2,2 coefficients of the spherical harmonics
  5771. */
  5772. lL22: Vector3;
  5773. /**
  5774. * Adds a light to the spherical harmonics
  5775. * @param direction the direction of the light
  5776. * @param color the color of the light
  5777. * @param deltaSolidAngle the delta solid angle of the light
  5778. */
  5779. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5780. /**
  5781. * Scales the spherical harmonics by the given amount
  5782. * @param scale the amount to scale
  5783. */
  5784. scale(scale: number): void;
  5785. /**
  5786. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5787. *
  5788. * ```
  5789. * E_lm = A_l * L_lm
  5790. * ```
  5791. *
  5792. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5793. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5794. * the scaling factors are given in equation 9.
  5795. */
  5796. convertIncidentRadianceToIrradiance(): void;
  5797. /**
  5798. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5799. *
  5800. * ```
  5801. * L = (1/pi) * E * rho
  5802. * ```
  5803. *
  5804. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5805. */
  5806. convertIrradianceToLambertianRadiance(): void;
  5807. /**
  5808. * Gets the spherical harmonics from polynomial
  5809. * @param polynomial the spherical polynomial
  5810. * @returns the spherical harmonics
  5811. */
  5812. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5813. /**
  5814. * Constructs a spherical harmonics from an array.
  5815. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5816. * @returns the spherical harmonics
  5817. */
  5818. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5819. }
  5820. }
  5821. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5822. import { Nullable } from "babylonjs/types";
  5823. /**
  5824. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5825. */
  5826. export interface CubeMapInfo {
  5827. /**
  5828. * The pixel array for the front face.
  5829. * This is stored in format, left to right, up to down format.
  5830. */
  5831. front: Nullable<ArrayBufferView>;
  5832. /**
  5833. * The pixel array for the back face.
  5834. * This is stored in format, left to right, up to down format.
  5835. */
  5836. back: Nullable<ArrayBufferView>;
  5837. /**
  5838. * The pixel array for the left face.
  5839. * This is stored in format, left to right, up to down format.
  5840. */
  5841. left: Nullable<ArrayBufferView>;
  5842. /**
  5843. * The pixel array for the right face.
  5844. * This is stored in format, left to right, up to down format.
  5845. */
  5846. right: Nullable<ArrayBufferView>;
  5847. /**
  5848. * The pixel array for the up face.
  5849. * This is stored in format, left to right, up to down format.
  5850. */
  5851. up: Nullable<ArrayBufferView>;
  5852. /**
  5853. * The pixel array for the down face.
  5854. * This is stored in format, left to right, up to down format.
  5855. */
  5856. down: Nullable<ArrayBufferView>;
  5857. /**
  5858. * The size of the cubemap stored.
  5859. *
  5860. * Each faces will be size * size pixels.
  5861. */
  5862. size: number;
  5863. /**
  5864. * The format of the texture.
  5865. *
  5866. * RGBA, RGB.
  5867. */
  5868. format: number;
  5869. /**
  5870. * The type of the texture data.
  5871. *
  5872. * UNSIGNED_INT, FLOAT.
  5873. */
  5874. type: number;
  5875. /**
  5876. * Specifies whether the texture is in gamma space.
  5877. */
  5878. gammaSpace: boolean;
  5879. }
  5880. /**
  5881. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5882. */
  5883. export class PanoramaToCubeMapTools {
  5884. private static FACE_FRONT;
  5885. private static FACE_BACK;
  5886. private static FACE_RIGHT;
  5887. private static FACE_LEFT;
  5888. private static FACE_DOWN;
  5889. private static FACE_UP;
  5890. /**
  5891. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5892. *
  5893. * @param float32Array The source data.
  5894. * @param inputWidth The width of the input panorama.
  5895. * @param inputHeight The height of the input panorama.
  5896. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5897. * @return The cubemap data
  5898. */
  5899. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5900. private static CreateCubemapTexture;
  5901. private static CalcProjectionSpherical;
  5902. }
  5903. }
  5904. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5905. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5907. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5908. /**
  5909. * Helper class dealing with the extraction of spherical polynomial dataArray
  5910. * from a cube map.
  5911. */
  5912. export class CubeMapToSphericalPolynomialTools {
  5913. private static FileFaces;
  5914. /**
  5915. * Converts a texture to the according Spherical Polynomial data.
  5916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5917. *
  5918. * @param texture The texture to extract the information from.
  5919. * @return The Spherical Polynomial data.
  5920. */
  5921. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5922. /**
  5923. * Converts a cubemap to the according Spherical Polynomial data.
  5924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5925. *
  5926. * @param cubeInfo The Cube map to extract the information from.
  5927. * @return The Spherical Polynomial data.
  5928. */
  5929. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5930. }
  5931. }
  5932. declare module "babylonjs/Engines/engineStore" {
  5933. import { Nullable } from "babylonjs/types";
  5934. import { Engine } from "babylonjs/Engines/engine";
  5935. import { Scene } from "babylonjs/scene";
  5936. /**
  5937. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5938. * during the life time of the application.
  5939. */
  5940. export class EngineStore {
  5941. /** Gets the list of created engines */
  5942. static Instances: import("babylonjs/Engines/engine").Engine[];
  5943. /**
  5944. * Gets the latest created engine
  5945. */
  5946. static readonly LastCreatedEngine: Nullable<Engine>;
  5947. /**
  5948. * Gets the latest created scene
  5949. */
  5950. static readonly LastCreatedScene: Nullable<Scene>;
  5951. }
  5952. }
  5953. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5954. /**
  5955. * Define options used to create a render target texture
  5956. */
  5957. export class RenderTargetCreationOptions {
  5958. /**
  5959. * Specifies is mipmaps must be generated
  5960. */
  5961. generateMipMaps?: boolean;
  5962. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5963. generateDepthBuffer?: boolean;
  5964. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5965. generateStencilBuffer?: boolean;
  5966. /** Defines texture type (int by default) */
  5967. type?: number;
  5968. /** Defines sampling mode (trilinear by default) */
  5969. samplingMode?: number;
  5970. /** Defines format (RGBA by default) */
  5971. format?: number;
  5972. }
  5973. }
  5974. declare module "babylonjs/States/alphaCullingState" {
  5975. /**
  5976. * @hidden
  5977. **/
  5978. export class _AlphaState {
  5979. private _isAlphaBlendDirty;
  5980. private _isBlendFunctionParametersDirty;
  5981. private _isBlendEquationParametersDirty;
  5982. private _isBlendConstantsDirty;
  5983. private _alphaBlend;
  5984. private _blendFunctionParameters;
  5985. private _blendEquationParameters;
  5986. private _blendConstants;
  5987. /**
  5988. * Initializes the state.
  5989. */
  5990. constructor();
  5991. readonly isDirty: boolean;
  5992. alphaBlend: boolean;
  5993. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5994. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5995. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5996. reset(): void;
  5997. apply(gl: WebGLRenderingContext): void;
  5998. }
  5999. }
  6000. declare module "babylonjs/States/depthCullingState" {
  6001. import { Nullable } from "babylonjs/types";
  6002. /**
  6003. * @hidden
  6004. **/
  6005. export class _DepthCullingState {
  6006. private _isDepthTestDirty;
  6007. private _isDepthMaskDirty;
  6008. private _isDepthFuncDirty;
  6009. private _isCullFaceDirty;
  6010. private _isCullDirty;
  6011. private _isZOffsetDirty;
  6012. private _isFrontFaceDirty;
  6013. private _depthTest;
  6014. private _depthMask;
  6015. private _depthFunc;
  6016. private _cull;
  6017. private _cullFace;
  6018. private _zOffset;
  6019. private _frontFace;
  6020. /**
  6021. * Initializes the state.
  6022. */
  6023. constructor();
  6024. readonly isDirty: boolean;
  6025. zOffset: number;
  6026. cullFace: Nullable<number>;
  6027. cull: Nullable<boolean>;
  6028. depthFunc: Nullable<number>;
  6029. depthMask: boolean;
  6030. depthTest: boolean;
  6031. frontFace: Nullable<number>;
  6032. reset(): void;
  6033. apply(gl: WebGLRenderingContext): void;
  6034. }
  6035. }
  6036. declare module "babylonjs/States/stencilState" {
  6037. /**
  6038. * @hidden
  6039. **/
  6040. export class _StencilState {
  6041. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6042. static readonly ALWAYS: number;
  6043. /** Passed to stencilOperation to specify that stencil value must be kept */
  6044. static readonly KEEP: number;
  6045. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6046. static readonly REPLACE: number;
  6047. private _isStencilTestDirty;
  6048. private _isStencilMaskDirty;
  6049. private _isStencilFuncDirty;
  6050. private _isStencilOpDirty;
  6051. private _stencilTest;
  6052. private _stencilMask;
  6053. private _stencilFunc;
  6054. private _stencilFuncRef;
  6055. private _stencilFuncMask;
  6056. private _stencilOpStencilFail;
  6057. private _stencilOpDepthFail;
  6058. private _stencilOpStencilDepthPass;
  6059. readonly isDirty: boolean;
  6060. stencilFunc: number;
  6061. stencilFuncRef: number;
  6062. stencilFuncMask: number;
  6063. stencilOpStencilFail: number;
  6064. stencilOpDepthFail: number;
  6065. stencilOpStencilDepthPass: number;
  6066. stencilMask: number;
  6067. stencilTest: boolean;
  6068. constructor();
  6069. reset(): void;
  6070. apply(gl: WebGLRenderingContext): void;
  6071. }
  6072. }
  6073. declare module "babylonjs/States/index" {
  6074. export * from "babylonjs/States/alphaCullingState";
  6075. export * from "babylonjs/States/depthCullingState";
  6076. export * from "babylonjs/States/stencilState";
  6077. }
  6078. declare module "babylonjs/Instrumentation/timeToken" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _TimeToken {
  6084. _startTimeQuery: Nullable<WebGLQuery>;
  6085. _endTimeQuery: Nullable<WebGLQuery>;
  6086. _timeElapsedQuery: Nullable<WebGLQuery>;
  6087. _timeElapsedQueryEnded: boolean;
  6088. }
  6089. }
  6090. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6091. import { Nullable } from "babylonjs/types";
  6092. /**
  6093. * Internal interface used to track InternalTexture already bound to the GL context
  6094. */
  6095. export interface IInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. /**
  6106. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6107. */
  6108. export class DummyInternalTextureTracker {
  6109. /**
  6110. * Gets or set the previous tracker in the list
  6111. */
  6112. previous: Nullable<IInternalTextureTracker>;
  6113. /**
  6114. * Gets or set the next tracker in the list
  6115. */
  6116. next: Nullable<IInternalTextureTracker>;
  6117. }
  6118. }
  6119. declare module "babylonjs/Materials/Textures/internalTexture" {
  6120. import { Observable } from "babylonjs/Misc/observable";
  6121. import { Nullable, int } from "babylonjs/types";
  6122. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6123. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6124. import { Engine } from "babylonjs/Engines/engine";
  6125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6126. /**
  6127. * Class used to store data associated with WebGL texture data for the engine
  6128. * This class should not be used directly
  6129. */
  6130. export class InternalTexture implements IInternalTextureTracker {
  6131. /** hidden */
  6132. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6133. /**
  6134. * The source of the texture data is unknown
  6135. */
  6136. static DATASOURCE_UNKNOWN: number;
  6137. /**
  6138. * Texture data comes from an URL
  6139. */
  6140. static DATASOURCE_URL: number;
  6141. /**
  6142. * Texture data is only used for temporary storage
  6143. */
  6144. static DATASOURCE_TEMP: number;
  6145. /**
  6146. * Texture data comes from raw data (ArrayBuffer)
  6147. */
  6148. static DATASOURCE_RAW: number;
  6149. /**
  6150. * Texture content is dynamic (video or dynamic texture)
  6151. */
  6152. static DATASOURCE_DYNAMIC: number;
  6153. /**
  6154. * Texture content is generated by rendering to it
  6155. */
  6156. static DATASOURCE_RENDERTARGET: number;
  6157. /**
  6158. * Texture content is part of a multi render target process
  6159. */
  6160. static DATASOURCE_MULTIRENDERTARGET: number;
  6161. /**
  6162. * Texture data comes from a cube data file
  6163. */
  6164. static DATASOURCE_CUBE: number;
  6165. /**
  6166. * Texture data comes from a raw cube data
  6167. */
  6168. static DATASOURCE_CUBERAW: number;
  6169. /**
  6170. * Texture data come from a prefiltered cube data file
  6171. */
  6172. static DATASOURCE_CUBEPREFILTERED: number;
  6173. /**
  6174. * Texture content is raw 3D data
  6175. */
  6176. static DATASOURCE_RAW3D: number;
  6177. /**
  6178. * Texture content is a depth texture
  6179. */
  6180. static DATASOURCE_DEPTHTEXTURE: number;
  6181. /**
  6182. * Texture data comes from a raw cube data encoded with RGBD
  6183. */
  6184. static DATASOURCE_CUBERAW_RGBD: number;
  6185. /**
  6186. * Defines if the texture is ready
  6187. */
  6188. isReady: boolean;
  6189. /**
  6190. * Defines if the texture is a cube texture
  6191. */
  6192. isCube: boolean;
  6193. /**
  6194. * Defines if the texture contains 3D data
  6195. */
  6196. is3D: boolean;
  6197. /**
  6198. * Gets the URL used to load this texture
  6199. */
  6200. url: string;
  6201. /**
  6202. * Gets the sampling mode of the texture
  6203. */
  6204. samplingMode: number;
  6205. /**
  6206. * Gets a boolean indicating if the texture needs mipmaps generation
  6207. */
  6208. generateMipMaps: boolean;
  6209. /**
  6210. * Gets the number of samples used by the texture (WebGL2+ only)
  6211. */
  6212. samples: number;
  6213. /**
  6214. * Gets the type of the texture (int, float...)
  6215. */
  6216. type: number;
  6217. /**
  6218. * Gets the format of the texture (RGB, RGBA...)
  6219. */
  6220. format: number;
  6221. /**
  6222. * Observable called when the texture is loaded
  6223. */
  6224. onLoadedObservable: Observable<InternalTexture>;
  6225. /**
  6226. * Gets the width of the texture
  6227. */
  6228. width: number;
  6229. /**
  6230. * Gets the height of the texture
  6231. */
  6232. height: number;
  6233. /**
  6234. * Gets the depth of the texture
  6235. */
  6236. depth: number;
  6237. /**
  6238. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6239. */
  6240. baseWidth: number;
  6241. /**
  6242. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6243. */
  6244. baseHeight: number;
  6245. /**
  6246. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6247. */
  6248. baseDepth: number;
  6249. /**
  6250. * Gets a boolean indicating if the texture is inverted on Y axis
  6251. */
  6252. invertY: boolean;
  6253. /**
  6254. * Gets or set the previous tracker in the list
  6255. */
  6256. previous: Nullable<IInternalTextureTracker>;
  6257. /**
  6258. * Gets or set the next tracker in the list
  6259. */
  6260. next: Nullable<IInternalTextureTracker>;
  6261. /** @hidden */
  6262. _invertVScale: boolean;
  6263. /** @hidden */
  6264. _initialSlot: number;
  6265. /** @hidden */
  6266. _designatedSlot: number;
  6267. /** @hidden */
  6268. _dataSource: number;
  6269. /** @hidden */
  6270. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6271. /** @hidden */
  6272. _bufferView: Nullable<ArrayBufferView>;
  6273. /** @hidden */
  6274. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6275. /** @hidden */
  6276. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6277. /** @hidden */
  6278. _size: number;
  6279. /** @hidden */
  6280. _extension: string;
  6281. /** @hidden */
  6282. _files: Nullable<string[]>;
  6283. /** @hidden */
  6284. _workingCanvas: HTMLCanvasElement;
  6285. /** @hidden */
  6286. _workingContext: CanvasRenderingContext2D;
  6287. /** @hidden */
  6288. _framebuffer: Nullable<WebGLFramebuffer>;
  6289. /** @hidden */
  6290. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6291. /** @hidden */
  6292. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6293. /** @hidden */
  6294. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6295. /** @hidden */
  6296. _attachments: Nullable<number[]>;
  6297. /** @hidden */
  6298. _cachedCoordinatesMode: Nullable<number>;
  6299. /** @hidden */
  6300. _cachedWrapU: Nullable<number>;
  6301. /** @hidden */
  6302. _cachedWrapV: Nullable<number>;
  6303. /** @hidden */
  6304. _cachedWrapR: Nullable<number>;
  6305. /** @hidden */
  6306. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6307. /** @hidden */
  6308. _isDisabled: boolean;
  6309. /** @hidden */
  6310. _compression: Nullable<string>;
  6311. /** @hidden */
  6312. _generateStencilBuffer: boolean;
  6313. /** @hidden */
  6314. _generateDepthBuffer: boolean;
  6315. /** @hidden */
  6316. _comparisonFunction: number;
  6317. /** @hidden */
  6318. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6319. /** @hidden */
  6320. _lodGenerationScale: number;
  6321. /** @hidden */
  6322. _lodGenerationOffset: number;
  6323. /** @hidden */
  6324. _lodTextureHigh: BaseTexture;
  6325. /** @hidden */
  6326. _lodTextureMid: BaseTexture;
  6327. /** @hidden */
  6328. _lodTextureLow: BaseTexture;
  6329. /** @hidden */
  6330. _isRGBD: boolean;
  6331. /** @hidden */
  6332. _webGLTexture: Nullable<WebGLTexture>;
  6333. /** @hidden */
  6334. _references: number;
  6335. private _engine;
  6336. /**
  6337. * Gets the Engine the texture belongs to.
  6338. * @returns The babylon engine
  6339. */
  6340. getEngine(): Engine;
  6341. /**
  6342. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6343. */
  6344. readonly dataSource: number;
  6345. /**
  6346. * Creates a new InternalTexture
  6347. * @param engine defines the engine to use
  6348. * @param dataSource defines the type of data that will be used
  6349. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6350. */
  6351. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6352. /**
  6353. * Increments the number of references (ie. the number of Texture that point to it)
  6354. */
  6355. incrementReferences(): void;
  6356. /**
  6357. * Change the size of the texture (not the size of the content)
  6358. * @param width defines the new width
  6359. * @param height defines the new height
  6360. * @param depth defines the new depth (1 by default)
  6361. */
  6362. updateSize(width: int, height: int, depth?: int): void;
  6363. /** @hidden */
  6364. _rebuild(): void;
  6365. /** @hidden */
  6366. _swapAndDie(target: InternalTexture): void;
  6367. /**
  6368. * Dispose the current allocated resources
  6369. */
  6370. dispose(): void;
  6371. }
  6372. }
  6373. declare module "babylonjs/Animations/easing" {
  6374. /**
  6375. * This represents the main contract an easing function should follow.
  6376. * Easing functions are used throughout the animation system.
  6377. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6378. */
  6379. export interface IEasingFunction {
  6380. /**
  6381. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6382. * of the easing function.
  6383. * The link below provides some of the most common examples of easing functions.
  6384. * @see https://easings.net/
  6385. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6386. * @returns the corresponding value on the curve defined by the easing function
  6387. */
  6388. ease(gradient: number): number;
  6389. }
  6390. /**
  6391. * Base class used for every default easing function.
  6392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6393. */
  6394. export class EasingFunction implements IEasingFunction {
  6395. /**
  6396. * Interpolation follows the mathematical formula associated with the easing function.
  6397. */
  6398. static readonly EASINGMODE_EASEIN: number;
  6399. /**
  6400. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6401. */
  6402. static readonly EASINGMODE_EASEOUT: number;
  6403. /**
  6404. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6405. */
  6406. static readonly EASINGMODE_EASEINOUT: number;
  6407. private _easingMode;
  6408. /**
  6409. * Sets the easing mode of the current function.
  6410. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6411. */
  6412. setEasingMode(easingMode: number): void;
  6413. /**
  6414. * Gets the current easing mode.
  6415. * @returns the easing mode
  6416. */
  6417. getEasingMode(): number;
  6418. /**
  6419. * @hidden
  6420. */
  6421. easeInCore(gradient: number): number;
  6422. /**
  6423. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6424. * of the easing function.
  6425. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6426. * @returns the corresponding value on the curve defined by the easing function
  6427. */
  6428. ease(gradient: number): number;
  6429. }
  6430. /**
  6431. * Easing function with a circle shape (see link below).
  6432. * @see https://easings.net/#easeInCirc
  6433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6434. */
  6435. export class CircleEase extends EasingFunction implements IEasingFunction {
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a ease back shape (see link below).
  6441. * @see https://easings.net/#easeInBack
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BackEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the amplitude of the function */
  6446. amplitude: number;
  6447. /**
  6448. * Instantiates a back ease easing
  6449. * @see https://easings.net/#easeInBack
  6450. * @param amplitude Defines the amplitude of the function
  6451. */
  6452. constructor(
  6453. /** Defines the amplitude of the function */
  6454. amplitude?: number);
  6455. /** @hidden */
  6456. easeInCore(gradient: number): number;
  6457. }
  6458. /**
  6459. * Easing function with a bouncing shape (see link below).
  6460. * @see https://easings.net/#easeInBounce
  6461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6462. */
  6463. export class BounceEase extends EasingFunction implements IEasingFunction {
  6464. /** Defines the number of bounces */
  6465. bounces: number;
  6466. /** Defines the amplitude of the bounce */
  6467. bounciness: number;
  6468. /**
  6469. * Instantiates a bounce easing
  6470. * @see https://easings.net/#easeInBounce
  6471. * @param bounces Defines the number of bounces
  6472. * @param bounciness Defines the amplitude of the bounce
  6473. */
  6474. constructor(
  6475. /** Defines the number of bounces */
  6476. bounces?: number,
  6477. /** Defines the amplitude of the bounce */
  6478. bounciness?: number);
  6479. /** @hidden */
  6480. easeInCore(gradient: number): number;
  6481. }
  6482. /**
  6483. * Easing function with a power of 3 shape (see link below).
  6484. * @see https://easings.net/#easeInCubic
  6485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6486. */
  6487. export class CubicEase extends EasingFunction implements IEasingFunction {
  6488. /** @hidden */
  6489. easeInCore(gradient: number): number;
  6490. }
  6491. /**
  6492. * Easing function with an elastic shape (see link below).
  6493. * @see https://easings.net/#easeInElastic
  6494. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6495. */
  6496. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6497. /** Defines the number of oscillations*/
  6498. oscillations: number;
  6499. /** Defines the amplitude of the oscillations*/
  6500. springiness: number;
  6501. /**
  6502. * Instantiates an elastic easing function
  6503. * @see https://easings.net/#easeInElastic
  6504. * @param oscillations Defines the number of oscillations
  6505. * @param springiness Defines the amplitude of the oscillations
  6506. */
  6507. constructor(
  6508. /** Defines the number of oscillations*/
  6509. oscillations?: number,
  6510. /** Defines the amplitude of the oscillations*/
  6511. springiness?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with an exponential shape (see link below).
  6517. * @see https://easings.net/#easeInExpo
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the exponent of the function */
  6522. exponent: number;
  6523. /**
  6524. * Instantiates an exponential easing function
  6525. * @see https://easings.net/#easeInExpo
  6526. * @param exponent Defines the exponent of the function
  6527. */
  6528. constructor(
  6529. /** Defines the exponent of the function */
  6530. exponent?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class PowerEase extends EasingFunction implements IEasingFunction {
  6540. /** Defines the power of the function */
  6541. power: number;
  6542. /**
  6543. * Instantiates an power base easing function
  6544. * @see https://easings.net/#easeInQuad
  6545. * @param power Defines the power of the function
  6546. */
  6547. constructor(
  6548. /** Defines the power of the function */
  6549. power?: number);
  6550. /** @hidden */
  6551. easeInCore(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with a power of 2 shape (see link below).
  6555. * @see https://easings.net/#easeInQuad
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6559. /** @hidden */
  6560. easeInCore(gradient: number): number;
  6561. }
  6562. /**
  6563. * Easing function with a power of 4 shape (see link below).
  6564. * @see https://easings.net/#easeInQuart
  6565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6566. */
  6567. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6568. /** @hidden */
  6569. easeInCore(gradient: number): number;
  6570. }
  6571. /**
  6572. * Easing function with a power of 5 shape (see link below).
  6573. * @see https://easings.net/#easeInQuint
  6574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6575. */
  6576. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6577. /** @hidden */
  6578. easeInCore(gradient: number): number;
  6579. }
  6580. /**
  6581. * Easing function with a sin shape (see link below).
  6582. * @see https://easings.net/#easeInSine
  6583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6584. */
  6585. export class SineEase extends EasingFunction implements IEasingFunction {
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a bezier shape (see link below).
  6591. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6595. /** Defines the x component of the start tangent in the bezier curve */
  6596. x1: number;
  6597. /** Defines the y component of the start tangent in the bezier curve */
  6598. y1: number;
  6599. /** Defines the x component of the end tangent in the bezier curve */
  6600. x2: number;
  6601. /** Defines the y component of the end tangent in the bezier curve */
  6602. y2: number;
  6603. /**
  6604. * Instantiates a bezier function
  6605. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6606. * @param x1 Defines the x component of the start tangent in the bezier curve
  6607. * @param y1 Defines the y component of the start tangent in the bezier curve
  6608. * @param x2 Defines the x component of the end tangent in the bezier curve
  6609. * @param y2 Defines the y component of the end tangent in the bezier curve
  6610. */
  6611. constructor(
  6612. /** Defines the x component of the start tangent in the bezier curve */
  6613. x1?: number,
  6614. /** Defines the y component of the start tangent in the bezier curve */
  6615. y1?: number,
  6616. /** Defines the x component of the end tangent in the bezier curve */
  6617. x2?: number,
  6618. /** Defines the y component of the end tangent in the bezier curve */
  6619. y2?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. }
  6624. declare module "babylonjs/Behaviors/behavior" {
  6625. import { Nullable } from "babylonjs/types";
  6626. /**
  6627. * Interface used to define a behavior
  6628. */
  6629. export interface Behavior<T> {
  6630. /** gets or sets behavior's name */
  6631. name: string;
  6632. /**
  6633. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6634. */
  6635. init(): void;
  6636. /**
  6637. * Called when the behavior is attached to a target
  6638. * @param target defines the target where the behavior is attached to
  6639. */
  6640. attach(target: T): void;
  6641. /**
  6642. * Called when the behavior is detached from its target
  6643. */
  6644. detach(): void;
  6645. }
  6646. /**
  6647. * Interface implemented by classes supporting behaviors
  6648. */
  6649. export interface IBehaviorAware<T> {
  6650. /**
  6651. * Attach a behavior
  6652. * @param behavior defines the behavior to attach
  6653. * @returns the current host
  6654. */
  6655. addBehavior(behavior: Behavior<T>): T;
  6656. /**
  6657. * Remove a behavior from the current object
  6658. * @param behavior defines the behavior to detach
  6659. * @returns the current host
  6660. */
  6661. removeBehavior(behavior: Behavior<T>): T;
  6662. /**
  6663. * Gets a behavior using its name to search
  6664. * @param name defines the name to search
  6665. * @returns the behavior or null if not found
  6666. */
  6667. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6668. }
  6669. }
  6670. declare module "babylonjs/Animations/runtimeAnimation" {
  6671. import { Animation } from "babylonjs/Animations/animation";
  6672. import { Animatable } from "babylonjs/Animations/animatable";
  6673. import { Scene } from "babylonjs/scene";
  6674. /**
  6675. * Defines a runtime animation
  6676. */
  6677. export class RuntimeAnimation {
  6678. private _events;
  6679. /**
  6680. * The current frame of the runtime animation
  6681. */
  6682. private _currentFrame;
  6683. /**
  6684. * The animation used by the runtime animation
  6685. */
  6686. private _animation;
  6687. /**
  6688. * The target of the runtime animation
  6689. */
  6690. private _target;
  6691. /**
  6692. * The initiating animatable
  6693. */
  6694. private _host;
  6695. /**
  6696. * The original value of the runtime animation
  6697. */
  6698. private _originalValue;
  6699. /**
  6700. * The original blend value of the runtime animation
  6701. */
  6702. private _originalBlendValue;
  6703. /**
  6704. * The offsets cache of the runtime animation
  6705. */
  6706. private _offsetsCache;
  6707. /**
  6708. * The high limits cache of the runtime animation
  6709. */
  6710. private _highLimitsCache;
  6711. /**
  6712. * Specifies if the runtime animation has been stopped
  6713. */
  6714. private _stopped;
  6715. /**
  6716. * The blending factor of the runtime animation
  6717. */
  6718. private _blendingFactor;
  6719. /**
  6720. * The BabylonJS scene
  6721. */
  6722. private _scene;
  6723. /**
  6724. * The current value of the runtime animation
  6725. */
  6726. private _currentValue;
  6727. /** @hidden */
  6728. _workValue: any;
  6729. /**
  6730. * The active target of the runtime animation
  6731. */
  6732. private _activeTarget;
  6733. /**
  6734. * The target path of the runtime animation
  6735. */
  6736. private _targetPath;
  6737. /**
  6738. * The weight of the runtime animation
  6739. */
  6740. private _weight;
  6741. /**
  6742. * The ratio offset of the runtime animation
  6743. */
  6744. private _ratioOffset;
  6745. /**
  6746. * The previous delay of the runtime animation
  6747. */
  6748. private _previousDelay;
  6749. /**
  6750. * The previous ratio of the runtime animation
  6751. */
  6752. private _previousRatio;
  6753. /**
  6754. * Gets the current frame of the runtime animation
  6755. */
  6756. readonly currentFrame: number;
  6757. /**
  6758. * Gets the weight of the runtime animation
  6759. */
  6760. readonly weight: number;
  6761. /**
  6762. * Gets the current value of the runtime animation
  6763. */
  6764. readonly currentValue: any;
  6765. /**
  6766. * Gets the target path of the runtime animation
  6767. */
  6768. readonly targetPath: string;
  6769. /**
  6770. * Gets the actual target of the runtime animation
  6771. */
  6772. readonly target: any;
  6773. /**
  6774. * Create a new RuntimeAnimation object
  6775. * @param target defines the target of the animation
  6776. * @param animation defines the source animation object
  6777. * @param scene defines the hosting scene
  6778. * @param host defines the initiating Animatable
  6779. */
  6780. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6781. /**
  6782. * Gets the animation from the runtime animation
  6783. */
  6784. readonly animation: Animation;
  6785. /**
  6786. * Resets the runtime animation to the beginning
  6787. * @param restoreOriginal defines whether to restore the target property to the original value
  6788. */
  6789. reset(restoreOriginal?: boolean): void;
  6790. /**
  6791. * Specifies if the runtime animation is stopped
  6792. * @returns Boolean specifying if the runtime animation is stopped
  6793. */
  6794. isStopped(): boolean;
  6795. /**
  6796. * Disposes of the runtime animation
  6797. */
  6798. dispose(): void;
  6799. /**
  6800. * Interpolates the animation from the current frame
  6801. * @param currentFrame The frame to interpolate the animation to
  6802. * @param repeatCount The number of times that the animation should loop
  6803. * @param loopMode The type of looping mode to use
  6804. * @param offsetValue Animation offset value
  6805. * @param highLimitValue The high limit value
  6806. * @returns The interpolated value
  6807. */
  6808. private _interpolate;
  6809. /**
  6810. * Apply the interpolated value to the target
  6811. * @param currentValue defines the value computed by the animation
  6812. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6813. */
  6814. setValue(currentValue: any, weight?: number): void;
  6815. private _setValue;
  6816. /**
  6817. * Gets the loop pmode of the runtime animation
  6818. * @returns Loop Mode
  6819. */
  6820. private _getCorrectLoopMode;
  6821. /**
  6822. * Move the current animation to a given frame
  6823. * @param frame defines the frame to move to
  6824. */
  6825. goToFrame(frame: number): void;
  6826. /**
  6827. * @hidden Internal use only
  6828. */
  6829. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6830. /**
  6831. * Execute the current animation
  6832. * @param delay defines the delay to add to the current frame
  6833. * @param from defines the lower bound of the animation range
  6834. * @param to defines the upper bound of the animation range
  6835. * @param loop defines if the current animation must loop
  6836. * @param speedRatio defines the current speed ratio
  6837. * @param weight defines the weight of the animation (default is -1 so no weight)
  6838. * @param onLoop optional callback called when animation loops
  6839. * @returns a boolean indicating if the animation is running
  6840. */
  6841. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6842. }
  6843. }
  6844. declare module "babylonjs/Animations/animatable" {
  6845. import { Animation } from "babylonjs/Animations/animation";
  6846. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  6847. import { Nullable } from "babylonjs/types";
  6848. import { Observable } from "babylonjs/Misc/observable";
  6849. import { Scene } from "babylonjs/scene";
  6850. /**
  6851. * Class used to store an actual running animation
  6852. */
  6853. export class Animatable {
  6854. /** defines the target object */
  6855. target: any;
  6856. /** defines the starting frame number (default is 0) */
  6857. fromFrame: number;
  6858. /** defines the ending frame number (default is 100) */
  6859. toFrame: number;
  6860. /** defines if the animation must loop (default is false) */
  6861. loopAnimation: boolean;
  6862. /** defines a callback to call when animation ends if it is not looping */
  6863. onAnimationEnd?: (() => void) | null | undefined;
  6864. /** defines a callback to call when animation loops */
  6865. onAnimationLoop?: (() => void) | null | undefined;
  6866. private _localDelayOffset;
  6867. private _pausedDelay;
  6868. private _runtimeAnimations;
  6869. private _paused;
  6870. private _scene;
  6871. private _speedRatio;
  6872. private _weight;
  6873. private _syncRoot;
  6874. /**
  6875. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6876. * This will only apply for non looping animation (default is true)
  6877. */
  6878. disposeOnEnd: boolean;
  6879. /**
  6880. * Gets a boolean indicating if the animation has started
  6881. */
  6882. animationStarted: boolean;
  6883. /**
  6884. * Observer raised when the animation ends
  6885. */
  6886. onAnimationEndObservable: Observable<Animatable>;
  6887. /**
  6888. * Observer raised when the animation loops
  6889. */
  6890. onAnimationLoopObservable: Observable<Animatable>;
  6891. /**
  6892. * Gets the root Animatable used to synchronize and normalize animations
  6893. */
  6894. readonly syncRoot: Animatable;
  6895. /**
  6896. * Gets the current frame of the first RuntimeAnimation
  6897. * Used to synchronize Animatables
  6898. */
  6899. readonly masterFrame: number;
  6900. /**
  6901. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6902. */
  6903. weight: number;
  6904. /**
  6905. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6906. */
  6907. speedRatio: number;
  6908. /**
  6909. * Creates a new Animatable
  6910. * @param scene defines the hosting scene
  6911. * @param target defines the target object
  6912. * @param fromFrame defines the starting frame number (default is 0)
  6913. * @param toFrame defines the ending frame number (default is 100)
  6914. * @param loopAnimation defines if the animation must loop (default is false)
  6915. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6916. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6917. * @param animations defines a group of animation to add to the new Animatable
  6918. * @param onAnimationLoop defines a callback to call when animation loops
  6919. */
  6920. constructor(scene: Scene,
  6921. /** defines the target object */
  6922. target: any,
  6923. /** defines the starting frame number (default is 0) */
  6924. fromFrame?: number,
  6925. /** defines the ending frame number (default is 100) */
  6926. toFrame?: number,
  6927. /** defines if the animation must loop (default is false) */
  6928. loopAnimation?: boolean, speedRatio?: number,
  6929. /** defines a callback to call when animation ends if it is not looping */
  6930. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6931. /** defines a callback to call when animation loops */
  6932. onAnimationLoop?: (() => void) | null | undefined);
  6933. /**
  6934. * Synchronize and normalize current Animatable with a source Animatable
  6935. * This is useful when using animation weights and when animations are not of the same length
  6936. * @param root defines the root Animatable to synchronize with
  6937. * @returns the current Animatable
  6938. */
  6939. syncWith(root: Animatable): Animatable;
  6940. /**
  6941. * Gets the list of runtime animations
  6942. * @returns an array of RuntimeAnimation
  6943. */
  6944. getAnimations(): RuntimeAnimation[];
  6945. /**
  6946. * Adds more animations to the current animatable
  6947. * @param target defines the target of the animations
  6948. * @param animations defines the new animations to add
  6949. */
  6950. appendAnimations(target: any, animations: Animation[]): void;
  6951. /**
  6952. * Gets the source animation for a specific property
  6953. * @param property defines the propertyu to look for
  6954. * @returns null or the source animation for the given property
  6955. */
  6956. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6957. /**
  6958. * Gets the runtime animation for a specific property
  6959. * @param property defines the propertyu to look for
  6960. * @returns null or the runtime animation for the given property
  6961. */
  6962. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6963. /**
  6964. * Resets the animatable to its original state
  6965. */
  6966. reset(): void;
  6967. /**
  6968. * Allows the animatable to blend with current running animations
  6969. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6970. * @param blendingSpeed defines the blending speed to use
  6971. */
  6972. enableBlending(blendingSpeed: number): void;
  6973. /**
  6974. * Disable animation blending
  6975. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6976. */
  6977. disableBlending(): void;
  6978. /**
  6979. * Jump directly to a given frame
  6980. * @param frame defines the frame to jump to
  6981. */
  6982. goToFrame(frame: number): void;
  6983. /**
  6984. * Pause the animation
  6985. */
  6986. pause(): void;
  6987. /**
  6988. * Restart the animation
  6989. */
  6990. restart(): void;
  6991. private _raiseOnAnimationEnd;
  6992. /**
  6993. * Stop and delete the current animation
  6994. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6995. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  6996. */
  6997. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6998. /**
  6999. * Wait asynchronously for the animation to end
  7000. * @returns a promise which will be fullfilled when the animation ends
  7001. */
  7002. waitAsync(): Promise<Animatable>;
  7003. /** @hidden */
  7004. _animate(delay: number): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7008. /**
  7009. * Class used to override all child animations of a given target
  7010. */
  7011. export class AnimationPropertiesOverride {
  7012. /**
  7013. * Gets or sets a value indicating if animation blending must be used
  7014. */
  7015. enableBlending: boolean;
  7016. /**
  7017. * Gets or sets the blending speed to use when enableBlending is true
  7018. */
  7019. blendingSpeed: number;
  7020. /**
  7021. * Gets or sets the default loop mode to use
  7022. */
  7023. loopMode: number;
  7024. }
  7025. }
  7026. declare module "babylonjs/Collisions/collider" {
  7027. import { Nullable, IndicesArray } from "babylonjs/types";
  7028. import { Vector3, Plane } from "babylonjs/Maths/math";
  7029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7030. /** @hidden */
  7031. export class Collider {
  7032. /** Define if a collision was found */
  7033. collisionFound: boolean;
  7034. /**
  7035. * Define last intersection point in local space
  7036. */
  7037. intersectionPoint: Vector3;
  7038. /**
  7039. * Define last collided mesh
  7040. */
  7041. collidedMesh: Nullable<AbstractMesh>;
  7042. private _collisionPoint;
  7043. private _planeIntersectionPoint;
  7044. private _tempVector;
  7045. private _tempVector2;
  7046. private _tempVector3;
  7047. private _tempVector4;
  7048. private _edge;
  7049. private _baseToVertex;
  7050. private _destinationPoint;
  7051. private _slidePlaneNormal;
  7052. private _displacementVector;
  7053. /** @hidden */
  7054. _radius: Vector3;
  7055. /** @hidden */
  7056. _retry: number;
  7057. private _velocity;
  7058. private _basePoint;
  7059. private _epsilon;
  7060. /** @hidden */
  7061. _velocityWorldLength: number;
  7062. /** @hidden */
  7063. _basePointWorld: Vector3;
  7064. private _velocityWorld;
  7065. private _normalizedVelocity;
  7066. /** @hidden */
  7067. _initialVelocity: Vector3;
  7068. /** @hidden */
  7069. _initialPosition: Vector3;
  7070. private _nearestDistance;
  7071. private _collisionMask;
  7072. collisionMask: number;
  7073. /**
  7074. * Gets the plane normal used to compute the sliding response (in local space)
  7075. */
  7076. readonly slidePlaneNormal: Vector3;
  7077. /** @hidden */
  7078. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7079. /** @hidden */
  7080. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7081. /** @hidden */
  7082. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7083. /** @hidden */
  7084. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7085. /** @hidden */
  7086. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7087. /** @hidden */
  7088. _getResponse(pos: Vector3, vel: Vector3): void;
  7089. }
  7090. }
  7091. declare module "babylonjs/Collisions/intersectionInfo" {
  7092. import { Nullable } from "babylonjs/types";
  7093. /**
  7094. * @hidden
  7095. */
  7096. export class IntersectionInfo {
  7097. bu: Nullable<number>;
  7098. bv: Nullable<number>;
  7099. distance: number;
  7100. faceId: number;
  7101. subMeshId: number;
  7102. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7103. }
  7104. }
  7105. declare module "babylonjs/Actions/actionEvent" {
  7106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7107. import { Nullable } from "babylonjs/types";
  7108. import { Sprite } from "babylonjs/Sprites/sprite";
  7109. import { Scene } from "babylonjs/scene";
  7110. import { Vector2 } from "babylonjs/Maths/math";
  7111. /**
  7112. * ActionEvent is the event being sent when an action is triggered.
  7113. */
  7114. export class ActionEvent {
  7115. /** The mesh or sprite that triggered the action */
  7116. source: any;
  7117. /** The X mouse cursor position at the time of the event */
  7118. pointerX: number;
  7119. /** The Y mouse cursor position at the time of the event */
  7120. pointerY: number;
  7121. /** The mesh that is currently pointed at (can be null) */
  7122. meshUnderPointer: Nullable<AbstractMesh>;
  7123. /** the original (browser) event that triggered the ActionEvent */
  7124. sourceEvent?: any;
  7125. /** additional data for the event */
  7126. additionalData?: any;
  7127. /**
  7128. * Creates a new ActionEvent
  7129. * @param source The mesh or sprite that triggered the action
  7130. * @param pointerX The X mouse cursor position at the time of the event
  7131. * @param pointerY The Y mouse cursor position at the time of the event
  7132. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7133. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7134. * @param additionalData additional data for the event
  7135. */
  7136. constructor(
  7137. /** The mesh or sprite that triggered the action */
  7138. source: any,
  7139. /** The X mouse cursor position at the time of the event */
  7140. pointerX: number,
  7141. /** The Y mouse cursor position at the time of the event */
  7142. pointerY: number,
  7143. /** The mesh that is currently pointed at (can be null) */
  7144. meshUnderPointer: Nullable<AbstractMesh>,
  7145. /** the original (browser) event that triggered the ActionEvent */
  7146. sourceEvent?: any,
  7147. /** additional data for the event */
  7148. additionalData?: any);
  7149. /**
  7150. * Helper function to auto-create an ActionEvent from a source mesh.
  7151. * @param source The source mesh that triggered the event
  7152. * @param evt The original (browser) event
  7153. * @param additionalData additional data for the event
  7154. * @returns the new ActionEvent
  7155. */
  7156. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7157. /**
  7158. * Helper function to auto-create an ActionEvent from a source sprite
  7159. * @param source The source sprite that triggered the event
  7160. * @param scene Scene associated with the sprite
  7161. * @param evt The original (browser) event
  7162. * @param additionalData additional data for the event
  7163. * @returns the new ActionEvent
  7164. */
  7165. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7166. /**
  7167. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7168. * @param scene the scene where the event occurred
  7169. * @param evt The original (browser) event
  7170. * @returns the new ActionEvent
  7171. */
  7172. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7173. /**
  7174. * Helper function to auto-create an ActionEvent from a primitive
  7175. * @param prim defines the target primitive
  7176. * @param pointerPos defines the pointer position
  7177. * @param evt The original (browser) event
  7178. * @param additionalData additional data for the event
  7179. * @returns the new ActionEvent
  7180. */
  7181. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingSphere" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7187. /**
  7188. * Class used to store bounding sphere information
  7189. */
  7190. export class BoundingSphere {
  7191. /**
  7192. * Gets the center of the bounding sphere in local space
  7193. */
  7194. readonly center: Vector3;
  7195. /**
  7196. * Radius of the bounding sphere in local space
  7197. */
  7198. radius: number;
  7199. /**
  7200. * Gets the center of the bounding sphere in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Radius of the bounding sphere in world space
  7205. */
  7206. radiusWorld: number;
  7207. /**
  7208. * Gets the minimum vector in local space
  7209. */
  7210. readonly minimum: Vector3;
  7211. /**
  7212. * Gets the maximum vector in local space
  7213. */
  7214. readonly maximum: Vector3;
  7215. private _worldMatrix;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Creates a new bounding sphere
  7219. * @param min defines the minimum vector (in local space)
  7220. * @param max defines the maximum vector (in local space)
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * Scale the current bounding sphere by applying a scale factor
  7233. * @param factor defines the scale factor to apply
  7234. * @returns the current bounding box
  7235. */
  7236. scale(factor: number): BoundingSphere;
  7237. /**
  7238. * Gets the world matrix of the bounding box
  7239. * @returns a matrix
  7240. */
  7241. getWorldMatrix(): DeepImmutable<Matrix>;
  7242. /** @hidden */
  7243. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7244. /**
  7245. * Tests if the bounding sphere is intersecting the frustum planes
  7246. * @param frustumPlanes defines the frustum planes to test
  7247. * @returns true if there is an intersection
  7248. */
  7249. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7250. /**
  7251. * Tests if the bounding sphere center is in between the frustum planes.
  7252. * Used for optimistic fast inclusion.
  7253. * @param frustumPlanes defines the frustum planes to test
  7254. * @returns true if the sphere center is in between the frustum planes
  7255. */
  7256. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7257. /**
  7258. * Tests if a point is inside the bounding sphere
  7259. * @param point defines the point to test
  7260. * @returns true if the point is inside the bounding sphere
  7261. */
  7262. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7263. /**
  7264. * Checks if two sphere intersct
  7265. * @param sphere0 sphere 0
  7266. * @param sphere1 sphere 1
  7267. * @returns true if the speres intersect
  7268. */
  7269. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7270. }
  7271. }
  7272. declare module "babylonjs/Culling/boundingBox" {
  7273. import { DeepImmutable } from "babylonjs/types";
  7274. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7275. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7276. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7277. /**
  7278. * Class used to store bounding box information
  7279. */
  7280. export class BoundingBox implements ICullable {
  7281. /**
  7282. * Gets the 8 vectors representing the bounding box in local space
  7283. */
  7284. readonly vectors: Vector3[];
  7285. /**
  7286. * Gets the center of the bounding box in local space
  7287. */
  7288. readonly center: Vector3;
  7289. /**
  7290. * Gets the center of the bounding box in world space
  7291. */
  7292. readonly centerWorld: Vector3;
  7293. /**
  7294. * Gets the extend size in local space
  7295. */
  7296. readonly extendSize: Vector3;
  7297. /**
  7298. * Gets the extend size in world space
  7299. */
  7300. readonly extendSizeWorld: Vector3;
  7301. /**
  7302. * Gets the OBB (object bounding box) directions
  7303. */
  7304. readonly directions: Vector3[];
  7305. /**
  7306. * Gets the 8 vectors representing the bounding box in world space
  7307. */
  7308. readonly vectorsWorld: Vector3[];
  7309. /**
  7310. * Gets the minimum vector in world space
  7311. */
  7312. readonly minimumWorld: Vector3;
  7313. /**
  7314. * Gets the maximum vector in world space
  7315. */
  7316. readonly maximumWorld: Vector3;
  7317. /**
  7318. * Gets the minimum vector in local space
  7319. */
  7320. readonly minimum: Vector3;
  7321. /**
  7322. * Gets the maximum vector in local space
  7323. */
  7324. readonly maximum: Vector3;
  7325. private _worldMatrix;
  7326. private static readonly TmpVector3;
  7327. /**
  7328. * @hidden
  7329. */
  7330. _tag: number;
  7331. /**
  7332. * Creates a new bounding box
  7333. * @param min defines the minimum vector (in local space)
  7334. * @param max defines the maximum vector (in local space)
  7335. * @param worldMatrix defines the new world matrix
  7336. */
  7337. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7338. /**
  7339. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7340. * @param min defines the new minimum vector (in local space)
  7341. * @param max defines the new maximum vector (in local space)
  7342. * @param worldMatrix defines the new world matrix
  7343. */
  7344. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7345. /**
  7346. * Scale the current bounding box by applying a scale factor
  7347. * @param factor defines the scale factor to apply
  7348. * @returns the current bounding box
  7349. */
  7350. scale(factor: number): BoundingBox;
  7351. /**
  7352. * Gets the world matrix of the bounding box
  7353. * @returns a matrix
  7354. */
  7355. getWorldMatrix(): DeepImmutable<Matrix>;
  7356. /** @hidden */
  7357. _update(world: DeepImmutable<Matrix>): void;
  7358. /**
  7359. * Tests if the bounding box is intersecting the frustum planes
  7360. * @param frustumPlanes defines the frustum planes to test
  7361. * @returns true if there is an intersection
  7362. */
  7363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7364. /**
  7365. * Tests if the bounding box is entirely inside the frustum planes
  7366. * @param frustumPlanes defines the frustum planes to test
  7367. * @returns true if there is an inclusion
  7368. */
  7369. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7370. /**
  7371. * Tests if a point is inside the bounding box
  7372. * @param point defines the point to test
  7373. * @returns true if the point is inside the bounding box
  7374. */
  7375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7376. /**
  7377. * Tests if the bounding box intersects with a bounding sphere
  7378. * @param sphere defines the sphere to test
  7379. * @returns true if there is an intersection
  7380. */
  7381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7382. /**
  7383. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7384. * @param min defines the min vector to use
  7385. * @param max defines the max vector to use
  7386. * @returns true if there is an intersection
  7387. */
  7388. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7389. /**
  7390. * Tests if two bounding boxes are intersections
  7391. * @param box0 defines the first box to test
  7392. * @param box1 defines the second box to test
  7393. * @returns true if there is an intersection
  7394. */
  7395. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7396. /**
  7397. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7398. * @param minPoint defines the minimum vector of the bounding box
  7399. * @param maxPoint defines the maximum vector of the bounding box
  7400. * @param sphereCenter defines the sphere center
  7401. * @param sphereRadius defines the sphere radius
  7402. * @returns true if there is an intersection
  7403. */
  7404. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7405. /**
  7406. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7407. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7408. * @param frustumPlanes defines the frustum planes to test
  7409. * @return true if there is an inclusion
  7410. */
  7411. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7412. /**
  7413. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7414. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7415. * @param frustumPlanes defines the frustum planes to test
  7416. * @return true if there is an intersection
  7417. */
  7418. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7419. }
  7420. }
  7421. declare module "babylonjs/Culling/boundingInfo" {
  7422. import { DeepImmutable } from "babylonjs/types";
  7423. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7424. import { Collider } from "babylonjs/Collisions/collider";
  7425. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7426. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7427. /**
  7428. * Interface for cullable objects
  7429. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7430. */
  7431. export interface ICullable {
  7432. /**
  7433. * Checks if the object or part of the object is in the frustum
  7434. * @param frustumPlanes Camera near/planes
  7435. * @returns true if the object is in frustum otherwise false
  7436. */
  7437. isInFrustum(frustumPlanes: Plane[]): boolean;
  7438. /**
  7439. * Checks if a cullable object (mesh...) is in the camera frustum
  7440. * Unlike isInFrustum this cheks the full bounding box
  7441. * @param frustumPlanes Camera near/planes
  7442. * @returns true if the object is in frustum otherwise false
  7443. */
  7444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7445. }
  7446. /**
  7447. * Info for a bounding data of a mesh
  7448. */
  7449. export class BoundingInfo implements ICullable {
  7450. /**
  7451. * Bounding box for the mesh
  7452. */
  7453. readonly boundingBox: BoundingBox;
  7454. /**
  7455. * Bounding sphere for the mesh
  7456. */
  7457. readonly boundingSphere: BoundingSphere;
  7458. private _isLocked;
  7459. private static readonly TmpVector3;
  7460. /**
  7461. * Constructs bounding info
  7462. * @param minimum min vector of the bounding box/sphere
  7463. * @param maximum max vector of the bounding box/sphere
  7464. * @param worldMatrix defines the new world matrix
  7465. */
  7466. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7467. /**
  7468. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7469. * @param min defines the new minimum vector (in local space)
  7470. * @param max defines the new maximum vector (in local space)
  7471. * @param worldMatrix defines the new world matrix
  7472. */
  7473. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7474. /**
  7475. * min vector of the bounding box/sphere
  7476. */
  7477. readonly minimum: Vector3;
  7478. /**
  7479. * max vector of the bounding box/sphere
  7480. */
  7481. readonly maximum: Vector3;
  7482. /**
  7483. * If the info is locked and won't be updated to avoid perf overhead
  7484. */
  7485. isLocked: boolean;
  7486. /**
  7487. * Updates the bounding sphere and box
  7488. * @param world world matrix to be used to update
  7489. */
  7490. update(world: DeepImmutable<Matrix>): void;
  7491. /**
  7492. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7493. * @param center New center of the bounding info
  7494. * @param extend New extend of the bounding info
  7495. * @returns the current bounding info
  7496. */
  7497. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7498. /**
  7499. * Scale the current bounding info by applying a scale factor
  7500. * @param factor defines the scale factor to apply
  7501. * @returns the current bounding info
  7502. */
  7503. scale(factor: number): BoundingInfo;
  7504. /**
  7505. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7506. * @param frustumPlanes defines the frustum to test
  7507. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7508. * @returns true if the bounding info is in the frustum planes
  7509. */
  7510. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7511. /**
  7512. * Gets the world distance between the min and max points of the bounding box
  7513. */
  7514. readonly diagonalLength: number;
  7515. /**
  7516. * Checks if a cullable object (mesh...) is in the camera frustum
  7517. * Unlike isInFrustum this cheks the full bounding box
  7518. * @param frustumPlanes Camera near/planes
  7519. * @returns true if the object is in frustum otherwise false
  7520. */
  7521. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7522. /** @hidden */
  7523. _checkCollision(collider: Collider): boolean;
  7524. /**
  7525. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7526. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7527. * @param point the point to check intersection with
  7528. * @returns if the point intersects
  7529. */
  7530. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7531. /**
  7532. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7533. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7534. * @param boundingInfo the bounding info to check intersection with
  7535. * @param precise if the intersection should be done using OBB
  7536. * @returns if the bounding info intersects
  7537. */
  7538. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7539. }
  7540. }
  7541. declare module "babylonjs/Misc/smartArray" {
  7542. /**
  7543. * Defines an array and its length.
  7544. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7545. */
  7546. export interface ISmartArrayLike<T> {
  7547. /**
  7548. * The data of the array.
  7549. */
  7550. data: Array<T>;
  7551. /**
  7552. * The active length of the array.
  7553. */
  7554. length: number;
  7555. }
  7556. /**
  7557. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7558. */
  7559. export class SmartArray<T> implements ISmartArrayLike<T> {
  7560. /**
  7561. * The full set of data from the array.
  7562. */
  7563. data: Array<T>;
  7564. /**
  7565. * The active length of the array.
  7566. */
  7567. length: number;
  7568. protected _id: number;
  7569. /**
  7570. * Instantiates a Smart Array.
  7571. * @param capacity defines the default capacity of the array.
  7572. */
  7573. constructor(capacity: number);
  7574. /**
  7575. * Pushes a value at the end of the active data.
  7576. * @param value defines the object to push in the array.
  7577. */
  7578. push(value: T): void;
  7579. /**
  7580. * Iterates over the active data and apply the lambda to them.
  7581. * @param func defines the action to apply on each value.
  7582. */
  7583. forEach(func: (content: T) => void): void;
  7584. /**
  7585. * Sorts the full sets of data.
  7586. * @param compareFn defines the comparison function to apply.
  7587. */
  7588. sort(compareFn: (a: T, b: T) => number): void;
  7589. /**
  7590. * Resets the active data to an empty array.
  7591. */
  7592. reset(): void;
  7593. /**
  7594. * Releases all the data from the array as well as the array.
  7595. */
  7596. dispose(): void;
  7597. /**
  7598. * Concats the active data with a given array.
  7599. * @param array defines the data to concatenate with.
  7600. */
  7601. concat(array: any): void;
  7602. /**
  7603. * Returns the position of a value in the active data.
  7604. * @param value defines the value to find the index for
  7605. * @returns the index if found in the active data otherwise -1
  7606. */
  7607. indexOf(value: T): number;
  7608. /**
  7609. * Returns whether an element is part of the active data.
  7610. * @param value defines the value to look for
  7611. * @returns true if found in the active data otherwise false
  7612. */
  7613. contains(value: T): boolean;
  7614. private static _GlobalId;
  7615. }
  7616. /**
  7617. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7618. * The data in this array can only be present once
  7619. */
  7620. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7621. private _duplicateId;
  7622. /**
  7623. * Pushes a value at the end of the active data.
  7624. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7625. * @param value defines the object to push in the array.
  7626. */
  7627. push(value: T): void;
  7628. /**
  7629. * Pushes a value at the end of the active data.
  7630. * If the data is already present, it won t be added again
  7631. * @param value defines the object to push in the array.
  7632. * @returns true if added false if it was already present
  7633. */
  7634. pushNoDuplicate(value: T): boolean;
  7635. /**
  7636. * Resets the active data to an empty array.
  7637. */
  7638. reset(): void;
  7639. /**
  7640. * Concats the active data with a given array.
  7641. * This ensures no dupplicate will be present in the result.
  7642. * @param array defines the data to concatenate with.
  7643. */
  7644. concatWithNoDuplicate(array: any): void;
  7645. }
  7646. }
  7647. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7648. import { Nullable } from "babylonjs/types";
  7649. import { Scene } from "babylonjs/scene";
  7650. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. /**
  7675. * Returns the bounding box size
  7676. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7677. */
  7678. boundingBoxSize: Vector3;
  7679. protected _rotationY: number;
  7680. /**
  7681. * Sets texture matrix rotation angle around Y axis in radians.
  7682. */
  7683. /**
  7684. * Gets texture matrix rotation angle around Y axis radians.
  7685. */
  7686. rotationY: number;
  7687. /**
  7688. * Are mip maps generated for this texture or not.
  7689. */
  7690. readonly noMipmap: boolean;
  7691. private _noMipmap;
  7692. private _files;
  7693. private _extensions;
  7694. private _textureMatrix;
  7695. private _format;
  7696. private _createPolynomials;
  7697. /** @hidden */
  7698. _prefiltered: boolean;
  7699. /**
  7700. * Creates a cube texture from an array of image urls
  7701. * @param files defines an array of image urls
  7702. * @param scene defines the hosting scene
  7703. * @param noMipmap specifies if mip maps are not used
  7704. * @returns a cube texture
  7705. */
  7706. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7707. /**
  7708. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7709. * @param url defines the url of the prefiltered texture
  7710. * @param scene defines the scene the texture is attached to
  7711. * @param forcedExtension defines the extension of the file if different from the url
  7712. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7713. * @return the prefiltered texture
  7714. */
  7715. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7716. /**
  7717. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7718. * as prefiltered data.
  7719. * @param rootUrl defines the url of the texture or the root name of the six images
  7720. * @param scene defines the scene the texture is attached to
  7721. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7722. * @param noMipmap defines if mipmaps should be created or not
  7723. * @param files defines the six files to load for the different faces
  7724. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7725. * @param onError defines a callback triggered in case of error during load
  7726. * @param format defines the internal format to use for the texture once loaded
  7727. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7728. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7729. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @return the cube texture
  7733. */
  7734. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7735. /**
  7736. * Get the current class name of the texture useful for serialization or dynamic coding.
  7737. * @returns "CubeTexture"
  7738. */
  7739. getClassName(): string;
  7740. /**
  7741. * Update the url (and optional buffer) of this texture if url was null during construction.
  7742. * @param url the url of the texture
  7743. * @param forcedExtension defines the extension to use
  7744. * @param onLoad callback called when the texture is loaded (defaults to null)
  7745. */
  7746. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7747. /**
  7748. * Delays loading of the cube texture
  7749. * @param forcedExtension defines the extension to use
  7750. */
  7751. delayLoad(forcedExtension?: string): void;
  7752. /**
  7753. * Returns the reflection texture matrix
  7754. * @returns the reflection texture matrix
  7755. */
  7756. getReflectionTextureMatrix(): Matrix;
  7757. /**
  7758. * Sets the reflection texture matrix
  7759. * @param value Reflection texture matrix
  7760. */
  7761. setReflectionTextureMatrix(value: Matrix): void;
  7762. /**
  7763. * Parses text to create a cube texture
  7764. * @param parsedTexture define the serialized text to read from
  7765. * @param scene defines the hosting scene
  7766. * @param rootUrl defines the root url of the cube texture
  7767. * @returns a cube texture
  7768. */
  7769. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7770. /**
  7771. * Makes a clone, or deep copy, of the cube texture
  7772. * @returns a new cube texture
  7773. */
  7774. clone(): CubeTexture;
  7775. }
  7776. }
  7777. declare module "babylonjs/Shaders/postprocess.vertex" {
  7778. /** @hidden */
  7779. export var postprocessVertexShader: {
  7780. name: string;
  7781. shader: string;
  7782. };
  7783. }
  7784. declare module "babylonjs/Cameras/targetCamera" {
  7785. import { Nullable } from "babylonjs/types";
  7786. import { Camera } from "babylonjs/Cameras/camera";
  7787. import { Scene } from "babylonjs/scene";
  7788. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7789. /**
  7790. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7791. * This is the base of the follow, arc rotate cameras and Free camera
  7792. * @see http://doc.babylonjs.com/features/cameras
  7793. */
  7794. export class TargetCamera extends Camera {
  7795. private static _RigCamTransformMatrix;
  7796. private static _TargetTransformMatrix;
  7797. private static _TargetFocalPoint;
  7798. /**
  7799. * Define the current direction the camera is moving to
  7800. */
  7801. cameraDirection: Vector3;
  7802. /**
  7803. * Define the current rotation the camera is rotating to
  7804. */
  7805. cameraRotation: Vector2;
  7806. /**
  7807. * When set, the up vector of the camera will be updated by the rotation of the camera
  7808. */
  7809. updateUpVectorFromRotation: boolean;
  7810. private _tmpQuaternion;
  7811. /**
  7812. * Define the current rotation of the camera
  7813. */
  7814. rotation: Vector3;
  7815. /**
  7816. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7817. */
  7818. rotationQuaternion: Quaternion;
  7819. /**
  7820. * Define the current speed of the camera
  7821. */
  7822. speed: number;
  7823. /**
  7824. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7825. * around all axis.
  7826. */
  7827. noRotationConstraint: boolean;
  7828. /**
  7829. * Define the current target of the camera as an object or a position.
  7830. */
  7831. lockedTarget: any;
  7832. /** @hidden */
  7833. _currentTarget: Vector3;
  7834. /** @hidden */
  7835. _initialFocalDistance: number;
  7836. /** @hidden */
  7837. _viewMatrix: Matrix;
  7838. /** @hidden */
  7839. _camMatrix: Matrix;
  7840. /** @hidden */
  7841. _cameraTransformMatrix: Matrix;
  7842. /** @hidden */
  7843. _cameraRotationMatrix: Matrix;
  7844. /** @hidden */
  7845. _referencePoint: Vector3;
  7846. /** @hidden */
  7847. _transformedReferencePoint: Vector3;
  7848. protected _globalCurrentTarget: Vector3;
  7849. protected _globalCurrentUpVector: Vector3;
  7850. /** @hidden */
  7851. _reset: () => void;
  7852. private _defaultUp;
  7853. /**
  7854. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7855. * This is the base of the follow, arc rotate cameras and Free camera
  7856. * @see http://doc.babylonjs.com/features/cameras
  7857. * @param name Defines the name of the camera in the scene
  7858. * @param position Defines the start position of the camera in the scene
  7859. * @param scene Defines the scene the camera belongs to
  7860. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7861. */
  7862. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7863. /**
  7864. * Gets the position in front of the camera at a given distance.
  7865. * @param distance The distance from the camera we want the position to be
  7866. * @returns the position
  7867. */
  7868. getFrontPosition(distance: number): Vector3;
  7869. /** @hidden */
  7870. _getLockedTargetPosition(): Nullable<Vector3>;
  7871. private _storedPosition;
  7872. private _storedRotation;
  7873. private _storedRotationQuaternion;
  7874. /**
  7875. * Store current camera state of the camera (fov, position, rotation, etc..)
  7876. * @returns the camera
  7877. */
  7878. storeState(): Camera;
  7879. /**
  7880. * Restored camera state. You must call storeState() first
  7881. * @returns whether it was successful or not
  7882. * @hidden
  7883. */
  7884. _restoreStateValues(): boolean;
  7885. /** @hidden */
  7886. _initCache(): void;
  7887. /** @hidden */
  7888. _updateCache(ignoreParentClass?: boolean): void;
  7889. /** @hidden */
  7890. _isSynchronizedViewMatrix(): boolean;
  7891. /** @hidden */
  7892. _computeLocalCameraSpeed(): number;
  7893. /** @hidden */
  7894. setTarget(target: Vector3): void;
  7895. /**
  7896. * Return the current target position of the camera. This value is expressed in local space.
  7897. * @returns the target position
  7898. */
  7899. getTarget(): Vector3;
  7900. /** @hidden */
  7901. _decideIfNeedsToMove(): boolean;
  7902. /** @hidden */
  7903. _updatePosition(): void;
  7904. /** @hidden */
  7905. _checkInputs(): void;
  7906. protected _updateCameraRotationMatrix(): void;
  7907. /**
  7908. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  7909. * @returns the current camera
  7910. */
  7911. private _rotateUpVectorWithCameraRotationMatrix;
  7912. private _cachedRotationZ;
  7913. private _cachedQuaternionRotationZ;
  7914. /** @hidden */
  7915. _getViewMatrix(): Matrix;
  7916. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7917. /**
  7918. * @hidden
  7919. */
  7920. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7921. /**
  7922. * @hidden
  7923. */
  7924. _updateRigCameras(): void;
  7925. private _getRigCamPositionAndTarget;
  7926. /**
  7927. * Gets the current object class name.
  7928. * @return the class name
  7929. */
  7930. getClassName(): string;
  7931. }
  7932. }
  7933. declare module "babylonjs/Cameras/cameraInputsManager" {
  7934. import { Nullable } from "babylonjs/types";
  7935. import { Camera } from "babylonjs/Cameras/camera";
  7936. /**
  7937. * @ignore
  7938. * This is a list of all the different input types that are available in the application.
  7939. * Fo instance: ArcRotateCameraGamepadInput...
  7940. */
  7941. export var CameraInputTypes: {};
  7942. /**
  7943. * This is the contract to implement in order to create a new input class.
  7944. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7945. */
  7946. export interface ICameraInput<TCamera extends Camera> {
  7947. /**
  7948. * Defines the camera the input is attached to.
  7949. */
  7950. camera: Nullable<TCamera>;
  7951. /**
  7952. * Gets the class name of the current intput.
  7953. * @returns the class name
  7954. */
  7955. getClassName(): string;
  7956. /**
  7957. * Get the friendly name associated with the input class.
  7958. * @returns the input friendly name
  7959. */
  7960. getSimpleName(): string;
  7961. /**
  7962. * Attach the input controls to a specific dom element to get the input from.
  7963. * @param element Defines the element the controls should be listened from
  7964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7965. */
  7966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7967. /**
  7968. * Detach the current controls from the specified dom element.
  7969. * @param element Defines the element to stop listening the inputs from
  7970. */
  7971. detachControl(element: Nullable<HTMLElement>): void;
  7972. /**
  7973. * Update the current camera state depending on the inputs that have been used this frame.
  7974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7975. */
  7976. checkInputs?: () => void;
  7977. }
  7978. /**
  7979. * Represents a map of input types to input instance or input index to input instance.
  7980. */
  7981. export interface CameraInputsMap<TCamera extends Camera> {
  7982. /**
  7983. * Accessor to the input by input type.
  7984. */
  7985. [name: string]: ICameraInput<TCamera>;
  7986. /**
  7987. * Accessor to the input by input index.
  7988. */
  7989. [idx: number]: ICameraInput<TCamera>;
  7990. }
  7991. /**
  7992. * This represents the input manager used within a camera.
  7993. * It helps dealing with all the different kind of input attached to a camera.
  7994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7995. */
  7996. export class CameraInputsManager<TCamera extends Camera> {
  7997. /**
  7998. * Defines the list of inputs attahed to the camera.
  7999. */
  8000. attached: CameraInputsMap<TCamera>;
  8001. /**
  8002. * Defines the dom element the camera is collecting inputs from.
  8003. * This is null if the controls have not been attached.
  8004. */
  8005. attachedElement: Nullable<HTMLElement>;
  8006. /**
  8007. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8008. */
  8009. noPreventDefault: boolean;
  8010. /**
  8011. * Defined the camera the input manager belongs to.
  8012. */
  8013. camera: TCamera;
  8014. /**
  8015. * Update the current camera state depending on the inputs that have been used this frame.
  8016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8017. */
  8018. checkInputs: () => void;
  8019. /**
  8020. * Instantiate a new Camera Input Manager.
  8021. * @param camera Defines the camera the input manager blongs to
  8022. */
  8023. constructor(camera: TCamera);
  8024. /**
  8025. * Add an input method to a camera
  8026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8027. * @param input camera input method
  8028. */
  8029. add(input: ICameraInput<TCamera>): void;
  8030. /**
  8031. * Remove a specific input method from a camera
  8032. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8033. * @param inputToRemove camera input method
  8034. */
  8035. remove(inputToRemove: ICameraInput<TCamera>): void;
  8036. /**
  8037. * Remove a specific input type from a camera
  8038. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8039. * @param inputType the type of the input to remove
  8040. */
  8041. removeByType(inputType: string): void;
  8042. private _addCheckInputs;
  8043. /**
  8044. * Attach the input controls to the currently attached dom element to listen the events from.
  8045. * @param input Defines the input to attach
  8046. */
  8047. attachInput(input: ICameraInput<TCamera>): void;
  8048. /**
  8049. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8050. * @param element Defines the dom element to collect the events from
  8051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8052. */
  8053. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8054. /**
  8055. * Detach the current manager inputs controls from a specific dom element.
  8056. * @param element Defines the dom element to collect the events from
  8057. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8058. */
  8059. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8060. /**
  8061. * Rebuild the dynamic inputCheck function from the current list of
  8062. * defined inputs in the manager.
  8063. */
  8064. rebuildInputCheck(): void;
  8065. /**
  8066. * Remove all attached input methods from a camera
  8067. */
  8068. clear(): void;
  8069. /**
  8070. * Serialize the current input manager attached to a camera.
  8071. * This ensures than once parsed,
  8072. * the input associated to the camera will be identical to the current ones
  8073. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8074. */
  8075. serialize(serializedCamera: any): void;
  8076. /**
  8077. * Parses an input manager serialized JSON to restore the previous list of inputs
  8078. * and states associated to a camera.
  8079. * @param parsedCamera Defines the JSON to parse
  8080. */
  8081. parse(parsedCamera: any): void;
  8082. }
  8083. }
  8084. declare module "babylonjs/Events/keyboardEvents" {
  8085. /**
  8086. * Gather the list of keyboard event types as constants.
  8087. */
  8088. export class KeyboardEventTypes {
  8089. /**
  8090. * The keydown event is fired when a key becomes active (pressed).
  8091. */
  8092. static readonly KEYDOWN: number;
  8093. /**
  8094. * The keyup event is fired when a key has been released.
  8095. */
  8096. static readonly KEYUP: number;
  8097. }
  8098. /**
  8099. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8100. */
  8101. export class KeyboardInfo {
  8102. /**
  8103. * Defines the type of event (KeyboardEventTypes)
  8104. */
  8105. type: number;
  8106. /**
  8107. * Defines the related dom event
  8108. */
  8109. event: KeyboardEvent;
  8110. /**
  8111. * Instantiates a new keyboard info.
  8112. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8113. * @param type Defines the type of event (KeyboardEventTypes)
  8114. * @param event Defines the related dom event
  8115. */
  8116. constructor(
  8117. /**
  8118. * Defines the type of event (KeyboardEventTypes)
  8119. */
  8120. type: number,
  8121. /**
  8122. * Defines the related dom event
  8123. */
  8124. event: KeyboardEvent);
  8125. }
  8126. /**
  8127. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8128. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8129. */
  8130. export class KeyboardInfoPre extends KeyboardInfo {
  8131. /**
  8132. * Defines the type of event (KeyboardEventTypes)
  8133. */
  8134. type: number;
  8135. /**
  8136. * Defines the related dom event
  8137. */
  8138. event: KeyboardEvent;
  8139. /**
  8140. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8141. */
  8142. skipOnPointerObservable: boolean;
  8143. /**
  8144. * Instantiates a new keyboard pre info.
  8145. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8146. * @param type Defines the type of event (KeyboardEventTypes)
  8147. * @param event Defines the related dom event
  8148. */
  8149. constructor(
  8150. /**
  8151. * Defines the type of event (KeyboardEventTypes)
  8152. */
  8153. type: number,
  8154. /**
  8155. * Defines the related dom event
  8156. */
  8157. event: KeyboardEvent);
  8158. }
  8159. }
  8160. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8161. import { Nullable } from "babylonjs/types";
  8162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8164. /**
  8165. * Manage the keyboard inputs to control the movement of a free camera.
  8166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8167. */
  8168. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8169. /**
  8170. * Defines the camera the input is attached to.
  8171. */
  8172. camera: FreeCamera;
  8173. /**
  8174. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8175. */
  8176. keysUp: number[];
  8177. /**
  8178. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8179. */
  8180. keysDown: number[];
  8181. /**
  8182. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8183. */
  8184. keysLeft: number[];
  8185. /**
  8186. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8187. */
  8188. keysRight: number[];
  8189. private _keys;
  8190. private _onCanvasBlurObserver;
  8191. private _onKeyboardObserver;
  8192. private _engine;
  8193. private _scene;
  8194. /**
  8195. * Attach the input controls to a specific dom element to get the input from.
  8196. * @param element Defines the element the controls should be listened from
  8197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8198. */
  8199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8200. /**
  8201. * Detach the current controls from the specified dom element.
  8202. * @param element Defines the element to stop listening the inputs from
  8203. */
  8204. detachControl(element: Nullable<HTMLElement>): void;
  8205. /**
  8206. * Update the current camera state depending on the inputs that have been used this frame.
  8207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8208. */
  8209. checkInputs(): void;
  8210. /**
  8211. * Gets the class name of the current intput.
  8212. * @returns the class name
  8213. */
  8214. getClassName(): string;
  8215. /** @hidden */
  8216. _onLostFocus(): void;
  8217. /**
  8218. * Get the friendly name associated with the input class.
  8219. * @returns the input friendly name
  8220. */
  8221. getSimpleName(): string;
  8222. }
  8223. }
  8224. declare module "babylonjs/Events/pointerEvents" {
  8225. import { Nullable } from "babylonjs/types";
  8226. import { Vector2 } from "babylonjs/Maths/math";
  8227. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  8228. import { Ray } from "babylonjs/Culling/ray";
  8229. /**
  8230. * Gather the list of pointer event types as constants.
  8231. */
  8232. export class PointerEventTypes {
  8233. /**
  8234. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  8235. */
  8236. static readonly POINTERDOWN: number;
  8237. /**
  8238. * The pointerup event is fired when a pointer is no longer active.
  8239. */
  8240. static readonly POINTERUP: number;
  8241. /**
  8242. * The pointermove event is fired when a pointer changes coordinates.
  8243. */
  8244. static readonly POINTERMOVE: number;
  8245. /**
  8246. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8247. */
  8248. static readonly POINTERWHEEL: number;
  8249. /**
  8250. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8251. */
  8252. static readonly POINTERPICK: number;
  8253. /**
  8254. * The pointertap event is fired when a the object has been touched and released without drag.
  8255. */
  8256. static readonly POINTERTAP: number;
  8257. /**
  8258. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8259. */
  8260. static readonly POINTERDOUBLETAP: number;
  8261. }
  8262. /**
  8263. * Base class of pointer info types.
  8264. */
  8265. export class PointerInfoBase {
  8266. /**
  8267. * Defines the type of event (PointerEventTypes)
  8268. */
  8269. type: number;
  8270. /**
  8271. * Defines the related dom event
  8272. */
  8273. event: PointerEvent | MouseWheelEvent;
  8274. /**
  8275. * Instantiates the base class of pointers info.
  8276. * @param type Defines the type of event (PointerEventTypes)
  8277. * @param event Defines the related dom event
  8278. */
  8279. constructor(
  8280. /**
  8281. * Defines the type of event (PointerEventTypes)
  8282. */
  8283. type: number,
  8284. /**
  8285. * Defines the related dom event
  8286. */
  8287. event: PointerEvent | MouseWheelEvent);
  8288. }
  8289. /**
  8290. * This class is used to store pointer related info for the onPrePointerObservable event.
  8291. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8292. */
  8293. export class PointerInfoPre extends PointerInfoBase {
  8294. /**
  8295. * Ray from a pointer if availible (eg. 6dof controller)
  8296. */
  8297. ray: Nullable<Ray>;
  8298. /**
  8299. * Defines the local position of the pointer on the canvas.
  8300. */
  8301. localPosition: Vector2;
  8302. /**
  8303. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8304. */
  8305. skipOnPointerObservable: boolean;
  8306. /**
  8307. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8308. * @param type Defines the type of event (PointerEventTypes)
  8309. * @param event Defines the related dom event
  8310. * @param localX Defines the local x coordinates of the pointer when the event occured
  8311. * @param localY Defines the local y coordinates of the pointer when the event occured
  8312. */
  8313. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8314. }
  8315. /**
  8316. * This type contains all the data related to a pointer event in Babylon.js.
  8317. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  8318. */
  8319. export class PointerInfo extends PointerInfoBase {
  8320. /**
  8321. * Defines the picking info associated to the info (if any)\
  8322. */
  8323. pickInfo: Nullable<PickingInfo>;
  8324. /**
  8325. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8326. * @param type Defines the type of event (PointerEventTypes)
  8327. * @param event Defines the related dom event
  8328. * @param pickInfo Defines the picking info associated to the info (if any)\
  8329. */
  8330. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8331. /**
  8332. * Defines the picking info associated to the info (if any)\
  8333. */
  8334. pickInfo: Nullable<PickingInfo>);
  8335. }
  8336. }
  8337. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  8338. import { Nullable } from "babylonjs/types";
  8339. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8340. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8341. /**
  8342. * Manage the mouse inputs to control the movement of a free camera.
  8343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8344. */
  8345. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8346. /**
  8347. * Define if touch is enabled in the mouse input
  8348. */
  8349. touchEnabled: boolean;
  8350. /**
  8351. * Defines the camera the input is attached to.
  8352. */
  8353. camera: FreeCamera;
  8354. /**
  8355. * Defines the buttons associated with the input to handle camera move.
  8356. */
  8357. buttons: number[];
  8358. /**
  8359. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8360. */
  8361. angularSensibility: number;
  8362. private _pointerInput;
  8363. private _onMouseMove;
  8364. private _observer;
  8365. private previousPosition;
  8366. /**
  8367. * Manage the mouse inputs to control the movement of a free camera.
  8368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8369. * @param touchEnabled Defines if touch is enabled or not
  8370. */
  8371. constructor(
  8372. /**
  8373. * Define if touch is enabled in the mouse input
  8374. */
  8375. touchEnabled?: boolean);
  8376. /**
  8377. * Attach the input controls to a specific dom element to get the input from.
  8378. * @param element Defines the element the controls should be listened from
  8379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8380. */
  8381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8382. /**
  8383. * Detach the current controls from the specified dom element.
  8384. * @param element Defines the element to stop listening the inputs from
  8385. */
  8386. detachControl(element: Nullable<HTMLElement>): void;
  8387. /**
  8388. * Gets the class name of the current intput.
  8389. * @returns the class name
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Get the friendly name associated with the input class.
  8394. * @returns the input friendly name
  8395. */
  8396. getSimpleName(): string;
  8397. }
  8398. }
  8399. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  8400. import { Nullable } from "babylonjs/types";
  8401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8402. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8403. /**
  8404. * Manage the touch inputs to control the movement of a free camera.
  8405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8406. */
  8407. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8408. /**
  8409. * Defines the camera the input is attached to.
  8410. */
  8411. camera: FreeCamera;
  8412. /**
  8413. * Defines the touch sensibility for rotation.
  8414. * The higher the faster.
  8415. */
  8416. touchAngularSensibility: number;
  8417. /**
  8418. * Defines the touch sensibility for move.
  8419. * The higher the faster.
  8420. */
  8421. touchMoveSensibility: number;
  8422. private _offsetX;
  8423. private _offsetY;
  8424. private _pointerPressed;
  8425. private _pointerInput;
  8426. private _observer;
  8427. private _onLostFocus;
  8428. /**
  8429. * Attach the input controls to a specific dom element to get the input from.
  8430. * @param element Defines the element the controls should be listened from
  8431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8432. */
  8433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8434. /**
  8435. * Detach the current controls from the specified dom element.
  8436. * @param element Defines the element to stop listening the inputs from
  8437. */
  8438. detachControl(element: Nullable<HTMLElement>): void;
  8439. /**
  8440. * Update the current camera state depending on the inputs that have been used this frame.
  8441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8442. */
  8443. checkInputs(): void;
  8444. /**
  8445. * Gets the class name of the current intput.
  8446. * @returns the class name
  8447. */
  8448. getClassName(): string;
  8449. /**
  8450. * Get the friendly name associated with the input class.
  8451. * @returns the input friendly name
  8452. */
  8453. getSimpleName(): string;
  8454. }
  8455. }
  8456. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  8457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8458. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  8459. /**
  8460. * Default Inputs manager for the FreeCamera.
  8461. * It groups all the default supported inputs for ease of use.
  8462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8463. */
  8464. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8465. /**
  8466. * Instantiates a new FreeCameraInputsManager.
  8467. * @param camera Defines the camera the inputs belong to
  8468. */
  8469. constructor(camera: FreeCamera);
  8470. /**
  8471. * Add keyboard input support to the input manager.
  8472. * @returns the current input manager
  8473. */
  8474. addKeyboard(): FreeCameraInputsManager;
  8475. /**
  8476. * Add mouse input support to the input manager.
  8477. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8478. * @returns the current input manager
  8479. */
  8480. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8481. /**
  8482. * Add touch input support to the input manager.
  8483. * @returns the current input manager
  8484. */
  8485. addTouch(): FreeCameraInputsManager;
  8486. }
  8487. }
  8488. declare module "babylonjs/Cameras/freeCamera" {
  8489. import { Vector3 } from "babylonjs/Maths/math";
  8490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8491. import { Scene } from "babylonjs/scene";
  8492. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  8493. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  8494. /**
  8495. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8496. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8498. */
  8499. export class FreeCamera extends TargetCamera {
  8500. /**
  8501. * Define the collision ellipsoid of the camera.
  8502. * This is helpful to simulate a camera body like the player body around the camera
  8503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8504. */
  8505. ellipsoid: Vector3;
  8506. /**
  8507. * Define an offset for the position of the ellipsoid around the camera.
  8508. * This can be helpful to determine the center of the body near the gravity center of the body
  8509. * instead of its head.
  8510. */
  8511. ellipsoidOffset: Vector3;
  8512. /**
  8513. * Enable or disable collisions of the camera with the rest of the scene objects.
  8514. */
  8515. checkCollisions: boolean;
  8516. /**
  8517. * Enable or disable gravity on the camera.
  8518. */
  8519. applyGravity: boolean;
  8520. /**
  8521. * Define the input manager associated to the camera.
  8522. */
  8523. inputs: FreeCameraInputsManager;
  8524. /**
  8525. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8526. * Higher values reduce sensitivity.
  8527. */
  8528. /**
  8529. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8530. * Higher values reduce sensitivity.
  8531. */
  8532. angularSensibility: number;
  8533. /**
  8534. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8535. */
  8536. keysUp: number[];
  8537. /**
  8538. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8539. */
  8540. keysDown: number[];
  8541. /**
  8542. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8543. */
  8544. keysLeft: number[];
  8545. /**
  8546. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8547. */
  8548. keysRight: number[];
  8549. /**
  8550. * Event raised when the camera collide with a mesh in the scene.
  8551. */
  8552. onCollide: (collidedMesh: AbstractMesh) => void;
  8553. private _collider;
  8554. private _needMoveForGravity;
  8555. private _oldPosition;
  8556. private _diffPosition;
  8557. private _newPosition;
  8558. /** @hidden */
  8559. _localDirection: Vector3;
  8560. /** @hidden */
  8561. _transformedDirection: Vector3;
  8562. /**
  8563. * Instantiates a Free Camera.
  8564. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8565. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8566. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8567. * @param name Define the name of the camera in the scene
  8568. * @param position Define the start position of the camera in the scene
  8569. * @param scene Define the scene the camera belongs to
  8570. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8571. */
  8572. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8573. /**
  8574. * Attached controls to the current camera.
  8575. * @param element Defines the element the controls should be listened from
  8576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8577. */
  8578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8579. /**
  8580. * Detach the current controls from the camera.
  8581. * The camera will stop reacting to inputs.
  8582. * @param element Defines the element to stop listening the inputs from
  8583. */
  8584. detachControl(element: HTMLElement): void;
  8585. private _collisionMask;
  8586. /**
  8587. * Define a collision mask to limit the list of object the camera can collide with
  8588. */
  8589. collisionMask: number;
  8590. /** @hidden */
  8591. _collideWithWorld(displacement: Vector3): void;
  8592. private _onCollisionPositionChange;
  8593. /** @hidden */
  8594. _checkInputs(): void;
  8595. /** @hidden */
  8596. _decideIfNeedsToMove(): boolean;
  8597. /** @hidden */
  8598. _updatePosition(): void;
  8599. /**
  8600. * Destroy the camera and release the current resources hold by it.
  8601. */
  8602. dispose(): void;
  8603. /**
  8604. * Gets the current object class name.
  8605. * @return the class name
  8606. */
  8607. getClassName(): string;
  8608. }
  8609. }
  8610. declare module "babylonjs/Gamepads/gamepad" {
  8611. import { Observable } from "babylonjs/Misc/observable";
  8612. /**
  8613. * Represents a gamepad control stick position
  8614. */
  8615. export class StickValues {
  8616. /**
  8617. * The x component of the control stick
  8618. */
  8619. x: number;
  8620. /**
  8621. * The y component of the control stick
  8622. */
  8623. y: number;
  8624. /**
  8625. * Initializes the gamepad x and y control stick values
  8626. * @param x The x component of the gamepad control stick value
  8627. * @param y The y component of the gamepad control stick value
  8628. */
  8629. constructor(
  8630. /**
  8631. * The x component of the control stick
  8632. */
  8633. x: number,
  8634. /**
  8635. * The y component of the control stick
  8636. */
  8637. y: number);
  8638. }
  8639. /**
  8640. * An interface which manages callbacks for gamepad button changes
  8641. */
  8642. export interface GamepadButtonChanges {
  8643. /**
  8644. * Called when a gamepad has been changed
  8645. */
  8646. changed: boolean;
  8647. /**
  8648. * Called when a gamepad press event has been triggered
  8649. */
  8650. pressChanged: boolean;
  8651. /**
  8652. * Called when a touch event has been triggered
  8653. */
  8654. touchChanged: boolean;
  8655. /**
  8656. * Called when a value has changed
  8657. */
  8658. valueChanged: boolean;
  8659. }
  8660. /**
  8661. * Represents a gamepad
  8662. */
  8663. export class Gamepad {
  8664. /**
  8665. * The id of the gamepad
  8666. */
  8667. id: string;
  8668. /**
  8669. * The index of the gamepad
  8670. */
  8671. index: number;
  8672. /**
  8673. * The browser gamepad
  8674. */
  8675. browserGamepad: any;
  8676. /**
  8677. * Specifies what type of gamepad this represents
  8678. */
  8679. type: number;
  8680. private _leftStick;
  8681. private _rightStick;
  8682. /** @hidden */
  8683. _isConnected: boolean;
  8684. private _leftStickAxisX;
  8685. private _leftStickAxisY;
  8686. private _rightStickAxisX;
  8687. private _rightStickAxisY;
  8688. /**
  8689. * Triggered when the left control stick has been changed
  8690. */
  8691. private _onleftstickchanged;
  8692. /**
  8693. * Triggered when the right control stick has been changed
  8694. */
  8695. private _onrightstickchanged;
  8696. /**
  8697. * Represents a gamepad controller
  8698. */
  8699. static GAMEPAD: number;
  8700. /**
  8701. * Represents a generic controller
  8702. */
  8703. static GENERIC: number;
  8704. /**
  8705. * Represents an XBox controller
  8706. */
  8707. static XBOX: number;
  8708. /**
  8709. * Represents a pose-enabled controller
  8710. */
  8711. static POSE_ENABLED: number;
  8712. /**
  8713. * Specifies whether the left control stick should be Y-inverted
  8714. */
  8715. protected _invertLeftStickY: boolean;
  8716. /**
  8717. * Specifies if the gamepad has been connected
  8718. */
  8719. readonly isConnected: boolean;
  8720. /**
  8721. * Initializes the gamepad
  8722. * @param id The id of the gamepad
  8723. * @param index The index of the gamepad
  8724. * @param browserGamepad The browser gamepad
  8725. * @param leftStickX The x component of the left joystick
  8726. * @param leftStickY The y component of the left joystick
  8727. * @param rightStickX The x component of the right joystick
  8728. * @param rightStickY The y component of the right joystick
  8729. */
  8730. constructor(
  8731. /**
  8732. * The id of the gamepad
  8733. */
  8734. id: string,
  8735. /**
  8736. * The index of the gamepad
  8737. */
  8738. index: number,
  8739. /**
  8740. * The browser gamepad
  8741. */
  8742. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8743. /**
  8744. * Callback triggered when the left joystick has changed
  8745. * @param callback
  8746. */
  8747. onleftstickchanged(callback: (values: StickValues) => void): void;
  8748. /**
  8749. * Callback triggered when the right joystick has changed
  8750. * @param callback
  8751. */
  8752. onrightstickchanged(callback: (values: StickValues) => void): void;
  8753. /**
  8754. * Gets the left joystick
  8755. */
  8756. /**
  8757. * Sets the left joystick values
  8758. */
  8759. leftStick: StickValues;
  8760. /**
  8761. * Gets the right joystick
  8762. */
  8763. /**
  8764. * Sets the right joystick value
  8765. */
  8766. rightStick: StickValues;
  8767. /**
  8768. * Updates the gamepad joystick positions
  8769. */
  8770. update(): void;
  8771. /**
  8772. * Disposes the gamepad
  8773. */
  8774. dispose(): void;
  8775. }
  8776. /**
  8777. * Represents a generic gamepad
  8778. */
  8779. export class GenericPad extends Gamepad {
  8780. private _buttons;
  8781. private _onbuttondown;
  8782. private _onbuttonup;
  8783. /**
  8784. * Observable triggered when a button has been pressed
  8785. */
  8786. onButtonDownObservable: Observable<number>;
  8787. /**
  8788. * Observable triggered when a button has been released
  8789. */
  8790. onButtonUpObservable: Observable<number>;
  8791. /**
  8792. * Callback triggered when a button has been pressed
  8793. * @param callback Called when a button has been pressed
  8794. */
  8795. onbuttondown(callback: (buttonPressed: number) => void): void;
  8796. /**
  8797. * Callback triggered when a button has been released
  8798. * @param callback Called when a button has been released
  8799. */
  8800. onbuttonup(callback: (buttonReleased: number) => void): void;
  8801. /**
  8802. * Initializes the generic gamepad
  8803. * @param id The id of the generic gamepad
  8804. * @param index The index of the generic gamepad
  8805. * @param browserGamepad The browser gamepad
  8806. */
  8807. constructor(id: string, index: number, browserGamepad: any);
  8808. private _setButtonValue;
  8809. /**
  8810. * Updates the generic gamepad
  8811. */
  8812. update(): void;
  8813. /**
  8814. * Disposes the generic gamepad
  8815. */
  8816. dispose(): void;
  8817. }
  8818. }
  8819. declare module "babylonjs/Materials/Textures/rawTexture" {
  8820. import { Scene } from "babylonjs/scene";
  8821. import { Texture } from "babylonjs/Materials/Textures/texture";
  8822. /**
  8823. * Raw texture can help creating a texture directly from an array of data.
  8824. * This can be super useful if you either get the data from an uncompressed source or
  8825. * if you wish to create your texture pixel by pixel.
  8826. */
  8827. export class RawTexture extends Texture {
  8828. /**
  8829. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8830. */
  8831. format: number;
  8832. private _engine;
  8833. /**
  8834. * Instantiates a new RawTexture.
  8835. * Raw texture can help creating a texture directly from an array of data.
  8836. * This can be super useful if you either get the data from an uncompressed source or
  8837. * if you wish to create your texture pixel by pixel.
  8838. * @param data define the array of data to use to create the texture
  8839. * @param width define the width of the texture
  8840. * @param height define the height of the texture
  8841. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8842. * @param scene define the scene the texture belongs to
  8843. * @param generateMipMaps define whether mip maps should be generated or not
  8844. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8845. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8846. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8847. */
  8848. constructor(data: ArrayBufferView, width: number, height: number,
  8849. /**
  8850. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8851. */
  8852. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  8853. /**
  8854. * Updates the texture underlying data.
  8855. * @param data Define the new data of the texture
  8856. */
  8857. update(data: ArrayBufferView): void;
  8858. /**
  8859. * Creates a luminance texture from some data.
  8860. * @param data Define the texture data
  8861. * @param width Define the width of the texture
  8862. * @param height Define the height of the texture
  8863. * @param scene Define the scene the texture belongs to
  8864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8867. * @returns the luminance texture
  8868. */
  8869. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8870. /**
  8871. * Creates a luminance alpha texture from some data.
  8872. * @param data Define the texture data
  8873. * @param width Define the width of the texture
  8874. * @param height Define the height of the texture
  8875. * @param scene Define the scene the texture belongs to
  8876. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8877. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8878. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8879. * @returns the luminance alpha texture
  8880. */
  8881. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8882. /**
  8883. * Creates an alpha texture from some data.
  8884. * @param data Define the texture data
  8885. * @param width Define the width of the texture
  8886. * @param height Define the height of the texture
  8887. * @param scene Define the scene the texture belongs to
  8888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8891. * @returns the alpha texture
  8892. */
  8893. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8894. /**
  8895. * Creates a RGB texture from some data.
  8896. * @param data Define the texture data
  8897. * @param width Define the width of the texture
  8898. * @param height Define the height of the texture
  8899. * @param scene Define the scene the texture belongs to
  8900. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8901. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8902. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8903. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8904. * @returns the RGB alpha texture
  8905. */
  8906. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8907. /**
  8908. * Creates a RGBA texture from some data.
  8909. * @param data Define the texture data
  8910. * @param width Define the width of the texture
  8911. * @param height Define the height of the texture
  8912. * @param scene Define the scene the texture belongs to
  8913. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8914. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8915. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8916. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8917. * @returns the RGBA texture
  8918. */
  8919. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8920. /**
  8921. * Creates a R texture from some data.
  8922. * @param data Define the texture data
  8923. * @param width Define the width of the texture
  8924. * @param height Define the height of the texture
  8925. * @param scene Define the scene the texture belongs to
  8926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8929. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8930. * @returns the R texture
  8931. */
  8932. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8933. }
  8934. }
  8935. declare module "babylonjs/Bones/skeleton" {
  8936. import { Bone } from "babylonjs/Bones/bone";
  8937. import { IAnimatable } from "babylonjs/Misc/tools";
  8938. import { Observable } from "babylonjs/Misc/observable";
  8939. import { Vector3, Matrix } from "babylonjs/Maths/math";
  8940. import { Scene } from "babylonjs/scene";
  8941. import { Nullable } from "babylonjs/types";
  8942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8943. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  8944. import { Animatable } from "babylonjs/Animations/animatable";
  8945. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8946. import { AnimationRange, Animation } from "babylonjs/Animations/animation";
  8947. /**
  8948. * Class used to handle skinning animations
  8949. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8950. */
  8951. export class Skeleton implements IAnimatable {
  8952. /** defines the skeleton name */
  8953. name: string;
  8954. /** defines the skeleton Id */
  8955. id: string;
  8956. /**
  8957. * Defines the list of child bones
  8958. */
  8959. bones: Bone[];
  8960. /**
  8961. * Defines an estimate of the dimension of the skeleton at rest
  8962. */
  8963. dimensionsAtRest: Vector3;
  8964. /**
  8965. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  8966. */
  8967. needInitialSkinMatrix: boolean;
  8968. /**
  8969. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  8970. */
  8971. overrideMesh: Nullable<AbstractMesh>;
  8972. /**
  8973. * Gets the list of animations attached to this skeleton
  8974. */
  8975. animations: Array<Animation>;
  8976. private _scene;
  8977. private _isDirty;
  8978. private _transformMatrices;
  8979. private _transformMatrixTexture;
  8980. private _meshesWithPoseMatrix;
  8981. private _animatables;
  8982. private _identity;
  8983. private _synchronizedWithMesh;
  8984. private _ranges;
  8985. private _lastAbsoluteTransformsUpdateId;
  8986. private _canUseTextureForBones;
  8987. /** @hidden */
  8988. _numBonesWithLinkedTransformNode: number;
  8989. /**
  8990. * Specifies if the skeleton should be serialized
  8991. */
  8992. doNotSerialize: boolean;
  8993. /**
  8994. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  8995. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  8996. */
  8997. useTextureToStoreBoneMatrices: boolean;
  8998. private _animationPropertiesOverride;
  8999. /**
  9000. * Gets or sets the animation properties override
  9001. */
  9002. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9003. /**
  9004. * An observable triggered before computing the skeleton's matrices
  9005. */
  9006. onBeforeComputeObservable: Observable<Skeleton>;
  9007. /**
  9008. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9009. */
  9010. readonly isUsingTextureForMatrices: boolean;
  9011. /**
  9012. * Creates a new skeleton
  9013. * @param name defines the skeleton name
  9014. * @param id defines the skeleton Id
  9015. * @param scene defines the hosting scene
  9016. */
  9017. constructor(
  9018. /** defines the skeleton name */
  9019. name: string,
  9020. /** defines the skeleton Id */
  9021. id: string, scene: Scene);
  9022. /**
  9023. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9024. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9025. * @returns a Float32Array containing matrices data
  9026. */
  9027. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9028. /**
  9029. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9030. * @returns a raw texture containing the data
  9031. */
  9032. getTransformMatrixTexture(): Nullable<RawTexture>;
  9033. /**
  9034. * Gets the current hosting scene
  9035. * @returns a scene object
  9036. */
  9037. getScene(): Scene;
  9038. /**
  9039. * Gets a string representing the current skeleton data
  9040. * @param fullDetails defines a boolean indicating if we want a verbose version
  9041. * @returns a string representing the current skeleton data
  9042. */
  9043. toString(fullDetails?: boolean): string;
  9044. /**
  9045. * Get bone's index searching by name
  9046. * @param name defines bone's name to search for
  9047. * @return the indice of the bone. Returns -1 if not found
  9048. */
  9049. getBoneIndexByName(name: string): number;
  9050. /**
  9051. * Creater a new animation range
  9052. * @param name defines the name of the range
  9053. * @param from defines the start key
  9054. * @param to defines the end key
  9055. */
  9056. createAnimationRange(name: string, from: number, to: number): void;
  9057. /**
  9058. * Delete a specific animation range
  9059. * @param name defines the name of the range
  9060. * @param deleteFrames defines if frames must be removed as well
  9061. */
  9062. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9063. /**
  9064. * Gets a specific animation range
  9065. * @param name defines the name of the range to look for
  9066. * @returns the requested animation range or null if not found
  9067. */
  9068. getAnimationRange(name: string): Nullable<AnimationRange>;
  9069. /**
  9070. * Gets the list of all animation ranges defined on this skeleton
  9071. * @returns an array
  9072. */
  9073. getAnimationRanges(): Nullable<AnimationRange>[];
  9074. /**
  9075. * Copy animation range from a source skeleton.
  9076. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9077. * @param source defines the source skeleton
  9078. * @param name defines the name of the range to copy
  9079. * @param rescaleAsRequired defines if rescaling must be applied if required
  9080. * @returns true if operation was successful
  9081. */
  9082. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9083. /**
  9084. * Forces the skeleton to go to rest pose
  9085. */
  9086. returnToRest(): void;
  9087. private _getHighestAnimationFrame;
  9088. /**
  9089. * Begin a specific animation range
  9090. * @param name defines the name of the range to start
  9091. * @param loop defines if looping must be turned on (false by default)
  9092. * @param speedRatio defines the speed ratio to apply (1 by default)
  9093. * @param onAnimationEnd defines a callback which will be called when animation will end
  9094. * @returns a new animatable
  9095. */
  9096. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  9097. /** @hidden */
  9098. _markAsDirty(): void;
  9099. /** @hidden */
  9100. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9101. /** @hidden */
  9102. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9103. private _computeTransformMatrices;
  9104. /**
  9105. * Build all resources required to render a skeleton
  9106. */
  9107. prepare(): void;
  9108. /**
  9109. * Gets the list of animatables currently running for this skeleton
  9110. * @returns an array of animatables
  9111. */
  9112. getAnimatables(): IAnimatable[];
  9113. /**
  9114. * Clone the current skeleton
  9115. * @param name defines the name of the new skeleton
  9116. * @param id defines the id of the enw skeleton
  9117. * @returns the new skeleton
  9118. */
  9119. clone(name: string, id: string): Skeleton;
  9120. /**
  9121. * Enable animation blending for this skeleton
  9122. * @param blendingSpeed defines the blending speed to apply
  9123. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9124. */
  9125. enableBlending(blendingSpeed?: number): void;
  9126. /**
  9127. * Releases all resources associated with the current skeleton
  9128. */
  9129. dispose(): void;
  9130. /**
  9131. * Serialize the skeleton in a JSON object
  9132. * @returns a JSON object
  9133. */
  9134. serialize(): any;
  9135. /**
  9136. * Creates a new skeleton from serialized data
  9137. * @param parsedSkeleton defines the serialized data
  9138. * @param scene defines the hosting scene
  9139. * @returns a new skeleton
  9140. */
  9141. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9142. /**
  9143. * Compute all node absolute transforms
  9144. * @param forceUpdate defines if computation must be done even if cache is up to date
  9145. */
  9146. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9147. /**
  9148. * Gets the root pose matrix
  9149. * @returns a matrix
  9150. */
  9151. getPoseMatrix(): Nullable<Matrix>;
  9152. /**
  9153. * Sorts bones per internal index
  9154. */
  9155. sortBones(): void;
  9156. private _sortBones;
  9157. }
  9158. }
  9159. declare module "babylonjs/Bones/bone" {
  9160. import { Skeleton } from "babylonjs/Bones/skeleton";
  9161. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  9162. import { Nullable } from "babylonjs/types";
  9163. import { Animation } from "babylonjs/Animations/animation";
  9164. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  9165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9167. import { Node } from "babylonjs/node";
  9168. /**
  9169. * Class used to store bone information
  9170. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9171. */
  9172. export class Bone extends Node {
  9173. /**
  9174. * defines the bone name
  9175. */
  9176. name: string;
  9177. private static _tmpVecs;
  9178. private static _tmpQuat;
  9179. private static _tmpMats;
  9180. /**
  9181. * Gets the list of child bones
  9182. */
  9183. children: Bone[];
  9184. /** Gets the animations associated with this bone */
  9185. animations: Animation[];
  9186. /**
  9187. * Gets or sets bone length
  9188. */
  9189. length: number;
  9190. /**
  9191. * @hidden Internal only
  9192. * Set this value to map this bone to a different index in the transform matrices
  9193. * Set this value to -1 to exclude the bone from the transform matrices
  9194. */
  9195. _index: Nullable<number>;
  9196. private _skeleton;
  9197. private _localMatrix;
  9198. private _restPose;
  9199. private _baseMatrix;
  9200. private _absoluteTransform;
  9201. private _invertedAbsoluteTransform;
  9202. private _parent;
  9203. private _scalingDeterminant;
  9204. private _worldTransform;
  9205. private _localScaling;
  9206. private _localRotation;
  9207. private _localPosition;
  9208. private _needToDecompose;
  9209. private _needToCompose;
  9210. /** @hidden */
  9211. _linkedTransformNode: Nullable<TransformNode>;
  9212. /** @hidden */
  9213. /** @hidden */
  9214. _matrix: Matrix;
  9215. /**
  9216. * Create a new bone
  9217. * @param name defines the bone name
  9218. * @param skeleton defines the parent skeleton
  9219. * @param parentBone defines the parent (can be null if the bone is the root)
  9220. * @param localMatrix defines the local matrix
  9221. * @param restPose defines the rest pose matrix
  9222. * @param baseMatrix defines the base matrix
  9223. * @param index defines index of the bone in the hiearchy
  9224. */
  9225. constructor(
  9226. /**
  9227. * defines the bone name
  9228. */
  9229. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9230. /**
  9231. * Gets the parent skeleton
  9232. * @returns a skeleton
  9233. */
  9234. getSkeleton(): Skeleton;
  9235. /**
  9236. * Gets parent bone
  9237. * @returns a bone or null if the bone is the root of the bone hierarchy
  9238. */
  9239. getParent(): Nullable<Bone>;
  9240. /**
  9241. * Sets the parent bone
  9242. * @param parent defines the parent (can be null if the bone is the root)
  9243. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9244. */
  9245. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9246. /**
  9247. * Gets the local matrix
  9248. * @returns a matrix
  9249. */
  9250. getLocalMatrix(): Matrix;
  9251. /**
  9252. * Gets the base matrix (initial matrix which remains unchanged)
  9253. * @returns a matrix
  9254. */
  9255. getBaseMatrix(): Matrix;
  9256. /**
  9257. * Gets the rest pose matrix
  9258. * @returns a matrix
  9259. */
  9260. getRestPose(): Matrix;
  9261. /**
  9262. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9263. */
  9264. getWorldMatrix(): Matrix;
  9265. /**
  9266. * Sets the local matrix to rest pose matrix
  9267. */
  9268. returnToRest(): void;
  9269. /**
  9270. * Gets the inverse of the absolute transform matrix.
  9271. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9272. * @returns a matrix
  9273. */
  9274. getInvertedAbsoluteTransform(): Matrix;
  9275. /**
  9276. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9277. * @returns a matrix
  9278. */
  9279. getAbsoluteTransform(): Matrix;
  9280. /**
  9281. * Links with the given transform node.
  9282. * The local matrix of this bone is copied from the transform node every frame.
  9283. * @param transformNode defines the transform node to link to
  9284. */
  9285. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9286. /** Gets or sets current position (in local space) */
  9287. position: Vector3;
  9288. /** Gets or sets current rotation (in local space) */
  9289. rotation: Vector3;
  9290. /** Gets or sets current rotation quaternion (in local space) */
  9291. rotationQuaternion: Quaternion;
  9292. /** Gets or sets current scaling (in local space) */
  9293. scaling: Vector3;
  9294. /**
  9295. * Gets the animation properties override
  9296. */
  9297. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9298. private _decompose;
  9299. private _compose;
  9300. /**
  9301. * Update the base and local matrices
  9302. * @param matrix defines the new base or local matrix
  9303. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9304. * @param updateLocalMatrix defines if the local matrix should be updated
  9305. */
  9306. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9307. /** @hidden */
  9308. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9309. /**
  9310. * Flag the bone as dirty (Forcing it to update everything)
  9311. */
  9312. markAsDirty(): void;
  9313. private _markAsDirtyAndCompose;
  9314. private _markAsDirtyAndDecompose;
  9315. /**
  9316. * Copy an animation range from another bone
  9317. * @param source defines the source bone
  9318. * @param rangeName defines the range name to copy
  9319. * @param frameOffset defines the frame offset
  9320. * @param rescaleAsRequired defines if rescaling must be applied if required
  9321. * @param skelDimensionsRatio defines the scaling ratio
  9322. * @returns true if operation was successful
  9323. */
  9324. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9325. /**
  9326. * Translate the bone in local or world space
  9327. * @param vec The amount to translate the bone
  9328. * @param space The space that the translation is in
  9329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9330. */
  9331. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9332. /**
  9333. * Set the postion of the bone in local or world space
  9334. * @param position The position to set the bone
  9335. * @param space The space that the position is in
  9336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9337. */
  9338. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9339. /**
  9340. * Set the absolute position of the bone (world space)
  9341. * @param position The position to set the bone
  9342. * @param mesh The mesh that this bone is attached to
  9343. */
  9344. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9345. /**
  9346. * Scale the bone on the x, y and z axes (in local space)
  9347. * @param x The amount to scale the bone on the x axis
  9348. * @param y The amount to scale the bone on the y axis
  9349. * @param z The amount to scale the bone on the z axis
  9350. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9351. */
  9352. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9353. /**
  9354. * Set the bone scaling in local space
  9355. * @param scale defines the scaling vector
  9356. */
  9357. setScale(scale: Vector3): void;
  9358. /**
  9359. * Gets the current scaling in local space
  9360. * @returns the current scaling vector
  9361. */
  9362. getScale(): Vector3;
  9363. /**
  9364. * Gets the current scaling in local space and stores it in a target vector
  9365. * @param result defines the target vector
  9366. */
  9367. getScaleToRef(result: Vector3): void;
  9368. /**
  9369. * Set the yaw, pitch, and roll of the bone in local or world space
  9370. * @param yaw The rotation of the bone on the y axis
  9371. * @param pitch The rotation of the bone on the x axis
  9372. * @param roll The rotation of the bone on the z axis
  9373. * @param space The space that the axes of rotation are in
  9374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9375. */
  9376. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9377. /**
  9378. * Add a rotation to the bone on an axis in local or world space
  9379. * @param axis The axis to rotate the bone on
  9380. * @param amount The amount to rotate the bone
  9381. * @param space The space that the axis is in
  9382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9383. */
  9384. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9385. /**
  9386. * Set the rotation of the bone to a particular axis angle in local or world space
  9387. * @param axis The axis to rotate the bone on
  9388. * @param angle The angle that the bone should be rotated to
  9389. * @param space The space that the axis is in
  9390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9391. */
  9392. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9393. /**
  9394. * Set the euler rotation of the bone in local of world space
  9395. * @param rotation The euler rotation that the bone should be set to
  9396. * @param space The space that the rotation is in
  9397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9398. */
  9399. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9400. /**
  9401. * Set the quaternion rotation of the bone in local of world space
  9402. * @param quat The quaternion rotation that the bone should be set to
  9403. * @param space The space that the rotation is in
  9404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9405. */
  9406. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9407. /**
  9408. * Set the rotation matrix of the bone in local of world space
  9409. * @param rotMat The rotation matrix that the bone should be set to
  9410. * @param space The space that the rotation is in
  9411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9412. */
  9413. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9414. private _rotateWithMatrix;
  9415. private _getNegativeRotationToRef;
  9416. /**
  9417. * Get the position of the bone in local or world space
  9418. * @param space The space that the returned position is in
  9419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9420. * @returns The position of the bone
  9421. */
  9422. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9423. /**
  9424. * Copy the position of the bone to a vector3 in local or world space
  9425. * @param space The space that the returned position is in
  9426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9427. * @param result The vector3 to copy the position to
  9428. */
  9429. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9430. /**
  9431. * Get the absolute position of the bone (world space)
  9432. * @param mesh The mesh that this bone is attached to
  9433. * @returns The absolute position of the bone
  9434. */
  9435. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9436. /**
  9437. * Copy the absolute position of the bone (world space) to the result param
  9438. * @param mesh The mesh that this bone is attached to
  9439. * @param result The vector3 to copy the absolute position to
  9440. */
  9441. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9442. /**
  9443. * Compute the absolute transforms of this bone and its children
  9444. */
  9445. computeAbsoluteTransforms(): void;
  9446. /**
  9447. * Get the world direction from an axis that is in the local space of the bone
  9448. * @param localAxis The local direction that is used to compute the world direction
  9449. * @param mesh The mesh that this bone is attached to
  9450. * @returns The world direction
  9451. */
  9452. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9453. /**
  9454. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9455. * @param localAxis The local direction that is used to compute the world direction
  9456. * @param mesh The mesh that this bone is attached to
  9457. * @param result The vector3 that the world direction will be copied to
  9458. */
  9459. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9460. /**
  9461. * Get the euler rotation of the bone in local or world space
  9462. * @param space The space that the rotation should be in
  9463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9464. * @returns The euler rotation
  9465. */
  9466. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9467. /**
  9468. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9469. * @param space The space that the rotation should be in
  9470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9471. * @param result The vector3 that the rotation should be copied to
  9472. */
  9473. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9474. /**
  9475. * Get the quaternion rotation of the bone in either local or world space
  9476. * @param space The space that the rotation should be in
  9477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9478. * @returns The quaternion rotation
  9479. */
  9480. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9481. /**
  9482. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9483. * @param space The space that the rotation should be in
  9484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9485. * @param result The quaternion that the rotation should be copied to
  9486. */
  9487. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9488. /**
  9489. * Get the rotation matrix of the bone in local or world space
  9490. * @param space The space that the rotation should be in
  9491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9492. * @returns The rotation matrix
  9493. */
  9494. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9495. /**
  9496. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9497. * @param space The space that the rotation should be in
  9498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9499. * @param result The quaternion that the rotation should be copied to
  9500. */
  9501. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9502. /**
  9503. * Get the world position of a point that is in the local space of the bone
  9504. * @param position The local position
  9505. * @param mesh The mesh that this bone is attached to
  9506. * @returns The world position
  9507. */
  9508. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9509. /**
  9510. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9511. * @param position The local position
  9512. * @param mesh The mesh that this bone is attached to
  9513. * @param result The vector3 that the world position should be copied to
  9514. */
  9515. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9516. /**
  9517. * Get the local position of a point that is in world space
  9518. * @param position The world position
  9519. * @param mesh The mesh that this bone is attached to
  9520. * @returns The local position
  9521. */
  9522. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9523. /**
  9524. * Get the local position of a point that is in world space and copy it to the result param
  9525. * @param position The world position
  9526. * @param mesh The mesh that this bone is attached to
  9527. * @param result The vector3 that the local position should be copied to
  9528. */
  9529. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9530. }
  9531. }
  9532. declare module "babylonjs/Meshes/transformNode" {
  9533. import { DeepImmutable } from "babylonjs/types";
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Nullable } from "babylonjs/types";
  9536. import { Camera } from "babylonjs/Cameras/camera";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  9539. import { Node } from "babylonjs/node";
  9540. import { Bone } from "babylonjs/Bones/bone";
  9541. /**
  9542. * 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.
  9543. * @see https://doc.babylonjs.com/how_to/transformnode
  9544. */
  9545. export class TransformNode extends Node {
  9546. /**
  9547. * Object will not rotate to face the camera
  9548. */
  9549. static BILLBOARDMODE_NONE: number;
  9550. /**
  9551. * Object will rotate to face the camera but only on the x axis
  9552. */
  9553. static BILLBOARDMODE_X: number;
  9554. /**
  9555. * Object will rotate to face the camera but only on the y axis
  9556. */
  9557. static BILLBOARDMODE_Y: number;
  9558. /**
  9559. * Object will rotate to face the camera but only on the z axis
  9560. */
  9561. static BILLBOARDMODE_Z: number;
  9562. /**
  9563. * Object will rotate to face the camera
  9564. */
  9565. static BILLBOARDMODE_ALL: number;
  9566. private _forward;
  9567. private _forwardInverted;
  9568. private _up;
  9569. private _right;
  9570. private _rightInverted;
  9571. private _position;
  9572. private _rotation;
  9573. private _rotationQuaternion;
  9574. protected _scaling: Vector3;
  9575. protected _isDirty: boolean;
  9576. private _transformToBoneReferal;
  9577. /**
  9578. * Set the billboard mode. Default is 0.
  9579. *
  9580. * | Value | Type | Description |
  9581. * | --- | --- | --- |
  9582. * | 0 | BILLBOARDMODE_NONE | |
  9583. * | 1 | BILLBOARDMODE_X | |
  9584. * | 2 | BILLBOARDMODE_Y | |
  9585. * | 4 | BILLBOARDMODE_Z | |
  9586. * | 7 | BILLBOARDMODE_ALL | |
  9587. *
  9588. */
  9589. billboardMode: number;
  9590. /**
  9591. * 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
  9592. */
  9593. scalingDeterminant: number;
  9594. /**
  9595. * Sets the distance of the object to max, often used by skybox
  9596. */
  9597. infiniteDistance: boolean;
  9598. /**
  9599. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9600. * By default the system will update normals to compensate
  9601. */
  9602. ignoreNonUniformScaling: boolean;
  9603. /** @hidden */
  9604. _poseMatrix: Matrix;
  9605. /** @hidden */
  9606. _localMatrix: Matrix;
  9607. private _absolutePosition;
  9608. private _pivotMatrix;
  9609. private _pivotMatrixInverse;
  9610. protected _postMultiplyPivotMatrix: boolean;
  9611. protected _isWorldMatrixFrozen: boolean;
  9612. /** @hidden */
  9613. _indexInSceneTransformNodesArray: number;
  9614. /**
  9615. * An event triggered after the world matrix is updated
  9616. */
  9617. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9618. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9619. /**
  9620. * Gets a string identifying the name of the class
  9621. * @returns "TransformNode" string
  9622. */
  9623. getClassName(): string;
  9624. /**
  9625. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9626. */
  9627. position: Vector3;
  9628. /**
  9629. * 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)).
  9630. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9631. */
  9632. rotation: Vector3;
  9633. /**
  9634. * 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)).
  9635. */
  9636. scaling: Vector3;
  9637. /**
  9638. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  9639. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9640. */
  9641. rotationQuaternion: Nullable<Quaternion>;
  9642. /**
  9643. * The forward direction of that transform in world space.
  9644. */
  9645. readonly forward: Vector3;
  9646. /**
  9647. * The up direction of that transform in world space.
  9648. */
  9649. readonly up: Vector3;
  9650. /**
  9651. * The right direction of that transform in world space.
  9652. */
  9653. readonly right: Vector3;
  9654. /**
  9655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9656. * @param matrix the matrix to copy the pose from
  9657. * @returns this TransformNode.
  9658. */
  9659. updatePoseMatrix(matrix: Matrix): TransformNode;
  9660. /**
  9661. * Returns the mesh Pose matrix.
  9662. * @returns the pose matrix
  9663. */
  9664. getPoseMatrix(): Matrix;
  9665. /** @hidden */
  9666. _isSynchronized(): boolean;
  9667. /** @hidden */
  9668. _initCache(): void;
  9669. /**
  9670. * Flag the transform node as dirty (Forcing it to update everything)
  9671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9672. * @returns this transform node
  9673. */
  9674. markAsDirty(property: string): TransformNode;
  9675. /**
  9676. * Returns the current mesh absolute position.
  9677. * Returns a Vector3.
  9678. */
  9679. readonly absolutePosition: Vector3;
  9680. /**
  9681. * Sets a new matrix to apply before all other transformation
  9682. * @param matrix defines the transform matrix
  9683. * @returns the current TransformNode
  9684. */
  9685. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9686. /**
  9687. * Sets a new pivot matrix to the current node
  9688. * @param matrix defines the new pivot matrix to use
  9689. * @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
  9690. * @returns the current TransformNode
  9691. */
  9692. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9693. /**
  9694. * Returns the mesh pivot matrix.
  9695. * Default : Identity.
  9696. * @returns the matrix
  9697. */
  9698. getPivotMatrix(): Matrix;
  9699. /**
  9700. * Prevents the World matrix to be computed any longer.
  9701. * @returns the TransformNode.
  9702. */
  9703. freezeWorldMatrix(): TransformNode;
  9704. /**
  9705. * Allows back the World matrix computation.
  9706. * @returns the TransformNode.
  9707. */
  9708. unfreezeWorldMatrix(): this;
  9709. /**
  9710. * True if the World matrix has been frozen.
  9711. */
  9712. readonly isWorldMatrixFrozen: boolean;
  9713. /**
  9714. * Retuns the mesh absolute position in the World.
  9715. * @returns a Vector3.
  9716. */
  9717. getAbsolutePosition(): Vector3;
  9718. /**
  9719. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9720. * @param absolutePosition the absolute position to set
  9721. * @returns the TransformNode.
  9722. */
  9723. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9724. /**
  9725. * Sets the mesh position in its local space.
  9726. * @param vector3 the position to set in localspace
  9727. * @returns the TransformNode.
  9728. */
  9729. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9730. /**
  9731. * Returns the mesh position in the local space from the current World matrix values.
  9732. * @returns a new Vector3.
  9733. */
  9734. getPositionExpressedInLocalSpace(): Vector3;
  9735. /**
  9736. * Translates the mesh along the passed Vector3 in its local space.
  9737. * @param vector3 the distance to translate in localspace
  9738. * @returns the TransformNode.
  9739. */
  9740. locallyTranslate(vector3: Vector3): TransformNode;
  9741. private static _lookAtVectorCache;
  9742. /**
  9743. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9744. * @param targetPoint the position (must be in same space as current mesh) to look at
  9745. * @param yawCor optional yaw (y-axis) correction in radians
  9746. * @param pitchCor optional pitch (x-axis) correction in radians
  9747. * @param rollCor optional roll (z-axis) correction in radians
  9748. * @param space the choosen space of the target
  9749. * @returns the TransformNode.
  9750. */
  9751. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9752. /**
  9753. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9754. * This Vector3 is expressed in the World space.
  9755. * @param localAxis axis to rotate
  9756. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9757. */
  9758. getDirection(localAxis: Vector3): Vector3;
  9759. /**
  9760. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9761. * localAxis is expressed in the mesh local space.
  9762. * result is computed in the Wordl space from the mesh World matrix.
  9763. * @param localAxis axis to rotate
  9764. * @param result the resulting transformnode
  9765. * @returns this TransformNode.
  9766. */
  9767. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9768. /**
  9769. * Sets this transform node rotation to the given local axis.
  9770. * @param localAxis the axis in local space
  9771. * @param yawCor optional yaw (y-axis) correction in radians
  9772. * @param pitchCor optional pitch (x-axis) correction in radians
  9773. * @param rollCor optional roll (z-axis) correction in radians
  9774. * @returns this TransformNode
  9775. */
  9776. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9777. /**
  9778. * Sets a new pivot point to the current node
  9779. * @param point defines the new pivot point to use
  9780. * @param space defines if the point is in world or local space (local by default)
  9781. * @returns the current TransformNode
  9782. */
  9783. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9784. /**
  9785. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9786. * @returns the pivot point
  9787. */
  9788. getPivotPoint(): Vector3;
  9789. /**
  9790. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9791. * @param result the vector3 to store the result
  9792. * @returns this TransformNode.
  9793. */
  9794. getPivotPointToRef(result: Vector3): TransformNode;
  9795. /**
  9796. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9797. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9798. */
  9799. getAbsolutePivotPoint(): Vector3;
  9800. /**
  9801. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9802. * @param result vector3 to store the result
  9803. * @returns this TransformNode.
  9804. */
  9805. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9806. /**
  9807. * Defines the passed node as the parent of the current node.
  9808. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9809. * @param node the node ot set as the parent
  9810. * @returns this TransformNode.
  9811. */
  9812. setParent(node: Nullable<Node>): TransformNode;
  9813. private _nonUniformScaling;
  9814. /**
  9815. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9816. */
  9817. readonly nonUniformScaling: boolean;
  9818. /** @hidden */
  9819. _updateNonUniformScalingState(value: boolean): boolean;
  9820. /**
  9821. * Attach the current TransformNode to another TransformNode associated with a bone
  9822. * @param bone Bone affecting the TransformNode
  9823. * @param affectedTransformNode TransformNode associated with the bone
  9824. * @returns this object
  9825. */
  9826. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9827. /**
  9828. * Detach the transform node if its associated with a bone
  9829. * @returns this object
  9830. */
  9831. detachFromBone(): TransformNode;
  9832. private static _rotationAxisCache;
  9833. /**
  9834. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9835. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9837. * The passed axis is also normalized.
  9838. * @param axis the axis to rotate around
  9839. * @param amount the amount to rotate in radians
  9840. * @param space Space to rotate in (Default: local)
  9841. * @returns the TransformNode.
  9842. */
  9843. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9844. /**
  9845. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9846. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9847. * The passed axis is also normalized. .
  9848. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9849. * @param point the point to rotate around
  9850. * @param axis the axis to rotate around
  9851. * @param amount the amount to rotate in radians
  9852. * @returns the TransformNode
  9853. */
  9854. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9855. /**
  9856. * Translates the mesh along the axis vector for the passed distance in the given space.
  9857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9858. * @param axis the axis to translate in
  9859. * @param distance the distance to translate
  9860. * @param space Space to rotate in (Default: local)
  9861. * @returns the TransformNode.
  9862. */
  9863. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9864. /**
  9865. * Adds a rotation step to the mesh current rotation.
  9866. * x, y, z are Euler angles expressed in radians.
  9867. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9868. * This means this rotation is made in the mesh local space only.
  9869. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9870. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9871. * ```javascript
  9872. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9873. * ```
  9874. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9875. * 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.
  9876. * @param x Rotation to add
  9877. * @param y Rotation to add
  9878. * @param z Rotation to add
  9879. * @returns the TransformNode.
  9880. */
  9881. addRotation(x: number, y: number, z: number): TransformNode;
  9882. /**
  9883. * Computes the world matrix of the node
  9884. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9885. * @returns the world matrix
  9886. */
  9887. computeWorldMatrix(force?: boolean): Matrix;
  9888. protected _afterComputeWorldMatrix(): void;
  9889. /**
  9890. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9891. * @param func callback function to add
  9892. *
  9893. * @returns the TransformNode.
  9894. */
  9895. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9896. /**
  9897. * Removes a registered callback function.
  9898. * @param func callback function to remove
  9899. * @returns the TransformNode.
  9900. */
  9901. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9902. /**
  9903. * Gets the position of the current mesh in camera space
  9904. * @param camera defines the camera to use
  9905. * @returns a position
  9906. */
  9907. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9908. /**
  9909. * Returns the distance from the mesh to the active camera
  9910. * @param camera defines the camera to use
  9911. * @returns the distance
  9912. */
  9913. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9914. /**
  9915. * Clone the current transform node
  9916. * @param name Name of the new clone
  9917. * @param newParent New parent for the clone
  9918. * @param doNotCloneChildren Do not clone children hierarchy
  9919. * @returns the new transform node
  9920. */
  9921. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9922. /**
  9923. * Serializes the objects information.
  9924. * @param currentSerializationObject defines the object to serialize in
  9925. * @returns the serialized object
  9926. */
  9927. serialize(currentSerializationObject?: any): any;
  9928. /**
  9929. * Returns a new TransformNode object parsed from the source provided.
  9930. * @param parsedTransformNode is the source.
  9931. * @param scene the scne the object belongs to
  9932. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9933. * @returns a new TransformNode object parsed from the source provided.
  9934. */
  9935. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9936. /**
  9937. * Get all child-transformNodes of this node
  9938. * @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
  9939. * @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
  9940. * @returns an array of TransformNode
  9941. */
  9942. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9943. /**
  9944. * Releases resources associated with this transform node.
  9945. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9946. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9947. */
  9948. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9949. }
  9950. }
  9951. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  9952. import { Observable } from "babylonjs/Misc/observable";
  9953. import { Nullable } from "babylonjs/types";
  9954. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  9955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9957. import { Ray } from "babylonjs/Culling/ray";
  9958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  9959. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  9960. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  9961. /**
  9962. * Defines the types of pose enabled controllers that are supported
  9963. */
  9964. export enum PoseEnabledControllerType {
  9965. /**
  9966. * HTC Vive
  9967. */
  9968. VIVE = 0,
  9969. /**
  9970. * Oculus Rift
  9971. */
  9972. OCULUS = 1,
  9973. /**
  9974. * Windows mixed reality
  9975. */
  9976. WINDOWS = 2,
  9977. /**
  9978. * Samsung gear VR
  9979. */
  9980. GEAR_VR = 3,
  9981. /**
  9982. * Google Daydream
  9983. */
  9984. DAYDREAM = 4,
  9985. /**
  9986. * Generic
  9987. */
  9988. GENERIC = 5
  9989. }
  9990. /**
  9991. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9992. */
  9993. export interface MutableGamepadButton {
  9994. /**
  9995. * Value of the button/trigger
  9996. */
  9997. value: number;
  9998. /**
  9999. * If the button/trigger is currently touched
  10000. */
  10001. touched: boolean;
  10002. /**
  10003. * If the button/trigger is currently pressed
  10004. */
  10005. pressed: boolean;
  10006. }
  10007. /**
  10008. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  10009. * @hidden
  10010. */
  10011. export interface ExtendedGamepadButton extends GamepadButton {
  10012. /**
  10013. * If the button/trigger is currently pressed
  10014. */
  10015. readonly pressed: boolean;
  10016. /**
  10017. * If the button/trigger is currently touched
  10018. */
  10019. readonly touched: boolean;
  10020. /**
  10021. * Value of the button/trigger
  10022. */
  10023. readonly value: number;
  10024. }
  10025. /** @hidden */
  10026. export interface _GamePadFactory {
  10027. /**
  10028. * Returns wether or not the current gamepad can be created for this type of controller.
  10029. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10030. * @returns true if it can be created, otherwise false
  10031. */
  10032. canCreate(gamepadInfo: any): boolean;
  10033. /**
  10034. * Creates a new instance of the Gamepad.
  10035. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10036. * @returns the new gamepad instance
  10037. */
  10038. create(gamepadInfo: any): Gamepad;
  10039. }
  10040. /**
  10041. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10042. */
  10043. export class PoseEnabledControllerHelper {
  10044. /** @hidden */
  10045. static _ControllerFactories: _GamePadFactory[];
  10046. /** @hidden */
  10047. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  10048. /**
  10049. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10050. * @param vrGamepad the gamepad to initialized
  10051. * @returns a vr controller of the type the gamepad identified as
  10052. */
  10053. static InitiateController(vrGamepad: any): Gamepad;
  10054. }
  10055. /**
  10056. * Defines the PoseEnabledController object that contains state of a vr capable controller
  10057. */
  10058. export class PoseEnabledController extends Gamepad implements PoseControlled {
  10059. private _deviceRoomPosition;
  10060. private _deviceRoomRotationQuaternion;
  10061. /**
  10062. * The device position in babylon space
  10063. */
  10064. devicePosition: Vector3;
  10065. /**
  10066. * The device rotation in babylon space
  10067. */
  10068. deviceRotationQuaternion: Quaternion;
  10069. /**
  10070. * The scale factor of the device in babylon space
  10071. */
  10072. deviceScaleFactor: number;
  10073. /**
  10074. * (Likely devicePosition should be used instead) The device position in its room space
  10075. */
  10076. position: Vector3;
  10077. /**
  10078. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  10079. */
  10080. rotationQuaternion: Quaternion;
  10081. /**
  10082. * The type of controller (Eg. Windows mixed reality)
  10083. */
  10084. controllerType: PoseEnabledControllerType;
  10085. protected _calculatedPosition: Vector3;
  10086. private _calculatedRotation;
  10087. /**
  10088. * The raw pose from the device
  10089. */
  10090. rawPose: DevicePose;
  10091. private _trackPosition;
  10092. private _maxRotationDistFromHeadset;
  10093. private _draggedRoomRotation;
  10094. /**
  10095. * @hidden
  10096. */
  10097. _disableTrackPosition(fixedPosition: Vector3): void;
  10098. /**
  10099. * Internal, the mesh attached to the controller
  10100. * @hidden
  10101. */
  10102. _mesh: Nullable<AbstractMesh>;
  10103. private _poseControlledCamera;
  10104. private _leftHandSystemQuaternion;
  10105. /**
  10106. * Internal, matrix used to convert room space to babylon space
  10107. * @hidden
  10108. */
  10109. _deviceToWorld: Matrix;
  10110. /**
  10111. * Node to be used when casting a ray from the controller
  10112. * @hidden
  10113. */
  10114. _pointingPoseNode: Nullable<TransformNode>;
  10115. /**
  10116. * Name of the child mesh that can be used to cast a ray from the controller
  10117. */
  10118. static readonly POINTING_POSE: string;
  10119. /**
  10120. * Creates a new PoseEnabledController from a gamepad
  10121. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  10122. */
  10123. constructor(browserGamepad: any);
  10124. private _workingMatrix;
  10125. /**
  10126. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  10127. */
  10128. update(): void;
  10129. /**
  10130. * Updates only the pose device and mesh without doing any button event checking
  10131. */
  10132. protected _updatePoseAndMesh(): void;
  10133. /**
  10134. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  10135. * @param poseData raw pose fromthe device
  10136. */
  10137. updateFromDevice(poseData: DevicePose): void;
  10138. /**
  10139. * @hidden
  10140. */
  10141. _meshAttachedObservable: Observable<AbstractMesh>;
  10142. /**
  10143. * Attaches a mesh to the controller
  10144. * @param mesh the mesh to be attached
  10145. */
  10146. attachToMesh(mesh: AbstractMesh): void;
  10147. /**
  10148. * Attaches the controllers mesh to a camera
  10149. * @param camera the camera the mesh should be attached to
  10150. */
  10151. attachToPoseControlledCamera(camera: TargetCamera): void;
  10152. /**
  10153. * Disposes of the controller
  10154. */
  10155. dispose(): void;
  10156. /**
  10157. * The mesh that is attached to the controller
  10158. */
  10159. readonly mesh: Nullable<AbstractMesh>;
  10160. /**
  10161. * Gets the ray of the controller in the direction the controller is pointing
  10162. * @param length the length the resulting ray should be
  10163. * @returns a ray in the direction the controller is pointing
  10164. */
  10165. getForwardRay(length?: number): Ray;
  10166. }
  10167. }
  10168. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  10169. import { Observable } from "babylonjs/Misc/observable";
  10170. import { Scene } from "babylonjs/scene";
  10171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10172. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  10173. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  10174. /**
  10175. * Defines the WebVRController object that represents controllers tracked in 3D space
  10176. */
  10177. export abstract class WebVRController extends PoseEnabledController {
  10178. /**
  10179. * Internal, the default controller model for the controller
  10180. */
  10181. protected _defaultModel: AbstractMesh;
  10182. /**
  10183. * Fired when the trigger state has changed
  10184. */
  10185. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  10186. /**
  10187. * Fired when the main button state has changed
  10188. */
  10189. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10190. /**
  10191. * Fired when the secondary button state has changed
  10192. */
  10193. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10194. /**
  10195. * Fired when the pad state has changed
  10196. */
  10197. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  10198. /**
  10199. * Fired when controllers stick values have changed
  10200. */
  10201. onPadValuesChangedObservable: Observable<StickValues>;
  10202. /**
  10203. * Array of button availible on the controller
  10204. */
  10205. protected _buttons: Array<MutableGamepadButton>;
  10206. private _onButtonStateChange;
  10207. /**
  10208. * Fired when a controller button's state has changed
  10209. * @param callback the callback containing the button that was modified
  10210. */
  10211. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  10212. /**
  10213. * X and Y axis corrisponding to the controllers joystick
  10214. */
  10215. pad: StickValues;
  10216. /**
  10217. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  10218. */
  10219. hand: string;
  10220. /**
  10221. * The default controller model for the controller
  10222. */
  10223. readonly defaultModel: AbstractMesh;
  10224. /**
  10225. * Creates a new WebVRController from a gamepad
  10226. * @param vrGamepad the gamepad that the WebVRController should be created from
  10227. */
  10228. constructor(vrGamepad: any);
  10229. /**
  10230. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  10231. */
  10232. update(): void;
  10233. /**
  10234. * Function to be called when a button is modified
  10235. */
  10236. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  10237. /**
  10238. * Loads a mesh and attaches it to the controller
  10239. * @param scene the scene the mesh should be added to
  10240. * @param meshLoaded callback for when the mesh has been loaded
  10241. */
  10242. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  10243. private _setButtonValue;
  10244. private _changes;
  10245. private _checkChanges;
  10246. /**
  10247. * Disposes of th webVRCOntroller
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Lights/shadowLight" {
  10253. import { Camera } from "babylonjs/Cameras/camera";
  10254. import { Scene } from "babylonjs/scene";
  10255. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10257. import { Light } from "babylonjs/Lights/light";
  10258. /**
  10259. * Interface describing all the common properties and methods a shadow light needs to implement.
  10260. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10261. * as well as binding the different shadow properties to the effects.
  10262. */
  10263. export interface IShadowLight extends Light {
  10264. /**
  10265. * The light id in the scene (used in scene.findLighById for instance)
  10266. */
  10267. id: string;
  10268. /**
  10269. * The position the shdow will be casted from.
  10270. */
  10271. position: Vector3;
  10272. /**
  10273. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10274. */
  10275. direction: Vector3;
  10276. /**
  10277. * The transformed position. Position of the light in world space taking parenting in account.
  10278. */
  10279. transformedPosition: Vector3;
  10280. /**
  10281. * The transformed direction. Direction of the light in world space taking parenting in account.
  10282. */
  10283. transformedDirection: Vector3;
  10284. /**
  10285. * The friendly name of the light in the scene.
  10286. */
  10287. name: string;
  10288. /**
  10289. * Defines the shadow projection clipping minimum z value.
  10290. */
  10291. shadowMinZ: number;
  10292. /**
  10293. * Defines the shadow projection clipping maximum z value.
  10294. */
  10295. shadowMaxZ: number;
  10296. /**
  10297. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10298. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10299. */
  10300. computeTransformedInformation(): boolean;
  10301. /**
  10302. * Gets the scene the light belongs to.
  10303. * @returns The scene
  10304. */
  10305. getScene(): Scene;
  10306. /**
  10307. * Callback defining a custom Projection Matrix Builder.
  10308. * This can be used to override the default projection matrix computation.
  10309. */
  10310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10311. /**
  10312. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10313. * @param matrix The materix to updated with the projection information
  10314. * @param viewMatrix The transform matrix of the light
  10315. * @param renderList The list of mesh to render in the map
  10316. * @returns The current light
  10317. */
  10318. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10319. /**
  10320. * Gets the current depth scale used in ESM.
  10321. * @returns The scale
  10322. */
  10323. getDepthScale(): number;
  10324. /**
  10325. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10326. * @returns true if a cube texture needs to be use
  10327. */
  10328. needCube(): boolean;
  10329. /**
  10330. * Detects if the projection matrix requires to be recomputed this frame.
  10331. * @returns true if it requires to be recomputed otherwise, false.
  10332. */
  10333. needProjectionMatrixCompute(): boolean;
  10334. /**
  10335. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10336. */
  10337. forceProjectionMatrixCompute(): void;
  10338. /**
  10339. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10340. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10341. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10342. */
  10343. getShadowDirection(faceIndex?: number): Vector3;
  10344. /**
  10345. * Gets the minZ used for shadow according to both the scene and the light.
  10346. * @param activeCamera The camera we are returning the min for
  10347. * @returns the depth min z
  10348. */
  10349. getDepthMinZ(activeCamera: Camera): number;
  10350. /**
  10351. * Gets the maxZ used for shadow according to both the scene and the light.
  10352. * @param activeCamera The camera we are returning the max for
  10353. * @returns the depth max z
  10354. */
  10355. getDepthMaxZ(activeCamera: Camera): number;
  10356. }
  10357. /**
  10358. * Base implementation IShadowLight
  10359. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10360. */
  10361. export abstract class ShadowLight extends Light implements IShadowLight {
  10362. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10363. protected _position: Vector3;
  10364. protected _setPosition(value: Vector3): void;
  10365. /**
  10366. * Sets the position the shadow will be casted from. Also use as the light position for both
  10367. * point and spot lights.
  10368. */
  10369. /**
  10370. * Sets the position the shadow will be casted from. Also use as the light position for both
  10371. * point and spot lights.
  10372. */
  10373. position: Vector3;
  10374. protected _direction: Vector3;
  10375. protected _setDirection(value: Vector3): void;
  10376. /**
  10377. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10378. * Also use as the light direction on spot and directional lights.
  10379. */
  10380. /**
  10381. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10382. * Also use as the light direction on spot and directional lights.
  10383. */
  10384. direction: Vector3;
  10385. private _shadowMinZ;
  10386. /**
  10387. * Gets the shadow projection clipping minimum z value.
  10388. */
  10389. /**
  10390. * Sets the shadow projection clipping minimum z value.
  10391. */
  10392. shadowMinZ: number;
  10393. private _shadowMaxZ;
  10394. /**
  10395. * Sets the shadow projection clipping maximum z value.
  10396. */
  10397. /**
  10398. * Gets the shadow projection clipping maximum z value.
  10399. */
  10400. shadowMaxZ: number;
  10401. /**
  10402. * Callback defining a custom Projection Matrix Builder.
  10403. * This can be used to override the default projection matrix computation.
  10404. */
  10405. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10406. /**
  10407. * The transformed position. Position of the light in world space taking parenting in account.
  10408. */
  10409. transformedPosition: Vector3;
  10410. /**
  10411. * The transformed direction. Direction of the light in world space taking parenting in account.
  10412. */
  10413. transformedDirection: Vector3;
  10414. private _needProjectionMatrixCompute;
  10415. /**
  10416. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10417. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10418. */
  10419. computeTransformedInformation(): boolean;
  10420. /**
  10421. * Return the depth scale used for the shadow map.
  10422. * @returns the depth scale.
  10423. */
  10424. getDepthScale(): number;
  10425. /**
  10426. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10427. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10428. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10429. */
  10430. getShadowDirection(faceIndex?: number): Vector3;
  10431. /**
  10432. * Returns the ShadowLight absolute position in the World.
  10433. * @returns the position vector in world space
  10434. */
  10435. getAbsolutePosition(): Vector3;
  10436. /**
  10437. * Sets the ShadowLight direction toward the passed target.
  10438. * @param target The point tot target in local space
  10439. * @returns the updated ShadowLight direction
  10440. */
  10441. setDirectionToTarget(target: Vector3): Vector3;
  10442. /**
  10443. * Returns the light rotation in euler definition.
  10444. * @returns the x y z rotation in local space.
  10445. */
  10446. getRotation(): Vector3;
  10447. /**
  10448. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10449. * @returns true if a cube texture needs to be use
  10450. */
  10451. needCube(): boolean;
  10452. /**
  10453. * Detects if the projection matrix requires to be recomputed this frame.
  10454. * @returns true if it requires to be recomputed otherwise, false.
  10455. */
  10456. needProjectionMatrixCompute(): boolean;
  10457. /**
  10458. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10459. */
  10460. forceProjectionMatrixCompute(): void;
  10461. /** @hidden */
  10462. _initCache(): void;
  10463. /** @hidden */
  10464. _isSynchronized(): boolean;
  10465. /**
  10466. * Computes the world matrix of the node
  10467. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10468. * @returns the world matrix
  10469. */
  10470. computeWorldMatrix(force?: boolean): Matrix;
  10471. /**
  10472. * Gets the minZ used for shadow according to both the scene and the light.
  10473. * @param activeCamera The camera we are returning the min for
  10474. * @returns the depth min z
  10475. */
  10476. getDepthMinZ(activeCamera: Camera): number;
  10477. /**
  10478. * Gets the maxZ used for shadow according to both the scene and the light.
  10479. * @param activeCamera The camera we are returning the max for
  10480. * @returns the depth max z
  10481. */
  10482. getDepthMaxZ(activeCamera: Camera): number;
  10483. /**
  10484. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10485. * @param matrix The materix to updated with the projection information
  10486. * @param viewMatrix The transform matrix of the light
  10487. * @param renderList The list of mesh to render in the map
  10488. * @returns The current light
  10489. */
  10490. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10491. }
  10492. }
  10493. declare module "babylonjs/Materials/materialHelper" {
  10494. import { Nullable } from "babylonjs/types";
  10495. import { Scene } from "babylonjs/scene";
  10496. import { Engine } from "babylonjs/Engines/engine";
  10497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10498. import { Light } from "babylonjs/Lights/light";
  10499. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10500. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  10501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10502. /**
  10503. * "Static Class" containing the most commonly used helper while dealing with material for
  10504. * rendering purpose.
  10505. *
  10506. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10507. *
  10508. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10509. */
  10510. export class MaterialHelper {
  10511. /**
  10512. * Bind the current view position to an effect.
  10513. * @param effect The effect to be bound
  10514. * @param scene The scene the eyes position is used from
  10515. */
  10516. static BindEyePosition(effect: Effect, scene: Scene): void;
  10517. /**
  10518. * Helps preparing the defines values about the UVs in used in the effect.
  10519. * UVs are shared as much as we can accross channels in the shaders.
  10520. * @param texture The texture we are preparing the UVs for
  10521. * @param defines The defines to update
  10522. * @param key The channel key "diffuse", "specular"... used in the shader
  10523. */
  10524. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10525. /**
  10526. * Binds a texture matrix value to its corrsponding uniform
  10527. * @param texture The texture to bind the matrix for
  10528. * @param uniformBuffer The uniform buffer receivin the data
  10529. * @param key The channel key "diffuse", "specular"... used in the shader
  10530. */
  10531. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10532. /**
  10533. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10534. * @param mesh defines the current mesh
  10535. * @param scene defines the current scene
  10536. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10537. * @param pointsCloud defines if point cloud rendering has to be turned on
  10538. * @param fogEnabled defines if fog has to be turned on
  10539. * @param alphaTest defines if alpha testing has to be turned on
  10540. * @param defines defines the current list of defines
  10541. */
  10542. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10543. /**
  10544. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10545. * @param scene defines the current scene
  10546. * @param engine defines the current engine
  10547. * @param defines specifies the list of active defines
  10548. * @param useInstances defines if instances have to be turned on
  10549. * @param useClipPlane defines if clip plane have to be turned on
  10550. */
  10551. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10552. /**
  10553. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10554. * @param mesh The mesh containing the geometry data we will draw
  10555. * @param defines The defines to update
  10556. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10557. * @param useBones Precise whether bones should be used or not (override mesh info)
  10558. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10559. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10560. * @returns false if defines are considered not dirty and have not been checked
  10561. */
  10562. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10563. /**
  10564. * Prepares the defines related to the light information passed in parameter
  10565. * @param scene The scene we are intending to draw
  10566. * @param mesh The mesh the effect is compiling for
  10567. * @param defines The defines to update
  10568. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10569. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10570. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10571. * @returns true if normals will be required for the rest of the effect
  10572. */
  10573. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10574. /**
  10575. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10576. * that won t be acctive due to defines being turned off.
  10577. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10578. * @param samplersList The samplers list
  10579. * @param defines The defines helping in the list generation
  10580. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10581. */
  10582. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10583. /**
  10584. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10585. * @param defines The defines to update while falling back
  10586. * @param fallbacks The authorized effect fallbacks
  10587. * @param maxSimultaneousLights The maximum number of lights allowed
  10588. * @param rank the current rank of the Effect
  10589. * @returns The newly affected rank
  10590. */
  10591. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10592. /**
  10593. * Prepares the list of attributes required for morph targets according to the effect defines.
  10594. * @param attribs The current list of supported attribs
  10595. * @param mesh The mesh to prepare the morph targets attributes for
  10596. * @param defines The current Defines of the effect
  10597. */
  10598. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10599. /**
  10600. * Prepares the list of attributes required for bones according to the effect defines.
  10601. * @param attribs The current list of supported attribs
  10602. * @param mesh The mesh to prepare the bones attributes for
  10603. * @param defines The current Defines of the effect
  10604. * @param fallbacks The current efffect fallback strategy
  10605. */
  10606. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10607. /**
  10608. * Prepares the list of attributes required for instances according to the effect defines.
  10609. * @param attribs The current list of supported attribs
  10610. * @param defines The current Defines of the effect
  10611. */
  10612. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10613. /**
  10614. * Binds the light shadow information to the effect for the given mesh.
  10615. * @param light The light containing the generator
  10616. * @param scene The scene the lights belongs to
  10617. * @param mesh The mesh we are binding the information to render
  10618. * @param lightIndex The light index in the effect used to render the mesh
  10619. * @param effect The effect we are binding the data to
  10620. */
  10621. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10622. /**
  10623. * Binds the light information to the effect.
  10624. * @param light The light containing the generator
  10625. * @param effect The effect we are binding the data to
  10626. * @param lightIndex The light index in the effect used to render
  10627. */
  10628. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10629. /**
  10630. * Binds the lights information from the scene to the effect for the given mesh.
  10631. * @param scene The scene the lights belongs to
  10632. * @param mesh The mesh we are binding the information to render
  10633. * @param effect The effect we are binding the data to
  10634. * @param defines The generated defines for the effect
  10635. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10636. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10637. */
  10638. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10639. private static _tempFogColor;
  10640. /**
  10641. * Binds the fog information from the scene to the effect for the given mesh.
  10642. * @param scene The scene the lights belongs to
  10643. * @param mesh The mesh we are binding the information to render
  10644. * @param effect The effect we are binding the data to
  10645. * @param linearSpace Defines if the fog effect is applied in linear space
  10646. */
  10647. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10648. /**
  10649. * Binds the bones information from the mesh to the effect.
  10650. * @param mesh The mesh we are binding the information to render
  10651. * @param effect The effect we are binding the data to
  10652. */
  10653. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10654. /**
  10655. * Binds the morph targets information from the mesh to the effect.
  10656. * @param abstractMesh The mesh we are binding the information to render
  10657. * @param effect The effect we are binding the data to
  10658. */
  10659. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10660. /**
  10661. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10662. * @param defines The generated defines used in the effect
  10663. * @param effect The effect we are binding the data to
  10664. * @param scene The scene we are willing to render with logarithmic scale for
  10665. */
  10666. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10667. /**
  10668. * Binds the clip plane information from the scene to the effect.
  10669. * @param scene The scene the clip plane information are extracted from
  10670. * @param effect The effect we are binding the data to
  10671. */
  10672. static BindClipPlane(effect: Effect, scene: Scene): void;
  10673. }
  10674. }
  10675. declare module "babylonjs/Shaders/shadowMap.fragment" {
  10676. /** @hidden */
  10677. export var shadowMapPixelShader: {
  10678. name: string;
  10679. shader: string;
  10680. };
  10681. }
  10682. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  10683. /** @hidden */
  10684. export var bonesDeclaration: {
  10685. name: string;
  10686. shader: string;
  10687. };
  10688. }
  10689. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  10690. /** @hidden */
  10691. export var morphTargetsVertexGlobalDeclaration: {
  10692. name: string;
  10693. shader: string;
  10694. };
  10695. }
  10696. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  10697. /** @hidden */
  10698. export var morphTargetsVertexDeclaration: {
  10699. name: string;
  10700. shader: string;
  10701. };
  10702. }
  10703. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  10704. /** @hidden */
  10705. export var instancesDeclaration: {
  10706. name: string;
  10707. shader: string;
  10708. };
  10709. }
  10710. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  10711. /** @hidden */
  10712. export var helperFunctions: {
  10713. name: string;
  10714. shader: string;
  10715. };
  10716. }
  10717. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  10718. /** @hidden */
  10719. export var morphTargetsVertex: {
  10720. name: string;
  10721. shader: string;
  10722. };
  10723. }
  10724. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  10725. /** @hidden */
  10726. export var instancesVertex: {
  10727. name: string;
  10728. shader: string;
  10729. };
  10730. }
  10731. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  10732. /** @hidden */
  10733. export var bonesVertex: {
  10734. name: string;
  10735. shader: string;
  10736. };
  10737. }
  10738. declare module "babylonjs/Shaders/shadowMap.vertex" {
  10739. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  10740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  10741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  10742. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  10743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  10744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  10745. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  10746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  10747. /** @hidden */
  10748. export var shadowMapVertexShader: {
  10749. name: string;
  10750. shader: string;
  10751. };
  10752. }
  10753. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10754. /** @hidden */
  10755. export var depthBoxBlurPixelShader: {
  10756. name: string;
  10757. shader: string;
  10758. };
  10759. }
  10760. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10761. import { Nullable } from "babylonjs/types";
  10762. import { Scene } from "babylonjs/scene";
  10763. import { Matrix } from "babylonjs/Maths/math";
  10764. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10766. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10767. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10768. import { Effect } from "babylonjs/Materials/effect";
  10769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10770. import "babylonjs/Shaders/shadowMap.fragment";
  10771. import "babylonjs/Shaders/shadowMap.vertex";
  10772. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10773. import { Observable } from "babylonjs/Misc/observable";
  10774. /**
  10775. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10776. */
  10777. export interface ICustomShaderOptions {
  10778. /**
  10779. * Gets or sets the custom shader name to use
  10780. */
  10781. shaderName: string;
  10782. /**
  10783. * The list of attribute names used in the shader
  10784. */
  10785. attributes?: string[];
  10786. /**
  10787. * The list of unifrom names used in the shader
  10788. */
  10789. uniforms?: string[];
  10790. /**
  10791. * The list of sampler names used in the shader
  10792. */
  10793. samplers?: string[];
  10794. /**
  10795. * The list of defines used in the shader
  10796. */
  10797. defines?: string[];
  10798. }
  10799. /**
  10800. * Interface to implement to create a shadow generator compatible with BJS.
  10801. */
  10802. export interface IShadowGenerator {
  10803. /**
  10804. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10805. * @returns The render target texture if present otherwise, null
  10806. */
  10807. getShadowMap(): Nullable<RenderTargetTexture>;
  10808. /**
  10809. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10810. * @returns The render target texture if the shadow map is present otherwise, null
  10811. */
  10812. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10813. /**
  10814. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10815. * @param subMesh The submesh we want to render in the shadow map
  10816. * @param useInstances Defines wether will draw in the map using instances
  10817. * @returns true if ready otherwise, false
  10818. */
  10819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10820. /**
  10821. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10822. * @param defines Defines of the material we want to update
  10823. * @param lightIndex Index of the light in the enabled light list of the material
  10824. */
  10825. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10826. /**
  10827. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10828. * defined in the generator but impacting the effect).
  10829. * It implies the unifroms available on the materials are the standard BJS ones.
  10830. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10831. * @param effect The effect we are binfing the information for
  10832. */
  10833. bindShadowLight(lightIndex: string, effect: Effect): void;
  10834. /**
  10835. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10836. * (eq to shadow prjection matrix * light transform matrix)
  10837. * @returns The transform matrix used to create the shadow map
  10838. */
  10839. getTransformMatrix(): Matrix;
  10840. /**
  10841. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10842. * Cube and 2D textures for instance.
  10843. */
  10844. recreateShadowMap(): void;
  10845. /**
  10846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10847. * @param onCompiled Callback triggered at the and of the effects compilation
  10848. * @param options Sets of optional options forcing the compilation with different modes
  10849. */
  10850. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10851. useInstances: boolean;
  10852. }>): void;
  10853. /**
  10854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10855. * @param options Sets of optional options forcing the compilation with different modes
  10856. * @returns A promise that resolves when the compilation completes
  10857. */
  10858. forceCompilationAsync(options?: Partial<{
  10859. useInstances: boolean;
  10860. }>): Promise<void>;
  10861. /**
  10862. * Serializes the shadow generator setup to a json object.
  10863. * @returns The serialized JSON object
  10864. */
  10865. serialize(): any;
  10866. /**
  10867. * Disposes the Shadow map and related Textures and effects.
  10868. */
  10869. dispose(): void;
  10870. }
  10871. /**
  10872. * Default implementation IShadowGenerator.
  10873. * This is the main object responsible of generating shadows in the framework.
  10874. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10875. */
  10876. export class ShadowGenerator implements IShadowGenerator {
  10877. /**
  10878. * Shadow generator mode None: no filtering applied.
  10879. */
  10880. static readonly FILTER_NONE: number;
  10881. /**
  10882. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10883. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10884. */
  10885. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10886. /**
  10887. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10888. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10889. */
  10890. static readonly FILTER_POISSONSAMPLING: number;
  10891. /**
  10892. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10893. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10894. */
  10895. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10896. /**
  10897. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10898. * edge artifacts on steep falloff.
  10899. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10900. */
  10901. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10902. /**
  10903. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10904. * edge artifacts on steep falloff.
  10905. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10906. */
  10907. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10908. /**
  10909. * Shadow generator mode PCF: Percentage Closer Filtering
  10910. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10911. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10912. */
  10913. static readonly FILTER_PCF: number;
  10914. /**
  10915. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10916. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10917. * Contact Hardening
  10918. */
  10919. static readonly FILTER_PCSS: number;
  10920. /**
  10921. * Reserved for PCF and PCSS
  10922. * Highest Quality.
  10923. *
  10924. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10925. *
  10926. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10927. */
  10928. static readonly QUALITY_HIGH: number;
  10929. /**
  10930. * Reserved for PCF and PCSS
  10931. * Good tradeoff for quality/perf cross devices
  10932. *
  10933. * Execute PCF on a 3*3 kernel.
  10934. *
  10935. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10936. */
  10937. static readonly QUALITY_MEDIUM: number;
  10938. /**
  10939. * Reserved for PCF and PCSS
  10940. * The lowest quality but the fastest.
  10941. *
  10942. * Execute PCF on a 1*1 kernel.
  10943. *
  10944. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10945. */
  10946. static readonly QUALITY_LOW: number;
  10947. /** Gets or sets the custom shader name to use */
  10948. customShaderOptions: ICustomShaderOptions;
  10949. /**
  10950. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10951. */
  10952. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10953. private _bias;
  10954. /**
  10955. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10956. */
  10957. /**
  10958. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10959. */
  10960. bias: number;
  10961. private _normalBias;
  10962. /**
  10963. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10964. */
  10965. /**
  10966. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10967. */
  10968. normalBias: number;
  10969. private _blurBoxOffset;
  10970. /**
  10971. * Gets the blur box offset: offset applied during the blur pass.
  10972. * Only useful if useKernelBlur = false
  10973. */
  10974. /**
  10975. * Sets the blur box offset: offset applied during the blur pass.
  10976. * Only useful if useKernelBlur = false
  10977. */
  10978. blurBoxOffset: number;
  10979. private _blurScale;
  10980. /**
  10981. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10982. * 2 means half of the size.
  10983. */
  10984. /**
  10985. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10986. * 2 means half of the size.
  10987. */
  10988. blurScale: number;
  10989. private _blurKernel;
  10990. /**
  10991. * Gets the blur kernel: kernel size of the blur pass.
  10992. * Only useful if useKernelBlur = true
  10993. */
  10994. /**
  10995. * Sets the blur kernel: kernel size of the blur pass.
  10996. * Only useful if useKernelBlur = true
  10997. */
  10998. blurKernel: number;
  10999. private _useKernelBlur;
  11000. /**
  11001. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11002. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11003. */
  11004. /**
  11005. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11006. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11007. */
  11008. useKernelBlur: boolean;
  11009. private _depthScale;
  11010. /**
  11011. * Gets the depth scale used in ESM mode.
  11012. */
  11013. /**
  11014. * Sets the depth scale used in ESM mode.
  11015. * This can override the scale stored on the light.
  11016. */
  11017. depthScale: number;
  11018. private _filter;
  11019. /**
  11020. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11021. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11022. */
  11023. /**
  11024. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11025. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11026. */
  11027. filter: number;
  11028. /**
  11029. * Gets if the current filter is set to Poisson Sampling.
  11030. */
  11031. /**
  11032. * Sets the current filter to Poisson Sampling.
  11033. */
  11034. usePoissonSampling: boolean;
  11035. /**
  11036. * Gets if the current filter is set to ESM.
  11037. */
  11038. /**
  11039. * Sets the current filter is to ESM.
  11040. */
  11041. useExponentialShadowMap: boolean;
  11042. /**
  11043. * Gets if the current filter is set to filtered ESM.
  11044. */
  11045. /**
  11046. * Gets if the current filter is set to filtered ESM.
  11047. */
  11048. useBlurExponentialShadowMap: boolean;
  11049. /**
  11050. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11051. * exponential to prevent steep falloff artifacts).
  11052. */
  11053. /**
  11054. * Sets the current filter to "close ESM" (using the inverse of the
  11055. * exponential to prevent steep falloff artifacts).
  11056. */
  11057. useCloseExponentialShadowMap: boolean;
  11058. /**
  11059. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11060. * exponential to prevent steep falloff artifacts).
  11061. */
  11062. /**
  11063. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11064. * exponential to prevent steep falloff artifacts).
  11065. */
  11066. useBlurCloseExponentialShadowMap: boolean;
  11067. /**
  11068. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11069. */
  11070. /**
  11071. * Sets the current filter to "PCF" (percentage closer filtering).
  11072. */
  11073. usePercentageCloserFiltering: boolean;
  11074. private _filteringQuality;
  11075. /**
  11076. * Gets the PCF or PCSS Quality.
  11077. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11078. */
  11079. /**
  11080. * Sets the PCF or PCSS Quality.
  11081. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11082. */
  11083. filteringQuality: number;
  11084. /**
  11085. * Gets if the current filter is set to "PCSS" (contact hardening).
  11086. */
  11087. /**
  11088. * Sets the current filter to "PCSS" (contact hardening).
  11089. */
  11090. useContactHardeningShadow: boolean;
  11091. private _contactHardeningLightSizeUVRatio;
  11092. /**
  11093. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11094. * Using a ratio helps keeping shape stability independently of the map size.
  11095. *
  11096. * It does not account for the light projection as it was having too much
  11097. * instability during the light setup or during light position changes.
  11098. *
  11099. * Only valid if useContactHardeningShadow is true.
  11100. */
  11101. /**
  11102. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11103. * Using a ratio helps keeping shape stability independently of the map size.
  11104. *
  11105. * It does not account for the light projection as it was having too much
  11106. * instability during the light setup or during light position changes.
  11107. *
  11108. * Only valid if useContactHardeningShadow is true.
  11109. */
  11110. contactHardeningLightSizeUVRatio: number;
  11111. private _darkness;
  11112. /**
  11113. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11114. * 0 means strongest and 1 would means no shadow.
  11115. * @returns the darkness.
  11116. */
  11117. getDarkness(): number;
  11118. /**
  11119. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11120. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11121. * @returns the shadow generator allowing fluent coding.
  11122. */
  11123. setDarkness(darkness: number): ShadowGenerator;
  11124. private _transparencyShadow;
  11125. /**
  11126. * Sets the ability to have transparent shadow (boolean).
  11127. * @param transparent True if transparent else False
  11128. * @returns the shadow generator allowing fluent coding
  11129. */
  11130. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11131. private _shadowMap;
  11132. private _shadowMap2;
  11133. /**
  11134. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11135. * @returns The render target texture if present otherwise, null
  11136. */
  11137. getShadowMap(): Nullable<RenderTargetTexture>;
  11138. /**
  11139. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11140. * @returns The render target texture if the shadow map is present otherwise, null
  11141. */
  11142. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11143. /**
  11144. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11145. * @param mesh Mesh to add
  11146. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11147. * @returns the Shadow Generator itself
  11148. */
  11149. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11150. /**
  11151. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11152. * @param mesh Mesh to remove
  11153. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11154. * @returns the Shadow Generator itself
  11155. */
  11156. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11157. /**
  11158. * Controls the extent to which the shadows fade out at the edge of the frustum
  11159. * Used only by directionals and spots
  11160. */
  11161. frustumEdgeFalloff: number;
  11162. private _light;
  11163. /**
  11164. * Returns the associated light object.
  11165. * @returns the light generating the shadow
  11166. */
  11167. getLight(): IShadowLight;
  11168. /**
  11169. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11170. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11171. * It might on the other hand introduce peter panning.
  11172. */
  11173. forceBackFacesOnly: boolean;
  11174. private _scene;
  11175. private _lightDirection;
  11176. private _effect;
  11177. private _viewMatrix;
  11178. private _projectionMatrix;
  11179. private _transformMatrix;
  11180. private _cachedPosition;
  11181. private _cachedDirection;
  11182. private _cachedDefines;
  11183. private _currentRenderID;
  11184. private _boxBlurPostprocess;
  11185. private _kernelBlurXPostprocess;
  11186. private _kernelBlurYPostprocess;
  11187. private _blurPostProcesses;
  11188. private _mapSize;
  11189. private _currentFaceIndex;
  11190. private _currentFaceIndexCache;
  11191. private _textureType;
  11192. private _defaultTextureMatrix;
  11193. /** @hidden */
  11194. static _SceneComponentInitialization: (scene: Scene) => void;
  11195. /**
  11196. * Creates a ShadowGenerator object.
  11197. * A ShadowGenerator is the required tool to use the shadows.
  11198. * Each light casting shadows needs to use its own ShadowGenerator.
  11199. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11200. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11201. * @param light The light object generating the shadows.
  11202. * @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.
  11203. */
  11204. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11205. private _initializeGenerator;
  11206. private _initializeShadowMap;
  11207. private _initializeBlurRTTAndPostProcesses;
  11208. private _renderForShadowMap;
  11209. private _renderSubMeshForShadowMap;
  11210. private _applyFilterValues;
  11211. /**
  11212. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11213. * @param onCompiled Callback triggered at the and of the effects compilation
  11214. * @param options Sets of optional options forcing the compilation with different modes
  11215. */
  11216. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11217. useInstances: boolean;
  11218. }>): void;
  11219. /**
  11220. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11221. * @param options Sets of optional options forcing the compilation with different modes
  11222. * @returns A promise that resolves when the compilation completes
  11223. */
  11224. forceCompilationAsync(options?: Partial<{
  11225. useInstances: boolean;
  11226. }>): Promise<void>;
  11227. /**
  11228. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11229. * @param subMesh The submesh we want to render in the shadow map
  11230. * @param useInstances Defines wether will draw in the map using instances
  11231. * @returns true if ready otherwise, false
  11232. */
  11233. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11234. /**
  11235. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11236. * @param defines Defines of the material we want to update
  11237. * @param lightIndex Index of the light in the enabled light list of the material
  11238. */
  11239. prepareDefines(defines: any, lightIndex: number): void;
  11240. /**
  11241. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11242. * defined in the generator but impacting the effect).
  11243. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11244. * @param effect The effect we are binfing the information for
  11245. */
  11246. bindShadowLight(lightIndex: string, effect: Effect): void;
  11247. /**
  11248. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11249. * (eq to shadow prjection matrix * light transform matrix)
  11250. * @returns The transform matrix used to create the shadow map
  11251. */
  11252. getTransformMatrix(): Matrix;
  11253. /**
  11254. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11255. * Cube and 2D textures for instance.
  11256. */
  11257. recreateShadowMap(): void;
  11258. private _disposeBlurPostProcesses;
  11259. private _disposeRTTandPostProcesses;
  11260. /**
  11261. * Disposes the ShadowGenerator.
  11262. * Returns nothing.
  11263. */
  11264. dispose(): void;
  11265. /**
  11266. * Serializes the shadow generator setup to a json object.
  11267. * @returns The serialized JSON object
  11268. */
  11269. serialize(): any;
  11270. /**
  11271. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11272. * @param parsedShadowGenerator The JSON object to parse
  11273. * @param scene The scene to create the shadow map for
  11274. * @returns The parsed shadow generator
  11275. */
  11276. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11277. }
  11278. }
  11279. declare module "babylonjs/Lights/light" {
  11280. import { Nullable } from "babylonjs/types";
  11281. import { Scene } from "babylonjs/scene";
  11282. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11283. import { Node } from "babylonjs/node";
  11284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11285. import { Effect } from "babylonjs/Materials/effect";
  11286. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11287. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11288. /**
  11289. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11290. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11291. * 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.
  11292. */
  11293. export abstract class Light extends Node {
  11294. /**
  11295. * Falloff Default: light is falling off following the material specification:
  11296. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11297. */
  11298. static readonly FALLOFF_DEFAULT: number;
  11299. /**
  11300. * Falloff Physical: light is falling off following the inverse squared distance law.
  11301. */
  11302. static readonly FALLOFF_PHYSICAL: number;
  11303. /**
  11304. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11305. * to enhance interoperability with other engines.
  11306. */
  11307. static readonly FALLOFF_GLTF: number;
  11308. /**
  11309. * Falloff Standard: light is falling off like in the standard material
  11310. * to enhance interoperability with other materials.
  11311. */
  11312. static readonly FALLOFF_STANDARD: number;
  11313. /**
  11314. * If every light affecting the material is in this lightmapMode,
  11315. * material.lightmapTexture adds or multiplies
  11316. * (depends on material.useLightmapAsShadowmap)
  11317. * after every other light calculations.
  11318. */
  11319. static readonly LIGHTMAP_DEFAULT: number;
  11320. /**
  11321. * material.lightmapTexture as only diffuse lighting from this light
  11322. * adds only specular lighting from this light
  11323. * adds dynamic shadows
  11324. */
  11325. static readonly LIGHTMAP_SPECULAR: number;
  11326. /**
  11327. * material.lightmapTexture as only lighting
  11328. * no light calculation from this light
  11329. * only adds dynamic shadows from this light
  11330. */
  11331. static readonly LIGHTMAP_SHADOWSONLY: number;
  11332. /**
  11333. * Each light type uses the default quantity according to its type:
  11334. * point/spot lights use luminous intensity
  11335. * directional lights use illuminance
  11336. */
  11337. static readonly INTENSITYMODE_AUTOMATIC: number;
  11338. /**
  11339. * lumen (lm)
  11340. */
  11341. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11342. /**
  11343. * candela (lm/sr)
  11344. */
  11345. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11346. /**
  11347. * lux (lm/m^2)
  11348. */
  11349. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11350. /**
  11351. * nit (cd/m^2)
  11352. */
  11353. static readonly INTENSITYMODE_LUMINANCE: number;
  11354. /**
  11355. * Light type const id of the point light.
  11356. */
  11357. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11358. /**
  11359. * Light type const id of the directional light.
  11360. */
  11361. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11362. /**
  11363. * Light type const id of the spot light.
  11364. */
  11365. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11366. /**
  11367. * Light type const id of the hemispheric light.
  11368. */
  11369. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11370. /**
  11371. * Diffuse gives the basic color to an object.
  11372. */
  11373. diffuse: Color3;
  11374. /**
  11375. * Specular produces a highlight color on an object.
  11376. * Note: This is note affecting PBR materials.
  11377. */
  11378. specular: Color3;
  11379. /**
  11380. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11381. * falling off base on range or angle.
  11382. * This can be set to any values in Light.FALLOFF_x.
  11383. *
  11384. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11385. * other types of materials.
  11386. */
  11387. falloffType: number;
  11388. /**
  11389. * Strength of the light.
  11390. * Note: By default it is define in the framework own unit.
  11391. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11392. */
  11393. intensity: number;
  11394. private _range;
  11395. protected _inverseSquaredRange: number;
  11396. /**
  11397. * Defines how far from the source the light is impacting in scene units.
  11398. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11399. */
  11400. /**
  11401. * Defines how far from the source the light is impacting in scene units.
  11402. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11403. */
  11404. range: number;
  11405. /**
  11406. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11407. * of light.
  11408. */
  11409. private _photometricScale;
  11410. private _intensityMode;
  11411. /**
  11412. * Gets the photometric scale used to interpret the intensity.
  11413. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11414. */
  11415. /**
  11416. * Sets the photometric scale used to interpret the intensity.
  11417. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11418. */
  11419. intensityMode: number;
  11420. private _radius;
  11421. /**
  11422. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11423. */
  11424. /**
  11425. * sets the light radius used by PBR Materials to simulate soft area lights.
  11426. */
  11427. radius: number;
  11428. private _renderPriority;
  11429. /**
  11430. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11431. * exceeding the number allowed of the materials.
  11432. */
  11433. renderPriority: number;
  11434. private _shadowEnabled;
  11435. /**
  11436. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11437. * the current shadow generator.
  11438. */
  11439. /**
  11440. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11441. * the current shadow generator.
  11442. */
  11443. shadowEnabled: boolean;
  11444. private _includedOnlyMeshes;
  11445. /**
  11446. * Gets the only meshes impacted by this light.
  11447. */
  11448. /**
  11449. * Sets the only meshes impacted by this light.
  11450. */
  11451. includedOnlyMeshes: AbstractMesh[];
  11452. private _excludedMeshes;
  11453. /**
  11454. * Gets the meshes not impacted by this light.
  11455. */
  11456. /**
  11457. * Sets the meshes not impacted by this light.
  11458. */
  11459. excludedMeshes: AbstractMesh[];
  11460. private _excludeWithLayerMask;
  11461. /**
  11462. * Gets the layer id use to find what meshes are not impacted by the light.
  11463. * Inactive if 0
  11464. */
  11465. /**
  11466. * Sets the layer id use to find what meshes are not impacted by the light.
  11467. * Inactive if 0
  11468. */
  11469. excludeWithLayerMask: number;
  11470. private _includeOnlyWithLayerMask;
  11471. /**
  11472. * Gets the layer id use to find what meshes are impacted by the light.
  11473. * Inactive if 0
  11474. */
  11475. /**
  11476. * Sets the layer id use to find what meshes are impacted by the light.
  11477. * Inactive if 0
  11478. */
  11479. includeOnlyWithLayerMask: number;
  11480. private _lightmapMode;
  11481. /**
  11482. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11483. */
  11484. /**
  11485. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11486. */
  11487. lightmapMode: number;
  11488. /**
  11489. * Shadow generator associted to the light.
  11490. * @hidden Internal use only.
  11491. */
  11492. _shadowGenerator: Nullable<IShadowGenerator>;
  11493. /**
  11494. * @hidden Internal use only.
  11495. */
  11496. _excludedMeshesIds: string[];
  11497. /**
  11498. * @hidden Internal use only.
  11499. */
  11500. _includedOnlyMeshesIds: string[];
  11501. /**
  11502. * The current light unifom buffer.
  11503. * @hidden Internal use only.
  11504. */
  11505. _uniformBuffer: UniformBuffer;
  11506. /**
  11507. * Creates a Light object in the scene.
  11508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11509. * @param name The firendly name of the light
  11510. * @param scene The scene the light belongs too
  11511. */
  11512. constructor(name: string, scene: Scene);
  11513. protected abstract _buildUniformLayout(): void;
  11514. /**
  11515. * Sets the passed Effect "effect" with the Light information.
  11516. * @param effect The effect to update
  11517. * @param lightIndex The index of the light in the effect to update
  11518. * @returns The light
  11519. */
  11520. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11521. /**
  11522. * Returns the string "Light".
  11523. * @returns the class name
  11524. */
  11525. getClassName(): string;
  11526. /** @hidden */
  11527. readonly _isLight: boolean;
  11528. /**
  11529. * Converts the light information to a readable string for debug purpose.
  11530. * @param fullDetails Supports for multiple levels of logging within scene loading
  11531. * @returns the human readable light info
  11532. */
  11533. toString(fullDetails?: boolean): string;
  11534. /** @hidden */
  11535. protected _syncParentEnabledState(): void;
  11536. /**
  11537. * Set the enabled state of this node.
  11538. * @param value - the new enabled state
  11539. */
  11540. setEnabled(value: boolean): void;
  11541. /**
  11542. * Returns the Light associated shadow generator if any.
  11543. * @return the associated shadow generator.
  11544. */
  11545. getShadowGenerator(): Nullable<IShadowGenerator>;
  11546. /**
  11547. * Returns a Vector3, the absolute light position in the World.
  11548. * @returns the world space position of the light
  11549. */
  11550. getAbsolutePosition(): Vector3;
  11551. /**
  11552. * Specifies if the light will affect the passed mesh.
  11553. * @param mesh The mesh to test against the light
  11554. * @return true the mesh is affected otherwise, false.
  11555. */
  11556. canAffectMesh(mesh: AbstractMesh): boolean;
  11557. /**
  11558. * Sort function to order lights for rendering.
  11559. * @param a First Light object to compare to second.
  11560. * @param b Second Light object to compare first.
  11561. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11562. */
  11563. static CompareLightsPriority(a: Light, b: Light): number;
  11564. /**
  11565. * Releases resources associated with this node.
  11566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11568. */
  11569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11570. /**
  11571. * Returns the light type ID (integer).
  11572. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11573. */
  11574. getTypeID(): number;
  11575. /**
  11576. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11577. * @returns the scaled intensity in intensity mode unit
  11578. */
  11579. getScaledIntensity(): number;
  11580. /**
  11581. * Returns a new Light object, named "name", from the current one.
  11582. * @param name The name of the cloned light
  11583. * @returns the new created light
  11584. */
  11585. clone(name: string): Nullable<Light>;
  11586. /**
  11587. * Serializes the current light into a Serialization object.
  11588. * @returns the serialized object.
  11589. */
  11590. serialize(): any;
  11591. /**
  11592. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11593. * This new light is named "name" and added to the passed scene.
  11594. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11595. * @param name The friendly name of the light
  11596. * @param scene The scene the new light will belong to
  11597. * @returns the constructor function
  11598. */
  11599. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11600. /**
  11601. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11602. * @param parsedLight The JSON representation of the light
  11603. * @param scene The scene to create the parsed light in
  11604. * @returns the created light after parsing
  11605. */
  11606. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11607. private _hookArrayForExcluded;
  11608. private _hookArrayForIncludedOnly;
  11609. private _resyncMeshes;
  11610. /**
  11611. * Forces the meshes to update their light related information in their rendering used effects
  11612. * @hidden Internal Use Only
  11613. */
  11614. _markMeshesAsLightDirty(): void;
  11615. /**
  11616. * Recomputes the cached photometric scale if needed.
  11617. */
  11618. private _computePhotometricScale;
  11619. /**
  11620. * Returns the Photometric Scale according to the light type and intensity mode.
  11621. */
  11622. private _getPhotometricScale;
  11623. /**
  11624. * Reorder the light in the scene according to their defined priority.
  11625. * @hidden Internal Use Only
  11626. */
  11627. _reorderLightsInScene(): void;
  11628. /**
  11629. * Prepares the list of defines specific to the light type.
  11630. * @param defines the list of defines
  11631. * @param lightIndex defines the index of the light for the effect
  11632. */
  11633. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11634. }
  11635. }
  11636. declare module "babylonjs/Lights/hemisphericLight" {
  11637. import { Nullable } from "babylonjs/types";
  11638. import { Scene } from "babylonjs/scene";
  11639. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  11640. import { Effect } from "babylonjs/Materials/effect";
  11641. import { Light } from "babylonjs/Lights/light";
  11642. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11643. /**
  11644. * The HemisphericLight simulates the ambient environment light,
  11645. * so the passed direction is the light reflection direction, not the incoming direction.
  11646. */
  11647. export class HemisphericLight extends Light {
  11648. /**
  11649. * The groundColor is the light in the opposite direction to the one specified during creation.
  11650. * 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.
  11651. */
  11652. groundColor: Color3;
  11653. /**
  11654. * The light reflection direction, not the incoming direction.
  11655. */
  11656. direction: Vector3;
  11657. /**
  11658. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11659. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11660. * The HemisphericLight can't cast shadows.
  11661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11662. * @param name The friendly name of the light
  11663. * @param direction The direction of the light reflection
  11664. * @param scene The scene the light belongs to
  11665. */
  11666. constructor(name: string, direction: Vector3, scene: Scene);
  11667. protected _buildUniformLayout(): void;
  11668. /**
  11669. * Returns the string "HemisphericLight".
  11670. * @return The class name
  11671. */
  11672. getClassName(): string;
  11673. /**
  11674. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11675. * Returns the updated direction.
  11676. * @param target The target the direction should point to
  11677. * @return The computed direction
  11678. */
  11679. setDirectionToTarget(target: Vector3): Vector3;
  11680. /**
  11681. * Returns the shadow generator associated to the light.
  11682. * @returns Always null for hemispheric lights because it does not support shadows.
  11683. */
  11684. getShadowGenerator(): Nullable<IShadowGenerator>;
  11685. /**
  11686. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11687. * @param effect The effect to update
  11688. * @param lightIndex The index of the light in the effect to update
  11689. * @returns The hemispheric light
  11690. */
  11691. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11692. /**
  11693. * Computes the world matrix of the node
  11694. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11695. * @param useWasUpdatedFlag defines a reserved property
  11696. * @returns the world matrix
  11697. */
  11698. computeWorldMatrix(): Matrix;
  11699. /**
  11700. * Returns the integer 3.
  11701. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11702. */
  11703. getTypeID(): number;
  11704. /**
  11705. * Prepares the list of defines specific to the light type.
  11706. * @param defines the list of defines
  11707. * @param lightIndex defines the index of the light for the effect
  11708. */
  11709. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  11713. declare module "babylonjs/Cameras/VR/webVRCamera" {
  11714. import { Nullable } from "babylonjs/types";
  11715. import { Observable } from "babylonjs/Misc/observable";
  11716. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11717. import { Scene } from "babylonjs/scene";
  11718. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  11719. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  11720. import { Node } from "babylonjs/node";
  11721. import { Ray } from "babylonjs/Culling/ray";
  11722. import "babylonjs/Cameras/RigModes/webVRRigMode";
  11723. /**
  11724. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11725. * IMPORTANT!! The data is right-hand data.
  11726. * @export
  11727. * @interface DevicePose
  11728. */
  11729. export interface DevicePose {
  11730. /**
  11731. * The position of the device, values in array are [x,y,z].
  11732. */
  11733. readonly position: Nullable<Float32Array>;
  11734. /**
  11735. * The linearVelocity of the device, values in array are [x,y,z].
  11736. */
  11737. readonly linearVelocity: Nullable<Float32Array>;
  11738. /**
  11739. * The linearAcceleration of the device, values in array are [x,y,z].
  11740. */
  11741. readonly linearAcceleration: Nullable<Float32Array>;
  11742. /**
  11743. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11744. */
  11745. readonly orientation: Nullable<Float32Array>;
  11746. /**
  11747. * The angularVelocity of the device, values in array are [x,y,z].
  11748. */
  11749. readonly angularVelocity: Nullable<Float32Array>;
  11750. /**
  11751. * The angularAcceleration of the device, values in array are [x,y,z].
  11752. */
  11753. readonly angularAcceleration: Nullable<Float32Array>;
  11754. }
  11755. /**
  11756. * Interface representing a pose controlled object in Babylon.
  11757. * A pose controlled object has both regular pose values as well as pose values
  11758. * from an external device such as a VR head mounted display
  11759. */
  11760. export interface PoseControlled {
  11761. /**
  11762. * The position of the object in babylon space.
  11763. */
  11764. position: Vector3;
  11765. /**
  11766. * The rotation quaternion of the object in babylon space.
  11767. */
  11768. rotationQuaternion: Quaternion;
  11769. /**
  11770. * The position of the device in babylon space.
  11771. */
  11772. devicePosition?: Vector3;
  11773. /**
  11774. * The rotation quaternion of the device in babylon space.
  11775. */
  11776. deviceRotationQuaternion: Quaternion;
  11777. /**
  11778. * The raw pose coming from the device.
  11779. */
  11780. rawPose: Nullable<DevicePose>;
  11781. /**
  11782. * The scale of the device to be used when translating from device space to babylon space.
  11783. */
  11784. deviceScaleFactor: number;
  11785. /**
  11786. * Updates the poseControlled values based on the input device pose.
  11787. * @param poseData the pose data to update the object with
  11788. */
  11789. updateFromDevice(poseData: DevicePose): void;
  11790. }
  11791. /**
  11792. * Set of options to customize the webVRCamera
  11793. */
  11794. export interface WebVROptions {
  11795. /**
  11796. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11797. */
  11798. trackPosition?: boolean;
  11799. /**
  11800. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11801. */
  11802. positionScale?: number;
  11803. /**
  11804. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11805. */
  11806. displayName?: string;
  11807. /**
  11808. * Should the native controller meshes be initialized. (default: true)
  11809. */
  11810. controllerMeshes?: boolean;
  11811. /**
  11812. * Creating a default HemiLight only on controllers. (default: true)
  11813. */
  11814. defaultLightingOnControllers?: boolean;
  11815. /**
  11816. * If you don't want to use the default VR button of the helper. (default: false)
  11817. */
  11818. useCustomVRButton?: boolean;
  11819. /**
  11820. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11821. */
  11822. customVRButton?: HTMLButtonElement;
  11823. /**
  11824. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11825. */
  11826. rayLength?: number;
  11827. /**
  11828. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11829. */
  11830. defaultHeight?: number;
  11831. }
  11832. /**
  11833. * This represents a WebVR camera.
  11834. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11835. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11836. */
  11837. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11838. private webVROptions;
  11839. /**
  11840. * @hidden
  11841. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11842. */
  11843. _vrDevice: any;
  11844. /**
  11845. * The rawPose of the vrDevice.
  11846. */
  11847. rawPose: Nullable<DevicePose>;
  11848. private _onVREnabled;
  11849. private _specsVersion;
  11850. private _attached;
  11851. private _frameData;
  11852. protected _descendants: Array<Node>;
  11853. private _deviceRoomPosition;
  11854. /** @hidden */
  11855. _deviceRoomRotationQuaternion: Quaternion;
  11856. private _standingMatrix;
  11857. /**
  11858. * Represents device position in babylon space.
  11859. */
  11860. devicePosition: Vector3;
  11861. /**
  11862. * Represents device rotation in babylon space.
  11863. */
  11864. deviceRotationQuaternion: Quaternion;
  11865. /**
  11866. * The scale of the device to be used when translating from device space to babylon space.
  11867. */
  11868. deviceScaleFactor: number;
  11869. private _deviceToWorld;
  11870. private _worldToDevice;
  11871. /**
  11872. * References to the webVR controllers for the vrDevice.
  11873. */
  11874. controllers: Array<WebVRController>;
  11875. /**
  11876. * Emits an event when a controller is attached.
  11877. */
  11878. onControllersAttachedObservable: Observable<WebVRController[]>;
  11879. /**
  11880. * Emits an event when a controller's mesh has been loaded;
  11881. */
  11882. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11883. /**
  11884. * Emits an event when the HMD's pose has been updated.
  11885. */
  11886. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11887. private _poseSet;
  11888. /**
  11889. * If the rig cameras be used as parent instead of this camera.
  11890. */
  11891. rigParenting: boolean;
  11892. private _lightOnControllers;
  11893. private _defaultHeight?;
  11894. /**
  11895. * Instantiates a WebVRFreeCamera.
  11896. * @param name The name of the WebVRFreeCamera
  11897. * @param position The starting anchor position for the camera
  11898. * @param scene The scene the camera belongs to
  11899. * @param webVROptions a set of customizable options for the webVRCamera
  11900. */
  11901. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11902. /**
  11903. * Gets the device distance from the ground in meters.
  11904. * @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.
  11905. */
  11906. deviceDistanceToRoomGround(): number;
  11907. /**
  11908. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11909. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11910. */
  11911. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11912. /**
  11913. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11914. * @returns A promise with a boolean set to if the standing matrix is supported.
  11915. */
  11916. useStandingMatrixAsync(): Promise<boolean>;
  11917. /**
  11918. * Disposes the camera
  11919. */
  11920. dispose(): void;
  11921. /**
  11922. * Gets a vrController by name.
  11923. * @param name The name of the controller to retreive
  11924. * @returns the controller matching the name specified or null if not found
  11925. */
  11926. getControllerByName(name: string): Nullable<WebVRController>;
  11927. private _leftController;
  11928. /**
  11929. * The controller corrisponding to the users left hand.
  11930. */
  11931. readonly leftController: Nullable<WebVRController>;
  11932. private _rightController;
  11933. /**
  11934. * The controller corrisponding to the users right hand.
  11935. */
  11936. readonly rightController: Nullable<WebVRController>;
  11937. /**
  11938. * Casts a ray forward from the vrCamera's gaze.
  11939. * @param length Length of the ray (default: 100)
  11940. * @returns the ray corrisponding to the gaze
  11941. */
  11942. getForwardRay(length?: number): Ray;
  11943. /**
  11944. * @hidden
  11945. * Updates the camera based on device's frame data
  11946. */
  11947. _checkInputs(): void;
  11948. /**
  11949. * Updates the poseControlled values based on the input device pose.
  11950. * @param poseData Pose coming from the device
  11951. */
  11952. updateFromDevice(poseData: DevicePose): void;
  11953. private _htmlElementAttached;
  11954. private _detachIfAttached;
  11955. /**
  11956. * WebVR's attach control will start broadcasting frames to the device.
  11957. * Note that in certain browsers (chrome for example) this function must be called
  11958. * within a user-interaction callback. Example:
  11959. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11960. *
  11961. * @param element html element to attach the vrDevice to
  11962. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11963. */
  11964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11965. /**
  11966. * Detaches the camera from the html element and disables VR
  11967. *
  11968. * @param element html element to detach from
  11969. */
  11970. detachControl(element: HTMLElement): void;
  11971. /**
  11972. * @returns the name of this class
  11973. */
  11974. getClassName(): string;
  11975. /**
  11976. * Calls resetPose on the vrDisplay
  11977. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11978. */
  11979. resetToCurrentRotation(): void;
  11980. /**
  11981. * @hidden
  11982. * Updates the rig cameras (left and right eye)
  11983. */
  11984. _updateRigCameras(): void;
  11985. private _workingVector;
  11986. private _oneVector;
  11987. private _workingMatrix;
  11988. private updateCacheCalled;
  11989. private _correctPositionIfNotTrackPosition;
  11990. /**
  11991. * @hidden
  11992. * Updates the cached values of the camera
  11993. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11994. */
  11995. _updateCache(ignoreParentClass?: boolean): void;
  11996. /**
  11997. * @hidden
  11998. * Get current device position in babylon world
  11999. */
  12000. _computeDevicePosition(): void;
  12001. /**
  12002. * Updates the current device position and rotation in the babylon world
  12003. */
  12004. update(): void;
  12005. /**
  12006. * @hidden
  12007. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12008. * @returns an identity matrix
  12009. */
  12010. _getViewMatrix(): Matrix;
  12011. private _tmpMatrix;
  12012. /**
  12013. * This function is called by the two RIG cameras.
  12014. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12015. * @hidden
  12016. */
  12017. _getWebVRViewMatrix(): Matrix;
  12018. /** @hidden */
  12019. _getWebVRProjectionMatrix(): Matrix;
  12020. private _onGamepadConnectedObserver;
  12021. private _onGamepadDisconnectedObserver;
  12022. private _updateCacheWhenTrackingDisabledObserver;
  12023. /**
  12024. * Initializes the controllers and their meshes
  12025. */
  12026. initControllers(): void;
  12027. }
  12028. }
  12029. declare module "babylonjs/PostProcesses/postProcess" {
  12030. import { Nullable } from "babylonjs/types";
  12031. import { SmartArray } from "babylonjs/Misc/smartArray";
  12032. import { Observable } from "babylonjs/Misc/observable";
  12033. import { Color4, Vector2 } from "babylonjs/Maths/math";
  12034. import { Camera } from "babylonjs/Cameras/camera";
  12035. import { Effect } from "babylonjs/Materials/effect";
  12036. import { Animation } from "babylonjs/Animations/animation";
  12037. import "babylonjs/Shaders/postprocess.vertex";
  12038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12039. import { Engine } from "babylonjs/Engines/engine";
  12040. /**
  12041. * Size options for a post process
  12042. */
  12043. export type PostProcessOptions = {
  12044. width: number;
  12045. height: number;
  12046. };
  12047. /**
  12048. * PostProcess can be used to apply a shader to a texture after it has been rendered
  12049. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12050. */
  12051. export class PostProcess {
  12052. /** Name of the PostProcess. */
  12053. name: string;
  12054. /**
  12055. * Width of the texture to apply the post process on
  12056. */
  12057. width: number;
  12058. /**
  12059. * Height of the texture to apply the post process on
  12060. */
  12061. height: number;
  12062. /**
  12063. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  12064. * @hidden
  12065. */
  12066. _outputTexture: Nullable<InternalTexture>;
  12067. /**
  12068. * Sampling mode used by the shader
  12069. * See https://doc.babylonjs.com/classes/3.1/texture
  12070. */
  12071. renderTargetSamplingMode: number;
  12072. /**
  12073. * Clear color to use when screen clearing
  12074. */
  12075. clearColor: Color4;
  12076. /**
  12077. * If the buffer needs to be cleared before applying the post process. (default: true)
  12078. * Should be set to false if shader will overwrite all previous pixels.
  12079. */
  12080. autoClear: boolean;
  12081. /**
  12082. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  12083. */
  12084. alphaMode: number;
  12085. /**
  12086. * Sets the setAlphaBlendConstants of the babylon engine
  12087. */
  12088. alphaConstants: Color4;
  12089. /**
  12090. * Animations to be used for the post processing
  12091. */
  12092. animations: Animation[];
  12093. /**
  12094. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  12095. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  12096. */
  12097. enablePixelPerfectMode: boolean;
  12098. /**
  12099. * Force the postprocess to be applied without taking in account viewport
  12100. */
  12101. forceFullscreenViewport: boolean;
  12102. /**
  12103. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  12104. *
  12105. * | Value | Type | Description |
  12106. * | ----- | ----------------------------------- | ----------- |
  12107. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  12108. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  12109. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  12110. *
  12111. */
  12112. scaleMode: number;
  12113. /**
  12114. * Force textures to be a power of two (default: false)
  12115. */
  12116. alwaysForcePOT: boolean;
  12117. private _samples;
  12118. /**
  12119. * Number of sample textures (default: 1)
  12120. */
  12121. samples: number;
  12122. /**
  12123. * Modify the scale of the post process to be the same as the viewport (default: false)
  12124. */
  12125. adaptScaleToCurrentViewport: boolean;
  12126. private _camera;
  12127. private _scene;
  12128. private _engine;
  12129. private _options;
  12130. private _reusable;
  12131. private _textureType;
  12132. /**
  12133. * Smart array of input and output textures for the post process.
  12134. * @hidden
  12135. */
  12136. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  12137. /**
  12138. * The index in _textures that corresponds to the output texture.
  12139. * @hidden
  12140. */
  12141. _currentRenderTextureInd: number;
  12142. private _effect;
  12143. private _samplers;
  12144. private _fragmentUrl;
  12145. private _vertexUrl;
  12146. private _parameters;
  12147. private _scaleRatio;
  12148. protected _indexParameters: any;
  12149. private _shareOutputWithPostProcess;
  12150. private _texelSize;
  12151. private _forcedOutputTexture;
  12152. /**
  12153. * Returns the fragment url or shader name used in the post process.
  12154. * @returns the fragment url or name in the shader store.
  12155. */
  12156. getEffectName(): string;
  12157. /**
  12158. * An event triggered when the postprocess is activated.
  12159. */
  12160. onActivateObservable: Observable<Camera>;
  12161. private _onActivateObserver;
  12162. /**
  12163. * A function that is added to the onActivateObservable
  12164. */
  12165. onActivate: Nullable<(camera: Camera) => void>;
  12166. /**
  12167. * An event triggered when the postprocess changes its size.
  12168. */
  12169. onSizeChangedObservable: Observable<PostProcess>;
  12170. private _onSizeChangedObserver;
  12171. /**
  12172. * A function that is added to the onSizeChangedObservable
  12173. */
  12174. onSizeChanged: (postProcess: PostProcess) => void;
  12175. /**
  12176. * An event triggered when the postprocess applies its effect.
  12177. */
  12178. onApplyObservable: Observable<Effect>;
  12179. private _onApplyObserver;
  12180. /**
  12181. * A function that is added to the onApplyObservable
  12182. */
  12183. onApply: (effect: Effect) => void;
  12184. /**
  12185. * An event triggered before rendering the postprocess
  12186. */
  12187. onBeforeRenderObservable: Observable<Effect>;
  12188. private _onBeforeRenderObserver;
  12189. /**
  12190. * A function that is added to the onBeforeRenderObservable
  12191. */
  12192. onBeforeRender: (effect: Effect) => void;
  12193. /**
  12194. * An event triggered after rendering the postprocess
  12195. */
  12196. onAfterRenderObservable: Observable<Effect>;
  12197. private _onAfterRenderObserver;
  12198. /**
  12199. * A function that is added to the onAfterRenderObservable
  12200. */
  12201. onAfterRender: (efect: Effect) => void;
  12202. /**
  12203. * 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
  12204. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12205. */
  12206. inputTexture: InternalTexture;
  12207. /**
  12208. * Gets the camera which post process is applied to.
  12209. * @returns The camera the post process is applied to.
  12210. */
  12211. getCamera(): Camera;
  12212. /**
  12213. * Gets the texel size of the postprocess.
  12214. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12215. */
  12216. readonly texelSize: Vector2;
  12217. /**
  12218. * Creates a new instance PostProcess
  12219. * @param name The name of the PostProcess.
  12220. * @param fragmentUrl The url of the fragment shader to be used.
  12221. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12222. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12223. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12224. * @param camera The camera to apply the render pass to.
  12225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12226. * @param engine The engine which the post process will be applied. (default: current engine)
  12227. * @param reusable If the post process can be reused on the same frame. (default: false)
  12228. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12229. * @param textureType Type of textures used when performing the post process. (default: 0)
  12230. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12231. * @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
  12232. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12233. */
  12234. constructor(
  12235. /** Name of the PostProcess. */
  12236. 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);
  12237. /**
  12238. * Gets the engine which this post process belongs to.
  12239. * @returns The engine the post process was enabled with.
  12240. */
  12241. getEngine(): Engine;
  12242. /**
  12243. * The effect that is created when initializing the post process.
  12244. * @returns The created effect corrisponding the the postprocess.
  12245. */
  12246. getEffect(): Effect;
  12247. /**
  12248. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12249. * @param postProcess The post process to share the output with.
  12250. * @returns This post process.
  12251. */
  12252. shareOutputWith(postProcess: PostProcess): PostProcess;
  12253. /**
  12254. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12255. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12256. */
  12257. useOwnOutput(): void;
  12258. /**
  12259. * Updates the effect with the current post process compile time values and recompiles the shader.
  12260. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12261. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12262. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12263. * @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
  12264. * @param onCompiled Called when the shader has been compiled.
  12265. * @param onError Called if there is an error when compiling a shader.
  12266. */
  12267. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12268. /**
  12269. * The post process is reusable if it can be used multiple times within one frame.
  12270. * @returns If the post process is reusable
  12271. */
  12272. isReusable(): boolean;
  12273. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12274. markTextureDirty(): void;
  12275. /**
  12276. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12277. * 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.
  12278. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12279. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12280. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12281. * @returns The target texture that was bound to be written to.
  12282. */
  12283. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12284. /**
  12285. * If the post process is supported.
  12286. */
  12287. readonly isSupported: boolean;
  12288. /**
  12289. * The aspect ratio of the output texture.
  12290. */
  12291. readonly aspectRatio: number;
  12292. /**
  12293. * Get a value indicating if the post-process is ready to be used
  12294. * @returns true if the post-process is ready (shader is compiled)
  12295. */
  12296. isReady(): boolean;
  12297. /**
  12298. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12299. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12300. */
  12301. apply(): Nullable<Effect>;
  12302. private _disposeTextures;
  12303. /**
  12304. * Disposes the post process.
  12305. * @param camera The camera to dispose the post process on.
  12306. */
  12307. dispose(camera?: Camera): void;
  12308. }
  12309. }
  12310. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  12311. /** @hidden */
  12312. export var kernelBlurVaryingDeclaration: {
  12313. name: string;
  12314. shader: string;
  12315. };
  12316. }
  12317. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  12318. /** @hidden */
  12319. export var kernelBlurFragment: {
  12320. name: string;
  12321. shader: string;
  12322. };
  12323. }
  12324. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  12325. /** @hidden */
  12326. export var kernelBlurFragment2: {
  12327. name: string;
  12328. shader: string;
  12329. };
  12330. }
  12331. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  12332. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12333. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  12334. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  12335. /** @hidden */
  12336. export var kernelBlurPixelShader: {
  12337. name: string;
  12338. shader: string;
  12339. };
  12340. }
  12341. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  12342. /** @hidden */
  12343. export var kernelBlurVertex: {
  12344. name: string;
  12345. shader: string;
  12346. };
  12347. }
  12348. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  12349. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12350. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  12351. /** @hidden */
  12352. export var kernelBlurVertexShader: {
  12353. name: string;
  12354. shader: string;
  12355. };
  12356. }
  12357. declare module "babylonjs/PostProcesses/blurPostProcess" {
  12358. import { Vector2 } from "babylonjs/Maths/math";
  12359. import { Nullable } from "babylonjs/types";
  12360. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  12361. import { Camera } from "babylonjs/Cameras/camera";
  12362. import { Effect } from "babylonjs/Materials/effect";
  12363. import { Engine } from "babylonjs/Engines/engine";
  12364. import "babylonjs/Shaders/kernelBlur.fragment";
  12365. import "babylonjs/Shaders/kernelBlur.vertex";
  12366. /**
  12367. * The Blur Post Process which blurs an image based on a kernel and direction.
  12368. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12369. */
  12370. export class BlurPostProcess extends PostProcess {
  12371. /** The direction in which to blur the image. */
  12372. direction: Vector2;
  12373. private blockCompilation;
  12374. protected _kernel: number;
  12375. protected _idealKernel: number;
  12376. protected _packedFloat: boolean;
  12377. private _staticDefines;
  12378. /**
  12379. * Sets the length in pixels of the blur sample region
  12380. */
  12381. /**
  12382. * Gets the length in pixels of the blur sample region
  12383. */
  12384. kernel: number;
  12385. /**
  12386. * Sets wether or not the blur needs to unpack/repack floats
  12387. */
  12388. /**
  12389. * Gets wether or not the blur is unpacking/repacking floats
  12390. */
  12391. packedFloat: boolean;
  12392. /**
  12393. * Creates a new instance BlurPostProcess
  12394. * @param name The name of the effect.
  12395. * @param direction The direction in which to blur the image.
  12396. * @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.
  12397. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12398. * @param camera The camera to apply the render pass to.
  12399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12400. * @param engine The engine which the post process will be applied. (default: current engine)
  12401. * @param reusable If the post process can be reused on the same frame. (default: false)
  12402. * @param textureType Type of textures used when performing the post process. (default: 0)
  12403. * @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)
  12404. */
  12405. constructor(name: string,
  12406. /** The direction in which to blur the image. */
  12407. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12408. /**
  12409. * Updates the effect with the current post process compile time values and recompiles the shader.
  12410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12413. * @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
  12414. * @param onCompiled Called when the shader has been compiled.
  12415. * @param onError Called if there is an error when compiling a shader.
  12416. */
  12417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12418. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12419. /**
  12420. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12421. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12422. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12423. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12424. * The gaps between physical kernels are compensated for in the weighting of the samples
  12425. * @param idealKernel Ideal blur kernel.
  12426. * @return Nearest best kernel.
  12427. */
  12428. protected _nearestBestKernel(idealKernel: number): number;
  12429. /**
  12430. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12431. * @param x The point on the Gaussian distribution to sample.
  12432. * @return the value of the Gaussian function at x.
  12433. */
  12434. protected _gaussianWeight(x: number): number;
  12435. /**
  12436. * Generates a string that can be used as a floating point number in GLSL.
  12437. * @param x Value to print.
  12438. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12439. * @return GLSL float string.
  12440. */
  12441. protected _glslFloat(x: number, decimalFigures?: number): string;
  12442. }
  12443. }
  12444. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  12445. import { Scene } from "babylonjs/scene";
  12446. import { Plane } from "babylonjs/Maths/math";
  12447. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12448. /**
  12449. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12450. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12451. * You can then easily use it as a reflectionTexture on a flat surface.
  12452. * In case the surface is not a plane, please consider relying on reflection probes.
  12453. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12454. */
  12455. export class MirrorTexture extends RenderTargetTexture {
  12456. private scene;
  12457. /**
  12458. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12459. * 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.
  12460. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12461. */
  12462. mirrorPlane: Plane;
  12463. /**
  12464. * Define the blur ratio used to blur the reflection if needed.
  12465. */
  12466. blurRatio: number;
  12467. /**
  12468. * Define the adaptive blur kernel used to blur the reflection if needed.
  12469. * This will autocompute the closest best match for the `blurKernel`
  12470. */
  12471. adaptiveBlurKernel: number;
  12472. /**
  12473. * Define the blur kernel used to blur the reflection if needed.
  12474. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12475. */
  12476. blurKernel: number;
  12477. /**
  12478. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12479. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12480. */
  12481. blurKernelX: number;
  12482. /**
  12483. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12485. */
  12486. blurKernelY: number;
  12487. private _autoComputeBlurKernel;
  12488. protected _onRatioRescale(): void;
  12489. private _updateGammaSpace;
  12490. private _imageProcessingConfigChangeObserver;
  12491. private _transformMatrix;
  12492. private _mirrorMatrix;
  12493. private _savedViewMatrix;
  12494. private _blurX;
  12495. private _blurY;
  12496. private _adaptiveBlurKernel;
  12497. private _blurKernelX;
  12498. private _blurKernelY;
  12499. private _blurRatio;
  12500. /**
  12501. * Instantiates a Mirror Texture.
  12502. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12503. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12504. * You can then easily use it as a reflectionTexture on a flat surface.
  12505. * In case the surface is not a plane, please consider relying on reflection probes.
  12506. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12507. * @param name
  12508. * @param size
  12509. * @param scene
  12510. * @param generateMipMaps
  12511. * @param type
  12512. * @param samplingMode
  12513. * @param generateDepthBuffer
  12514. */
  12515. constructor(name: string, size: number | {
  12516. width: number;
  12517. height: number;
  12518. } | {
  12519. ratio: number;
  12520. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12521. private _preparePostProcesses;
  12522. /**
  12523. * Clone the mirror texture.
  12524. * @returns the cloned texture
  12525. */
  12526. clone(): MirrorTexture;
  12527. /**
  12528. * Serialize the texture to a JSON representation you could use in Parse later on
  12529. * @returns the serialized JSON representation
  12530. */
  12531. serialize(): any;
  12532. /**
  12533. * Dispose the texture and release its associated resources.
  12534. */
  12535. dispose(): void;
  12536. }
  12537. }
  12538. declare module "babylonjs/Materials/Textures/texture" {
  12539. import { Observable } from "babylonjs/Misc/observable";
  12540. import { Nullable } from "babylonjs/types";
  12541. import { Scene } from "babylonjs/scene";
  12542. import { Matrix } from "babylonjs/Maths/math";
  12543. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12544. /**
  12545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12547. */
  12548. export class Texture extends BaseTexture {
  12549. /** @hidden */
  12550. static _AnimationParser: (jsonAnimation: any) => import("babylonjs/Animations/animation").Animation;
  12551. /** @hidden */
  12552. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  12553. /** @hidden */
  12554. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  12555. /** @hidden */
  12556. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  12557. /** nearest is mag = nearest and min = nearest and mip = linear */
  12558. static readonly NEAREST_SAMPLINGMODE: number;
  12559. /** nearest is mag = nearest and min = nearest and mip = linear */
  12560. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12562. static readonly BILINEAR_SAMPLINGMODE: number;
  12563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12564. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12565. /** Trilinear is mag = linear and min = linear and mip = linear */
  12566. static readonly TRILINEAR_SAMPLINGMODE: number;
  12567. /** Trilinear is mag = linear and min = linear and mip = linear */
  12568. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12569. /** mag = nearest and min = nearest and mip = nearest */
  12570. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12571. /** mag = nearest and min = linear and mip = nearest */
  12572. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12573. /** mag = nearest and min = linear and mip = linear */
  12574. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12575. /** mag = nearest and min = linear and mip = none */
  12576. static readonly NEAREST_LINEAR: number;
  12577. /** mag = nearest and min = nearest and mip = none */
  12578. static readonly NEAREST_NEAREST: number;
  12579. /** mag = linear and min = nearest and mip = nearest */
  12580. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12581. /** mag = linear and min = nearest and mip = linear */
  12582. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12583. /** mag = linear and min = linear and mip = none */
  12584. static readonly LINEAR_LINEAR: number;
  12585. /** mag = linear and min = nearest and mip = none */
  12586. static readonly LINEAR_NEAREST: number;
  12587. /** Explicit coordinates mode */
  12588. static readonly EXPLICIT_MODE: number;
  12589. /** Spherical coordinates mode */
  12590. static readonly SPHERICAL_MODE: number;
  12591. /** Planar coordinates mode */
  12592. static readonly PLANAR_MODE: number;
  12593. /** Cubic coordinates mode */
  12594. static readonly CUBIC_MODE: number;
  12595. /** Projection coordinates mode */
  12596. static readonly PROJECTION_MODE: number;
  12597. /** Inverse Cubic coordinates mode */
  12598. static readonly SKYBOX_MODE: number;
  12599. /** Inverse Cubic coordinates mode */
  12600. static readonly INVCUBIC_MODE: number;
  12601. /** Equirectangular coordinates mode */
  12602. static readonly EQUIRECTANGULAR_MODE: number;
  12603. /** Equirectangular Fixed coordinates mode */
  12604. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12605. /** Equirectangular Fixed Mirrored coordinates mode */
  12606. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12607. /** Texture is not repeating outside of 0..1 UVs */
  12608. static readonly CLAMP_ADDRESSMODE: number;
  12609. /** Texture is repeating outside of 0..1 UVs */
  12610. static readonly WRAP_ADDRESSMODE: number;
  12611. /** Texture is repeating and mirrored */
  12612. static readonly MIRROR_ADDRESSMODE: number;
  12613. /**
  12614. * 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
  12615. */
  12616. static UseSerializedUrlIfAny: boolean;
  12617. /**
  12618. * Define the url of the texture.
  12619. */
  12620. url: Nullable<string>;
  12621. /**
  12622. * Define an offset on the texture to offset the u coordinates of the UVs
  12623. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12624. */
  12625. uOffset: number;
  12626. /**
  12627. * Define an offset on the texture to offset the v coordinates of the UVs
  12628. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12629. */
  12630. vOffset: number;
  12631. /**
  12632. * Define an offset on the texture to scale the u coordinates of the UVs
  12633. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12634. */
  12635. uScale: number;
  12636. /**
  12637. * Define an offset on the texture to scale the v coordinates of the UVs
  12638. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12639. */
  12640. vScale: number;
  12641. /**
  12642. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12643. * @see http://doc.babylonjs.com/how_to/more_materials
  12644. */
  12645. uAng: number;
  12646. /**
  12647. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12648. * @see http://doc.babylonjs.com/how_to/more_materials
  12649. */
  12650. vAng: number;
  12651. /**
  12652. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12653. * @see http://doc.babylonjs.com/how_to/more_materials
  12654. */
  12655. wAng: number;
  12656. /**
  12657. * Defines the center of rotation (U)
  12658. */
  12659. uRotationCenter: number;
  12660. /**
  12661. * Defines the center of rotation (V)
  12662. */
  12663. vRotationCenter: number;
  12664. /**
  12665. * Defines the center of rotation (W)
  12666. */
  12667. wRotationCenter: number;
  12668. /**
  12669. * Are mip maps generated for this texture or not.
  12670. */
  12671. readonly noMipmap: boolean;
  12672. private _noMipmap;
  12673. /** @hidden */
  12674. _invertY: boolean;
  12675. private _rowGenerationMatrix;
  12676. private _cachedTextureMatrix;
  12677. private _projectionModeMatrix;
  12678. private _t0;
  12679. private _t1;
  12680. private _t2;
  12681. private _cachedUOffset;
  12682. private _cachedVOffset;
  12683. private _cachedUScale;
  12684. private _cachedVScale;
  12685. private _cachedUAng;
  12686. private _cachedVAng;
  12687. private _cachedWAng;
  12688. private _cachedProjectionMatrixId;
  12689. private _cachedCoordinatesMode;
  12690. /** @hidden */
  12691. protected _initialSamplingMode: number;
  12692. /** @hidden */
  12693. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12694. private _deleteBuffer;
  12695. protected _format: Nullable<number>;
  12696. private _delayedOnLoad;
  12697. private _delayedOnError;
  12698. /**
  12699. * Observable triggered once the texture has been loaded.
  12700. */
  12701. onLoadObservable: Observable<Texture>;
  12702. protected _isBlocking: boolean;
  12703. /**
  12704. * Is the texture preventing material to render while loading.
  12705. * If false, a default texture will be used instead of the loading one during the preparation step.
  12706. */
  12707. isBlocking: boolean;
  12708. /**
  12709. * Get the current sampling mode associated with the texture.
  12710. */
  12711. readonly samplingMode: number;
  12712. /**
  12713. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12714. */
  12715. readonly invertY: boolean;
  12716. /**
  12717. * Instantiates a new texture.
  12718. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12719. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12720. * @param url define the url of the picture to load as a texture
  12721. * @param scene define the scene the texture will belong to
  12722. * @param noMipmap define if the texture will require mip maps or not
  12723. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12724. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12725. * @param onLoad define a callback triggered when the texture has been loaded
  12726. * @param onError define a callback triggered when an error occurred during the loading session
  12727. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12728. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12729. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12730. */
  12731. 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);
  12732. /**
  12733. * Update the url (and optional buffer) of this texture if url was null during construction.
  12734. * @param url the url of the texture
  12735. * @param buffer the buffer of the texture (defaults to null)
  12736. * @param onLoad callback called when the texture is loaded (defaults to null)
  12737. */
  12738. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12739. /**
  12740. * Finish the loading sequence of a texture flagged as delayed load.
  12741. * @hidden
  12742. */
  12743. delayLoad(): void;
  12744. private _prepareRowForTextureGeneration;
  12745. /**
  12746. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12747. * @returns the transform matrix of the texture.
  12748. */
  12749. getTextureMatrix(): Matrix;
  12750. /**
  12751. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12752. * @returns The reflection texture transform
  12753. */
  12754. getReflectionTextureMatrix(): Matrix;
  12755. /**
  12756. * Clones the texture.
  12757. * @returns the cloned texture
  12758. */
  12759. clone(): Texture;
  12760. /**
  12761. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12762. * @returns The JSON representation of the texture
  12763. */
  12764. serialize(): any;
  12765. /**
  12766. * Get the current class name of the texture useful for serialization or dynamic coding.
  12767. * @returns "Texture"
  12768. */
  12769. getClassName(): string;
  12770. /**
  12771. * Dispose the texture and release its associated resources.
  12772. */
  12773. dispose(): void;
  12774. /**
  12775. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12776. * @param parsedTexture Define the JSON representation of the texture
  12777. * @param scene Define the scene the parsed texture should be instantiated in
  12778. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12779. * @returns The parsed texture if successful
  12780. */
  12781. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12782. /**
  12783. * Creates a texture from its base 64 representation.
  12784. * @param data Define the base64 payload without the data: prefix
  12785. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12786. * @param scene Define the scene the texture should belong to
  12787. * @param noMipmap Forces the texture to not create mip map information if true
  12788. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12789. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12790. * @param onLoad define a callback triggered when the texture has been loaded
  12791. * @param onError define a callback triggered when an error occurred during the loading session
  12792. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12793. * @returns the created texture
  12794. */
  12795. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12796. /**
  12797. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12798. * @param data Define the base64 payload without the data: prefix
  12799. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12800. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12801. * @param scene Define the scene the texture should belong to
  12802. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12803. * @param noMipmap Forces the texture to not create mip map information if true
  12804. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12805. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12806. * @param onLoad define a callback triggered when the texture has been loaded
  12807. * @param onError define a callback triggered when an error occurred during the loading session
  12808. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12809. * @returns the created texture
  12810. */
  12811. 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;
  12812. }
  12813. }
  12814. declare module "babylonjs/PostProcesses/postProcessManager" {
  12815. import { Nullable } from "babylonjs/types";
  12816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  12818. import { Scene } from "babylonjs/scene";
  12819. /**
  12820. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12821. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12822. */
  12823. export class PostProcessManager {
  12824. private _scene;
  12825. private _indexBuffer;
  12826. private _vertexBuffers;
  12827. /**
  12828. * Creates a new instance PostProcess
  12829. * @param scene The scene that the post process is associated with.
  12830. */
  12831. constructor(scene: Scene);
  12832. private _prepareBuffers;
  12833. private _buildIndexBuffer;
  12834. /**
  12835. * Rebuilds the vertex buffers of the manager.
  12836. * @hidden
  12837. */
  12838. _rebuild(): void;
  12839. /**
  12840. * Prepares a frame to be run through a post process.
  12841. * @param sourceTexture The input texture to the post procesess. (default: null)
  12842. * @param postProcesses An array of post processes to be run. (default: null)
  12843. * @returns True if the post processes were able to be run.
  12844. * @hidden
  12845. */
  12846. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12847. /**
  12848. * Manually render a set of post processes to a texture.
  12849. * @param postProcesses An array of post processes to be run.
  12850. * @param targetTexture The target texture to render to.
  12851. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12852. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12853. * @param lodLevel defines which lod of the texture to render to
  12854. */
  12855. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12856. /**
  12857. * Finalize the result of the output of the postprocesses.
  12858. * @param doNotPresent If true the result will not be displayed to the screen.
  12859. * @param targetTexture The target texture to render to.
  12860. * @param faceIndex The index of the face to bind the target texture to.
  12861. * @param postProcesses The array of post processes to render.
  12862. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12863. * @hidden
  12864. */
  12865. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12866. /**
  12867. * Disposes of the post process manager.
  12868. */
  12869. dispose(): void;
  12870. }
  12871. }
  12872. declare module "babylonjs/sceneComponent" {
  12873. import { Scene } from "babylonjs/scene";
  12874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12876. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  12877. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  12878. import { Nullable } from "babylonjs/types";
  12879. import { Camera } from "babylonjs/Cameras/camera";
  12880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12881. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12882. import { AbstractScene } from "babylonjs/abstractScene";
  12883. /**
  12884. * Groups all the scene component constants in one place to ease maintenance.
  12885. * @hidden
  12886. */
  12887. export class SceneComponentConstants {
  12888. static readonly NAME_EFFECTLAYER: string;
  12889. static readonly NAME_LAYER: string;
  12890. static readonly NAME_LENSFLARESYSTEM: string;
  12891. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12892. static readonly NAME_PARTICLESYSTEM: string;
  12893. static readonly NAME_GAMEPAD: string;
  12894. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12895. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12896. static readonly NAME_DEPTHRENDERER: string;
  12897. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12898. static readonly NAME_SPRITE: string;
  12899. static readonly NAME_OUTLINERENDERER: string;
  12900. static readonly NAME_PROCEDURALTEXTURE: string;
  12901. static readonly NAME_SHADOWGENERATOR: string;
  12902. static readonly NAME_OCTREE: string;
  12903. static readonly NAME_PHYSICSENGINE: string;
  12904. static readonly NAME_AUDIO: string;
  12905. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12906. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12907. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12908. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12909. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12910. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12911. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12912. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12913. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12914. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12915. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12916. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12917. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12918. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12919. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12920. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12921. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12922. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12923. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12924. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12925. static readonly STEP_AFTERRENDER_AUDIO: number;
  12926. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12927. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12928. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12929. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12930. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12931. static readonly STEP_POINTERMOVE_SPRITE: number;
  12932. static readonly STEP_POINTERDOWN_SPRITE: number;
  12933. static readonly STEP_POINTERUP_SPRITE: number;
  12934. }
  12935. /**
  12936. * This represents a scene component.
  12937. *
  12938. * This is used to decouple the dependency the scene is having on the different workloads like
  12939. * layers, post processes...
  12940. */
  12941. export interface ISceneComponent {
  12942. /**
  12943. * The name of the component. Each component must have a unique name.
  12944. */
  12945. name: string;
  12946. /**
  12947. * The scene the component belongs to.
  12948. */
  12949. scene: Scene;
  12950. /**
  12951. * Register the component to one instance of a scene.
  12952. */
  12953. register(): void;
  12954. /**
  12955. * Rebuilds the elements related to this component in case of
  12956. * context lost for instance.
  12957. */
  12958. rebuild(): void;
  12959. /**
  12960. * Disposes the component and the associated ressources.
  12961. */
  12962. dispose(): void;
  12963. }
  12964. /**
  12965. * This represents a SERIALIZABLE scene component.
  12966. *
  12967. * This extends Scene Component to add Serialization methods on top.
  12968. */
  12969. export interface ISceneSerializableComponent extends ISceneComponent {
  12970. /**
  12971. * Adds all the element from the container to the scene
  12972. * @param container the container holding the elements
  12973. */
  12974. addFromContainer(container: AbstractScene): void;
  12975. /**
  12976. * Removes all the elements in the container from the scene
  12977. * @param container contains the elements to remove
  12978. */
  12979. removeFromContainer(container: AbstractScene): void;
  12980. /**
  12981. * Serializes the component data to the specified json object
  12982. * @param serializationObject The object to serialize to
  12983. */
  12984. serialize(serializationObject: any): void;
  12985. }
  12986. /**
  12987. * Strong typing of a Mesh related stage step action
  12988. */
  12989. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12990. /**
  12991. * Strong typing of a Evaluate Sub Mesh related stage step action
  12992. */
  12993. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12994. /**
  12995. * Strong typing of a Active Mesh related stage step action
  12996. */
  12997. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12998. /**
  12999. * Strong typing of a Camera related stage step action
  13000. */
  13001. export type CameraStageAction = (camera: Camera) => void;
  13002. /**
  13003. * Strong typing of a Render Target related stage step action
  13004. */
  13005. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  13006. /**
  13007. * Strong typing of a RenderingGroup related stage step action
  13008. */
  13009. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  13010. /**
  13011. * Strong typing of a Mesh Render related stage step action
  13012. */
  13013. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  13014. /**
  13015. * Strong typing of a simple stage step action
  13016. */
  13017. export type SimpleStageAction = () => void;
  13018. /**
  13019. * Strong typing of a render target action.
  13020. */
  13021. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  13022. /**
  13023. * Strong typing of a pointer move action.
  13024. */
  13025. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  13026. /**
  13027. * Strong typing of a pointer up/down action.
  13028. */
  13029. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  13030. /**
  13031. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  13032. * @hidden
  13033. */
  13034. export class Stage<T extends Function> extends Array<{
  13035. index: number;
  13036. component: ISceneComponent;
  13037. action: T;
  13038. }> {
  13039. /**
  13040. * Hide ctor from the rest of the world.
  13041. * @param items The items to add.
  13042. */
  13043. private constructor();
  13044. /**
  13045. * Creates a new Stage.
  13046. * @returns A new instance of a Stage
  13047. */
  13048. static Create<T extends Function>(): Stage<T>;
  13049. /**
  13050. * Registers a step in an ordered way in the targeted stage.
  13051. * @param index Defines the position to register the step in
  13052. * @param component Defines the component attached to the step
  13053. * @param action Defines the action to launch during the step
  13054. */
  13055. registerStep(index: number, component: ISceneComponent, action: T): void;
  13056. /**
  13057. * Clears all the steps from the stage.
  13058. */
  13059. clear(): void;
  13060. }
  13061. }
  13062. declare module "babylonjs/Sprites/spriteSceneComponent" {
  13063. import { Nullable } from "babylonjs/types";
  13064. import { Observable } from "babylonjs/Misc/observable";
  13065. import { Scene } from "babylonjs/scene";
  13066. import { Sprite } from "babylonjs/Sprites/sprite";
  13067. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  13068. import { Ray } from "babylonjs/Culling/ray";
  13069. import { Camera } from "babylonjs/Cameras/camera";
  13070. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13071. import { ISceneComponent } from "babylonjs/sceneComponent";
  13072. module "babylonjs/scene" {
  13073. interface Scene {
  13074. /** @hidden */
  13075. _pointerOverSprite: Nullable<Sprite>;
  13076. /** @hidden */
  13077. _pickedDownSprite: Nullable<Sprite>;
  13078. /** @hidden */
  13079. _tempSpritePickingRay: Nullable<Ray>;
  13080. /**
  13081. * All of the sprite managers added to this scene
  13082. * @see http://doc.babylonjs.com/babylon101/sprites
  13083. */
  13084. spriteManagers: Array<ISpriteManager>;
  13085. /**
  13086. * An event triggered when sprites rendering is about to start
  13087. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13088. */
  13089. onBeforeSpritesRenderingObservable: Observable<Scene>;
  13090. /**
  13091. * An event triggered when sprites rendering is done
  13092. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13093. */
  13094. onAfterSpritesRenderingObservable: Observable<Scene>;
  13095. /** @hidden */
  13096. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13097. /** Launch a ray to try to pick a sprite in the scene
  13098. * @param x position on screen
  13099. * @param y position on screen
  13100. * @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
  13101. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13102. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  13103. * @returns a PickingInfo
  13104. */
  13105. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13106. /** Use the given ray to pick a sprite in the scene
  13107. * @param ray The ray (in world space) to use to pick meshes
  13108. * @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
  13109. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13110. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  13111. * @returns a PickingInfo
  13112. */
  13113. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13114. /**
  13115. * Force the sprite under the pointer
  13116. * @param sprite defines the sprite to use
  13117. */
  13118. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  13119. /**
  13120. * Gets the sprite under the pointer
  13121. * @returns a Sprite or null if no sprite is under the pointer
  13122. */
  13123. getPointerOverSprite(): Nullable<Sprite>;
  13124. }
  13125. }
  13126. /**
  13127. * Defines the sprite scene component responsible to manage sprites
  13128. * in a given scene.
  13129. */
  13130. export class SpriteSceneComponent implements ISceneComponent {
  13131. /**
  13132. * The component name helpfull to identify the component in the list of scene components.
  13133. */
  13134. readonly name: string;
  13135. /**
  13136. * The scene the component belongs to.
  13137. */
  13138. scene: Scene;
  13139. /** @hidden */
  13140. private _spritePredicate;
  13141. /**
  13142. * Creates a new instance of the component for the given scene
  13143. * @param scene Defines the scene to register the component in
  13144. */
  13145. constructor(scene: Scene);
  13146. /**
  13147. * Registers the component in a given scene
  13148. */
  13149. register(): void;
  13150. /**
  13151. * Rebuilds the elements related to this component in case of
  13152. * context lost for instance.
  13153. */
  13154. rebuild(): void;
  13155. /**
  13156. * Disposes the component and the associated ressources.
  13157. */
  13158. dispose(): void;
  13159. private _pickSpriteButKeepRay;
  13160. private _pointerMove;
  13161. private _pointerDown;
  13162. private _pointerUp;
  13163. }
  13164. }
  13165. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  13166. /** @hidden */
  13167. export var fogFragmentDeclaration: {
  13168. name: string;
  13169. shader: string;
  13170. };
  13171. }
  13172. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  13173. /** @hidden */
  13174. export var fogFragment: {
  13175. name: string;
  13176. shader: string;
  13177. };
  13178. }
  13179. declare module "babylonjs/Shaders/sprites.fragment" {
  13180. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  13181. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  13182. /** @hidden */
  13183. export var spritesPixelShader: {
  13184. name: string;
  13185. shader: string;
  13186. };
  13187. }
  13188. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  13189. /** @hidden */
  13190. export var fogVertexDeclaration: {
  13191. name: string;
  13192. shader: string;
  13193. };
  13194. }
  13195. declare module "babylonjs/Shaders/sprites.vertex" {
  13196. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  13197. /** @hidden */
  13198. export var spritesVertexShader: {
  13199. name: string;
  13200. shader: string;
  13201. };
  13202. }
  13203. declare module "babylonjs/Sprites/spriteManager" {
  13204. import { IDisposable, Scene } from "babylonjs/scene";
  13205. import { Nullable } from "babylonjs/types";
  13206. import { Observable } from "babylonjs/Misc/observable";
  13207. import { Sprite } from "babylonjs/Sprites/sprite";
  13208. import { Ray } from "babylonjs/Culling/ray";
  13209. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13210. import { Camera } from "babylonjs/Cameras/camera";
  13211. import { Texture } from "babylonjs/Materials/Textures/texture";
  13212. import "babylonjs/Shaders/sprites.fragment";
  13213. import "babylonjs/Shaders/sprites.vertex";
  13214. /**
  13215. * Defines the minimum interface to fullfil in order to be a sprite manager.
  13216. */
  13217. export interface ISpriteManager extends IDisposable {
  13218. /**
  13219. * Restricts the camera to viewing objects with the same layerMask.
  13220. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  13221. */
  13222. layerMask: number;
  13223. /**
  13224. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  13225. */
  13226. isPickable: boolean;
  13227. /**
  13228. * Specifies the rendering group id for this mesh (0 by default)
  13229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  13230. */
  13231. renderingGroupId: number;
  13232. /**
  13233. * Defines the list of sprites managed by the manager.
  13234. */
  13235. sprites: Array<Sprite>;
  13236. /**
  13237. * Tests the intersection of a sprite with a specific ray.
  13238. * @param ray The ray we are sending to test the collision
  13239. * @param camera The camera space we are sending rays in
  13240. * @param predicate A predicate allowing excluding sprites from the list of object to test
  13241. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  13242. * @returns picking info or null.
  13243. */
  13244. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13245. /**
  13246. * Renders the list of sprites on screen.
  13247. */
  13248. render(): void;
  13249. }
  13250. /**
  13251. * Class used to manage multiple sprites on the same spritesheet
  13252. * @see http://doc.babylonjs.com/babylon101/sprites
  13253. */
  13254. export class SpriteManager implements ISpriteManager {
  13255. /** defines the manager's name */
  13256. name: string;
  13257. /** Gets the list of sprites */
  13258. sprites: Sprite[];
  13259. /** Gets or sets the rendering group id (0 by default) */
  13260. renderingGroupId: number;
  13261. /** Gets or sets camera layer mask */
  13262. layerMask: number;
  13263. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  13264. fogEnabled: boolean;
  13265. /** Gets or sets a boolean indicating if the sprites are pickable */
  13266. isPickable: boolean;
  13267. /** Defines the default width of a cell in the spritesheet */
  13268. cellWidth: number;
  13269. /** Defines the default height of a cell in the spritesheet */
  13270. cellHeight: number;
  13271. /**
  13272. * An event triggered when the manager is disposed.
  13273. */
  13274. onDisposeObservable: Observable<SpriteManager>;
  13275. private _onDisposeObserver;
  13276. /**
  13277. * Callback called when the manager is disposed
  13278. */
  13279. onDispose: () => void;
  13280. private _capacity;
  13281. private _spriteTexture;
  13282. private _epsilon;
  13283. private _scene;
  13284. private _vertexData;
  13285. private _buffer;
  13286. private _vertexBuffers;
  13287. private _indexBuffer;
  13288. private _effectBase;
  13289. private _effectFog;
  13290. /**
  13291. * Gets or sets the spritesheet texture
  13292. */
  13293. texture: Texture;
  13294. /**
  13295. * Creates a new sprite manager
  13296. * @param name defines the manager's name
  13297. * @param imgUrl defines the sprite sheet url
  13298. * @param capacity defines the maximum allowed number of sprites
  13299. * @param cellSize defines the size of a sprite cell
  13300. * @param scene defines the hosting scene
  13301. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  13302. * @param samplingMode defines the smapling mode to use with spritesheet
  13303. */
  13304. constructor(
  13305. /** defines the manager's name */
  13306. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  13307. private _appendSpriteVertex;
  13308. /**
  13309. * Intersects the sprites with a ray
  13310. * @param ray defines the ray to intersect with
  13311. * @param camera defines the current active camera
  13312. * @param predicate defines a predicate used to select candidate sprites
  13313. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  13314. * @returns null if no hit or a PickingInfo
  13315. */
  13316. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13317. /**
  13318. * Render all child sprites
  13319. */
  13320. render(): void;
  13321. /**
  13322. * Release associated resources
  13323. */
  13324. dispose(): void;
  13325. }
  13326. }
  13327. declare module "babylonjs/Layers/layerSceneComponent" {
  13328. import { Scene } from "babylonjs/scene";
  13329. import { ISceneComponent } from "babylonjs/sceneComponent";
  13330. import { Layer } from "babylonjs/Layers/layer";
  13331. module "babylonjs/abstractScene" {
  13332. interface AbstractScene {
  13333. /**
  13334. * The list of layers (background and foreground) of the scene
  13335. */
  13336. layers: Array<Layer>;
  13337. }
  13338. }
  13339. /**
  13340. * Defines the layer scene component responsible to manage any layers
  13341. * in a given scene.
  13342. */
  13343. export class LayerSceneComponent implements ISceneComponent {
  13344. /**
  13345. * The component name helpfull to identify the component in the list of scene components.
  13346. */
  13347. readonly name: string;
  13348. /**
  13349. * The scene the component belongs to.
  13350. */
  13351. scene: Scene;
  13352. private _engine;
  13353. /**
  13354. * Creates a new instance of the component for the given scene
  13355. * @param scene Defines the scene to register the component in
  13356. */
  13357. constructor(scene: Scene);
  13358. /**
  13359. * Registers the component in a given scene
  13360. */
  13361. register(): void;
  13362. /**
  13363. * Rebuilds the elements related to this component in case of
  13364. * context lost for instance.
  13365. */
  13366. rebuild(): void;
  13367. /**
  13368. * Disposes the component and the associated ressources.
  13369. */
  13370. dispose(): void;
  13371. private _draw;
  13372. private _drawCameraPredicate;
  13373. private _drawCameraBackground;
  13374. private _drawCameraForeground;
  13375. private _drawRenderTargetPredicate;
  13376. private _drawRenderTargetBackground;
  13377. private _drawRenderTargetForeground;
  13378. }
  13379. }
  13380. declare module "babylonjs/Shaders/layer.fragment" {
  13381. /** @hidden */
  13382. export var layerPixelShader: {
  13383. name: string;
  13384. shader: string;
  13385. };
  13386. }
  13387. declare module "babylonjs/Shaders/layer.vertex" {
  13388. /** @hidden */
  13389. export var layerVertexShader: {
  13390. name: string;
  13391. shader: string;
  13392. };
  13393. }
  13394. declare module "babylonjs/Layers/layer" {
  13395. import { Observable } from "babylonjs/Misc/observable";
  13396. import { Nullable } from "babylonjs/types";
  13397. import { Scene } from "babylonjs/scene";
  13398. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13399. import { Texture } from "babylonjs/Materials/Textures/texture";
  13400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13401. import "babylonjs/Shaders/layer.fragment";
  13402. import "babylonjs/Shaders/layer.vertex";
  13403. /**
  13404. * This represents a full screen 2d layer.
  13405. * This can be useful to display a picture in the background of your scene for instance.
  13406. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13407. */
  13408. export class Layer {
  13409. /**
  13410. * Define the name of the layer.
  13411. */
  13412. name: string;
  13413. /**
  13414. * Define the texture the layer should display.
  13415. */
  13416. texture: Nullable<Texture>;
  13417. /**
  13418. * Is the layer in background or foreground.
  13419. */
  13420. isBackground: boolean;
  13421. /**
  13422. * Define the color of the layer (instead of texture).
  13423. */
  13424. color: Color4;
  13425. /**
  13426. * Define the scale of the layer in order to zoom in out of the texture.
  13427. */
  13428. scale: Vector2;
  13429. /**
  13430. * Define an offset for the layer in order to shift the texture.
  13431. */
  13432. offset: Vector2;
  13433. /**
  13434. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13435. */
  13436. alphaBlendingMode: number;
  13437. /**
  13438. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13439. * Alpha test will not mix with the background color in case of transparency.
  13440. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13441. */
  13442. alphaTest: boolean;
  13443. /**
  13444. * Define a mask to restrict the layer to only some of the scene cameras.
  13445. */
  13446. layerMask: number;
  13447. /**
  13448. * Define the list of render target the layer is visible into.
  13449. */
  13450. renderTargetTextures: RenderTargetTexture[];
  13451. /**
  13452. * Define if the layer is only used in renderTarget or if it also
  13453. * renders in the main frame buffer of the canvas.
  13454. */
  13455. renderOnlyInRenderTargetTextures: boolean;
  13456. private _scene;
  13457. private _vertexBuffers;
  13458. private _indexBuffer;
  13459. private _effect;
  13460. private _alphaTestEffect;
  13461. /**
  13462. * An event triggered when the layer is disposed.
  13463. */
  13464. onDisposeObservable: Observable<Layer>;
  13465. private _onDisposeObserver;
  13466. /**
  13467. * Back compatibility with callback before the onDisposeObservable existed.
  13468. * The set callback will be triggered when the layer has been disposed.
  13469. */
  13470. onDispose: () => void;
  13471. /**
  13472. * An event triggered before rendering the scene
  13473. */
  13474. onBeforeRenderObservable: Observable<Layer>;
  13475. private _onBeforeRenderObserver;
  13476. /**
  13477. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13478. * The set callback will be triggered just before rendering the layer.
  13479. */
  13480. onBeforeRender: () => void;
  13481. /**
  13482. * An event triggered after rendering the scene
  13483. */
  13484. onAfterRenderObservable: Observable<Layer>;
  13485. private _onAfterRenderObserver;
  13486. /**
  13487. * Back compatibility with callback before the onAfterRenderObservable existed.
  13488. * The set callback will be triggered just after rendering the layer.
  13489. */
  13490. onAfterRender: () => void;
  13491. /**
  13492. * Instantiates a new layer.
  13493. * This represents a full screen 2d layer.
  13494. * This can be useful to display a picture in the background of your scene for instance.
  13495. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13496. * @param name Define the name of the layer in the scene
  13497. * @param imgUrl Define the url of the texture to display in the layer
  13498. * @param scene Define the scene the layer belongs to
  13499. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13500. * @param color Defines a color for the layer
  13501. */
  13502. constructor(
  13503. /**
  13504. * Define the name of the layer.
  13505. */
  13506. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13507. private _createIndexBuffer;
  13508. /** @hidden */
  13509. _rebuild(): void;
  13510. /**
  13511. * Renders the layer in the scene.
  13512. */
  13513. render(): void;
  13514. /**
  13515. * Disposes and releases the associated ressources.
  13516. */
  13517. dispose(): void;
  13518. }
  13519. }
  13520. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13521. import { Scene } from "babylonjs/scene";
  13522. import { ISceneComponent } from "babylonjs/sceneComponent";
  13523. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13524. module "babylonjs/abstractScene" {
  13525. interface AbstractScene {
  13526. /**
  13527. * The list of procedural textures added to the scene
  13528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13529. */
  13530. proceduralTextures: Array<ProceduralTexture>;
  13531. }
  13532. }
  13533. /**
  13534. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13535. * in a given scene.
  13536. */
  13537. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13538. /**
  13539. * The component name helpfull to identify the component in the list of scene components.
  13540. */
  13541. readonly name: string;
  13542. /**
  13543. * The scene the component belongs to.
  13544. */
  13545. scene: Scene;
  13546. /**
  13547. * Creates a new instance of the component for the given scene
  13548. * @param scene Defines the scene to register the component in
  13549. */
  13550. constructor(scene: Scene);
  13551. /**
  13552. * Registers the component in a given scene
  13553. */
  13554. register(): void;
  13555. /**
  13556. * Rebuilds the elements related to this component in case of
  13557. * context lost for instance.
  13558. */
  13559. rebuild(): void;
  13560. /**
  13561. * Disposes the component and the associated ressources.
  13562. */
  13563. dispose(): void;
  13564. private _beforeClear;
  13565. }
  13566. }
  13567. declare module "babylonjs/Shaders/procedural.vertex" {
  13568. /** @hidden */
  13569. export var proceduralVertexShader: {
  13570. name: string;
  13571. shader: string;
  13572. };
  13573. }
  13574. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13575. import { Observable } from "babylonjs/Misc/observable";
  13576. import { Nullable } from "babylonjs/types";
  13577. import { Scene } from "babylonjs/scene";
  13578. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13579. import { Effect } from "babylonjs/Materials/effect";
  13580. import { Texture } from "babylonjs/Materials/Textures/texture";
  13581. import "babylonjs/Shaders/procedural.vertex";
  13582. /**
  13583. * 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.
  13584. * This is the base class of any Procedural texture and contains most of the shareable code.
  13585. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13586. */
  13587. export class ProceduralTexture extends Texture {
  13588. isCube: boolean;
  13589. /**
  13590. * Define if the texture is enabled or not (disabled texture will not render)
  13591. */
  13592. isEnabled: boolean;
  13593. /**
  13594. * Define if the texture must be cleared before rendering (default is true)
  13595. */
  13596. autoClear: boolean;
  13597. /**
  13598. * Callback called when the texture is generated
  13599. */
  13600. onGenerated: () => void;
  13601. /**
  13602. * Event raised when the texture is generated
  13603. */
  13604. onGeneratedObservable: Observable<ProceduralTexture>;
  13605. /** @hidden */
  13606. _generateMipMaps: boolean;
  13607. /** @hidden **/
  13608. _effect: Effect;
  13609. /** @hidden */
  13610. _textures: {
  13611. [key: string]: Texture;
  13612. };
  13613. private _size;
  13614. private _currentRefreshId;
  13615. private _refreshRate;
  13616. private _vertexBuffers;
  13617. private _indexBuffer;
  13618. private _uniforms;
  13619. private _samplers;
  13620. private _fragment;
  13621. private _floats;
  13622. private _ints;
  13623. private _floatsArrays;
  13624. private _colors3;
  13625. private _colors4;
  13626. private _vectors2;
  13627. private _vectors3;
  13628. private _matrices;
  13629. private _fallbackTexture;
  13630. private _fallbackTextureUsed;
  13631. private _engine;
  13632. private _cachedDefines;
  13633. private _contentUpdateId;
  13634. private _contentData;
  13635. /**
  13636. * Instantiates a new procedural texture.
  13637. * 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.
  13638. * This is the base class of any Procedural texture and contains most of the shareable code.
  13639. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13640. * @param name Define the name of the texture
  13641. * @param size Define the size of the texture to create
  13642. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13643. * @param scene Define the scene the texture belongs to
  13644. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13645. * @param generateMipMaps Define if the texture should creates mip maps or not
  13646. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13647. */
  13648. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13649. /**
  13650. * The effect that is created when initializing the post process.
  13651. * @returns The created effect corrisponding the the postprocess.
  13652. */
  13653. getEffect(): Effect;
  13654. /**
  13655. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13656. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13657. */
  13658. getContent(): Nullable<ArrayBufferView>;
  13659. private _createIndexBuffer;
  13660. /** @hidden */
  13661. _rebuild(): void;
  13662. /**
  13663. * Resets the texture in order to recreate its associated resources.
  13664. * This can be called in case of context loss
  13665. */
  13666. reset(): void;
  13667. protected _getDefines(): string;
  13668. /**
  13669. * Is the texture ready to be used ? (rendered at least once)
  13670. * @returns true if ready, otherwise, false.
  13671. */
  13672. isReady(): boolean;
  13673. /**
  13674. * Resets the refresh counter of the texture and start bak from scratch.
  13675. * Could be useful to regenerate the texture if it is setup to render only once.
  13676. */
  13677. resetRefreshCounter(): void;
  13678. /**
  13679. * Set the fragment shader to use in order to render the texture.
  13680. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13681. */
  13682. setFragment(fragment: any): void;
  13683. /**
  13684. * Define the refresh rate of the texture or the rendering frequency.
  13685. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13686. */
  13687. refreshRate: number;
  13688. /** @hidden */
  13689. _shouldRender(): boolean;
  13690. /**
  13691. * Get the size the texture is rendering at.
  13692. * @returns the size (texture is always squared)
  13693. */
  13694. getRenderSize(): number;
  13695. /**
  13696. * Resize the texture to new value.
  13697. * @param size Define the new size the texture should have
  13698. * @param generateMipMaps Define whether the new texture should create mip maps
  13699. */
  13700. resize(size: number, generateMipMaps: boolean): void;
  13701. private _checkUniform;
  13702. /**
  13703. * Set a texture in the shader program used to render.
  13704. * @param name Define the name of the uniform samplers as defined in the shader
  13705. * @param texture Define the texture to bind to this sampler
  13706. * @return the texture itself allowing "fluent" like uniform updates
  13707. */
  13708. setTexture(name: string, texture: Texture): ProceduralTexture;
  13709. /**
  13710. * Set a float in the shader.
  13711. * @param name Define the name of the uniform as defined in the shader
  13712. * @param value Define the value to give to the uniform
  13713. * @return the texture itself allowing "fluent" like uniform updates
  13714. */
  13715. setFloat(name: string, value: number): ProceduralTexture;
  13716. /**
  13717. * Set a int in the shader.
  13718. * @param name Define the name of the uniform as defined in the shader
  13719. * @param value Define the value to give to the uniform
  13720. * @return the texture itself allowing "fluent" like uniform updates
  13721. */
  13722. setInt(name: string, value: number): ProceduralTexture;
  13723. /**
  13724. * Set an array of floats in the shader.
  13725. * @param name Define the name of the uniform as defined in the shader
  13726. * @param value Define the value to give to the uniform
  13727. * @return the texture itself allowing "fluent" like uniform updates
  13728. */
  13729. setFloats(name: string, value: number[]): ProceduralTexture;
  13730. /**
  13731. * Set a vec3 in the shader from a Color3.
  13732. * @param name Define the name of the uniform as defined in the shader
  13733. * @param value Define the value to give to the uniform
  13734. * @return the texture itself allowing "fluent" like uniform updates
  13735. */
  13736. setColor3(name: string, value: Color3): ProceduralTexture;
  13737. /**
  13738. * Set a vec4 in the shader from a Color4.
  13739. * @param name Define the name of the uniform as defined in the shader
  13740. * @param value Define the value to give to the uniform
  13741. * @return the texture itself allowing "fluent" like uniform updates
  13742. */
  13743. setColor4(name: string, value: Color4): ProceduralTexture;
  13744. /**
  13745. * Set a vec2 in the shader from a Vector2.
  13746. * @param name Define the name of the uniform as defined in the shader
  13747. * @param value Define the value to give to the uniform
  13748. * @return the texture itself allowing "fluent" like uniform updates
  13749. */
  13750. setVector2(name: string, value: Vector2): ProceduralTexture;
  13751. /**
  13752. * Set a vec3 in the shader from a Vector3.
  13753. * @param name Define the name of the uniform as defined in the shader
  13754. * @param value Define the value to give to the uniform
  13755. * @return the texture itself allowing "fluent" like uniform updates
  13756. */
  13757. setVector3(name: string, value: Vector3): ProceduralTexture;
  13758. /**
  13759. * Set a mat4 in the shader from a MAtrix.
  13760. * @param name Define the name of the uniform as defined in the shader
  13761. * @param value Define the value to give to the uniform
  13762. * @return the texture itself allowing "fluent" like uniform updates
  13763. */
  13764. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13765. /**
  13766. * Render the texture to its associated render target.
  13767. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13768. */
  13769. render(useCameraPostProcess?: boolean): void;
  13770. /**
  13771. * Clone the texture.
  13772. * @returns the cloned texture
  13773. */
  13774. clone(): ProceduralTexture;
  13775. /**
  13776. * Dispose the texture and release its asoociated resources.
  13777. */
  13778. dispose(): void;
  13779. }
  13780. }
  13781. declare module "babylonjs/Particles/baseParticleSystem" {
  13782. import { Nullable } from "babylonjs/types";
  13783. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  13784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13785. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  13786. import { Texture } from "babylonjs/Materials/Textures/texture";
  13787. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13788. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13789. import { Scene } from "babylonjs/scene";
  13790. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  13791. import { Animation } from "babylonjs/Animations/animation";
  13792. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13793. /**
  13794. * This represents the base class for particle system in Babylon.
  13795. * 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.
  13796. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13797. * @example https://doc.babylonjs.com/babylon101/particles
  13798. */
  13799. export class BaseParticleSystem {
  13800. /**
  13801. * Source color is added to the destination color without alpha affecting the result
  13802. */
  13803. static BLENDMODE_ONEONE: number;
  13804. /**
  13805. * Blend current color and particle color using particle’s alpha
  13806. */
  13807. static BLENDMODE_STANDARD: number;
  13808. /**
  13809. * Add current color and particle color multiplied by particle’s alpha
  13810. */
  13811. static BLENDMODE_ADD: number;
  13812. /**
  13813. * Multiply current color with particle color
  13814. */
  13815. static BLENDMODE_MULTIPLY: number;
  13816. /**
  13817. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13818. */
  13819. static BLENDMODE_MULTIPLYADD: number;
  13820. /**
  13821. * List of animations used by the particle system.
  13822. */
  13823. animations: Animation[];
  13824. /**
  13825. * The id of the Particle system.
  13826. */
  13827. id: string;
  13828. /**
  13829. * The friendly name of the Particle system.
  13830. */
  13831. name: string;
  13832. /**
  13833. * The rendering group used by the Particle system to chose when to render.
  13834. */
  13835. renderingGroupId: number;
  13836. /**
  13837. * The emitter represents the Mesh or position we are attaching the particle system to.
  13838. */
  13839. emitter: Nullable<AbstractMesh | Vector3>;
  13840. /**
  13841. * The maximum number of particles to emit per frame
  13842. */
  13843. emitRate: number;
  13844. /**
  13845. * If you want to launch only a few particles at once, that can be done, as well.
  13846. */
  13847. manualEmitCount: number;
  13848. /**
  13849. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13850. */
  13851. updateSpeed: number;
  13852. /**
  13853. * The amount of time the particle system is running (depends of the overall update speed).
  13854. */
  13855. targetStopDuration: number;
  13856. /**
  13857. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13858. */
  13859. disposeOnStop: boolean;
  13860. /**
  13861. * Minimum power of emitting particles.
  13862. */
  13863. minEmitPower: number;
  13864. /**
  13865. * Maximum power of emitting particles.
  13866. */
  13867. maxEmitPower: number;
  13868. /**
  13869. * Minimum life time of emitting particles.
  13870. */
  13871. minLifeTime: number;
  13872. /**
  13873. * Maximum life time of emitting particles.
  13874. */
  13875. maxLifeTime: number;
  13876. /**
  13877. * Minimum Size of emitting particles.
  13878. */
  13879. minSize: number;
  13880. /**
  13881. * Maximum Size of emitting particles.
  13882. */
  13883. maxSize: number;
  13884. /**
  13885. * Minimum scale of emitting particles on X axis.
  13886. */
  13887. minScaleX: number;
  13888. /**
  13889. * Maximum scale of emitting particles on X axis.
  13890. */
  13891. maxScaleX: number;
  13892. /**
  13893. * Minimum scale of emitting particles on Y axis.
  13894. */
  13895. minScaleY: number;
  13896. /**
  13897. * Maximum scale of emitting particles on Y axis.
  13898. */
  13899. maxScaleY: number;
  13900. /**
  13901. * Gets or sets the minimal initial rotation in radians.
  13902. */
  13903. minInitialRotation: number;
  13904. /**
  13905. * Gets or sets the maximal initial rotation in radians.
  13906. */
  13907. maxInitialRotation: number;
  13908. /**
  13909. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13910. */
  13911. minAngularSpeed: number;
  13912. /**
  13913. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13914. */
  13915. maxAngularSpeed: number;
  13916. /**
  13917. * The texture used to render each particle. (this can be a spritesheet)
  13918. */
  13919. particleTexture: Nullable<Texture>;
  13920. /**
  13921. * The layer mask we are rendering the particles through.
  13922. */
  13923. layerMask: number;
  13924. /**
  13925. * This can help using your own shader to render the particle system.
  13926. * The according effect will be created
  13927. */
  13928. customShader: any;
  13929. /**
  13930. * By default particle system starts as soon as they are created. This prevents the
  13931. * automatic start to happen and let you decide when to start emitting particles.
  13932. */
  13933. preventAutoStart: boolean;
  13934. private _noiseTexture;
  13935. /**
  13936. * Gets or sets a texture used to add random noise to particle positions
  13937. */
  13938. noiseTexture: Nullable<ProceduralTexture>;
  13939. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13940. noiseStrength: Vector3;
  13941. /**
  13942. * Callback triggered when the particle animation is ending.
  13943. */
  13944. onAnimationEnd: Nullable<() => void>;
  13945. /**
  13946. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13947. */
  13948. blendMode: number;
  13949. /**
  13950. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13951. * to override the particles.
  13952. */
  13953. forceDepthWrite: boolean;
  13954. /** 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 */
  13955. preWarmCycles: number;
  13956. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13957. preWarmStepOffset: number;
  13958. /**
  13959. * 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)
  13960. */
  13961. spriteCellChangeSpeed: number;
  13962. /**
  13963. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13964. */
  13965. startSpriteCellID: number;
  13966. /**
  13967. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13968. */
  13969. endSpriteCellID: number;
  13970. /**
  13971. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13972. */
  13973. spriteCellWidth: number;
  13974. /**
  13975. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13976. */
  13977. spriteCellHeight: number;
  13978. /**
  13979. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13980. */
  13981. spriteRandomStartCell: boolean;
  13982. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13983. translationPivot: Vector2;
  13984. /** @hidden */
  13985. protected _isAnimationSheetEnabled: boolean;
  13986. /**
  13987. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13988. */
  13989. beginAnimationOnStart: boolean;
  13990. /**
  13991. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13992. */
  13993. beginAnimationFrom: number;
  13994. /**
  13995. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13996. */
  13997. beginAnimationTo: number;
  13998. /**
  13999. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14000. */
  14001. beginAnimationLoop: boolean;
  14002. /**
  14003. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14004. */
  14005. isAnimationSheetEnabled: boolean;
  14006. /**
  14007. * Get hosting scene
  14008. * @returns the scene
  14009. */
  14010. getScene(): Scene;
  14011. /**
  14012. * You can use gravity if you want to give an orientation to your particles.
  14013. */
  14014. gravity: Vector3;
  14015. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14016. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14017. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14018. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14019. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14020. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14021. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14022. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14023. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14024. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14025. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14026. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14027. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14028. /**
  14029. * Defines the delay in milliseconds before starting the system (0 by default)
  14030. */
  14031. startDelay: number;
  14032. /**
  14033. * Gets the current list of drag gradients.
  14034. * You must use addDragGradient and removeDragGradient to udpate this list
  14035. * @returns the list of drag gradients
  14036. */
  14037. getDragGradients(): Nullable<Array<FactorGradient>>;
  14038. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14039. limitVelocityDamping: number;
  14040. /**
  14041. * Gets the current list of limit velocity gradients.
  14042. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14043. * @returns the list of limit velocity gradients
  14044. */
  14045. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14046. /**
  14047. * Gets the current list of color gradients.
  14048. * You must use addColorGradient and removeColorGradient to udpate this list
  14049. * @returns the list of color gradients
  14050. */
  14051. getColorGradients(): Nullable<Array<ColorGradient>>;
  14052. /**
  14053. * Gets the current list of size gradients.
  14054. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14055. * @returns the list of size gradients
  14056. */
  14057. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14058. /**
  14059. * Gets the current list of color remap gradients.
  14060. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14061. * @returns the list of color remap gradients
  14062. */
  14063. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14064. /**
  14065. * Gets the current list of alpha remap gradients.
  14066. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14067. * @returns the list of alpha remap gradients
  14068. */
  14069. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14070. /**
  14071. * Gets the current list of life time gradients.
  14072. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14073. * @returns the list of life time gradients
  14074. */
  14075. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14076. /**
  14077. * Gets the current list of angular speed gradients.
  14078. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14079. * @returns the list of angular speed gradients
  14080. */
  14081. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14082. /**
  14083. * Gets the current list of velocity gradients.
  14084. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14085. * @returns the list of velocity gradients
  14086. */
  14087. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14088. /**
  14089. * Gets the current list of start size gradients.
  14090. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14091. * @returns the list of start size gradients
  14092. */
  14093. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14094. /**
  14095. * Gets the current list of emit rate gradients.
  14096. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14097. * @returns the list of emit rate gradients
  14098. */
  14099. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14100. /**
  14101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14102. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14103. */
  14104. direction1: Vector3;
  14105. /**
  14106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14107. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14108. */
  14109. direction2: Vector3;
  14110. /**
  14111. * 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.
  14112. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14113. */
  14114. minEmitBox: Vector3;
  14115. /**
  14116. * 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.
  14117. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14118. */
  14119. maxEmitBox: Vector3;
  14120. /**
  14121. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14122. */
  14123. color1: Color4;
  14124. /**
  14125. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14126. */
  14127. color2: Color4;
  14128. /**
  14129. * Color the particle will have at the end of its lifetime
  14130. */
  14131. colorDead: Color4;
  14132. /**
  14133. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14134. */
  14135. textureMask: Color4;
  14136. /**
  14137. * The particle emitter type defines the emitter used by the particle system.
  14138. * It can be for example box, sphere, or cone...
  14139. */
  14140. particleEmitterType: IParticleEmitterType;
  14141. /** @hidden */
  14142. _isSubEmitter: boolean;
  14143. /**
  14144. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14145. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14146. */
  14147. billboardMode: number;
  14148. protected _isBillboardBased: boolean;
  14149. /**
  14150. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14151. */
  14152. isBillboardBased: boolean;
  14153. /**
  14154. * The scene the particle system belongs to.
  14155. */
  14156. protected _scene: Scene;
  14157. /**
  14158. * Local cache of defines for image processing.
  14159. */
  14160. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14161. /**
  14162. * Default configuration related to image processing available in the standard Material.
  14163. */
  14164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14165. /**
  14166. * Gets the image processing configuration used either in this material.
  14167. */
  14168. /**
  14169. * Sets the Default image processing configuration used either in the this material.
  14170. *
  14171. * If sets to null, the scene one is in use.
  14172. */
  14173. imageProcessingConfiguration: ImageProcessingConfiguration;
  14174. /**
  14175. * Attaches a new image processing configuration to the Standard Material.
  14176. * @param configuration
  14177. */
  14178. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14179. /** @hidden */
  14180. protected _reset(): void;
  14181. /** @hidden */
  14182. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14183. /**
  14184. * Instantiates a particle system.
  14185. * 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.
  14186. * @param name The name of the particle system
  14187. */
  14188. constructor(name: string);
  14189. /**
  14190. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14191. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14192. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14193. * @returns the emitter
  14194. */
  14195. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14196. /**
  14197. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14198. * @param radius The radius of the hemisphere to emit from
  14199. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14200. * @returns the emitter
  14201. */
  14202. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14203. /**
  14204. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14205. * @param radius The radius of the sphere to emit from
  14206. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14207. * @returns the emitter
  14208. */
  14209. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14210. /**
  14211. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14212. * @param radius The radius of the sphere to emit from
  14213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14215. * @returns the emitter
  14216. */
  14217. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14218. /**
  14219. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14220. * @param radius The radius of the emission cylinder
  14221. * @param height The height of the emission cylinder
  14222. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14223. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14224. * @returns the emitter
  14225. */
  14226. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14227. /**
  14228. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14229. * @param radius The radius of the cylinder to emit from
  14230. * @param height The height of the emission cylinder
  14231. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14232. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14233. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14234. * @returns the emitter
  14235. */
  14236. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14237. /**
  14238. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14239. * @param radius The radius of the cone to emit from
  14240. * @param angle The base angle of the cone
  14241. * @returns the emitter
  14242. */
  14243. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14244. /**
  14245. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14246. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14247. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14248. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14249. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14250. * @returns the emitter
  14251. */
  14252. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14253. }
  14254. }
  14255. declare module "babylonjs/Particles/subEmitter" {
  14256. import { Scene } from "babylonjs/scene";
  14257. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14258. /**
  14259. * Type of sub emitter
  14260. */
  14261. export enum SubEmitterType {
  14262. /**
  14263. * Attached to the particle over it's lifetime
  14264. */
  14265. ATTACHED = 0,
  14266. /**
  14267. * Created when the particle dies
  14268. */
  14269. END = 1
  14270. }
  14271. /**
  14272. * Sub emitter class used to emit particles from an existing particle
  14273. */
  14274. export class SubEmitter {
  14275. /**
  14276. * the particle system to be used by the sub emitter
  14277. */
  14278. particleSystem: ParticleSystem;
  14279. /**
  14280. * Type of the submitter (Default: END)
  14281. */
  14282. type: SubEmitterType;
  14283. /**
  14284. * 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)
  14285. * Note: This only is supported when using an emitter of type Mesh
  14286. */
  14287. inheritDirection: boolean;
  14288. /**
  14289. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14290. */
  14291. inheritedVelocityAmount: number;
  14292. /**
  14293. * Creates a sub emitter
  14294. * @param particleSystem the particle system to be used by the sub emitter
  14295. */
  14296. constructor(
  14297. /**
  14298. * the particle system to be used by the sub emitter
  14299. */
  14300. particleSystem: ParticleSystem);
  14301. /**
  14302. * Clones the sub emitter
  14303. * @returns the cloned sub emitter
  14304. */
  14305. clone(): SubEmitter;
  14306. /**
  14307. * Serialize current object to a JSON object
  14308. * @returns the serialized object
  14309. */
  14310. serialize(): any;
  14311. /** @hidden */
  14312. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14313. /**
  14314. * Creates a new SubEmitter from a serialized JSON version
  14315. * @param serializationObject defines the JSON object to read from
  14316. * @param scene defines the hosting scene
  14317. * @param rootUrl defines the rootUrl for data loading
  14318. * @returns a new SubEmitter
  14319. */
  14320. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14321. /** Release associated resources */
  14322. dispose(): void;
  14323. }
  14324. }
  14325. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14326. /** @hidden */
  14327. export var clipPlaneFragmentDeclaration: {
  14328. name: string;
  14329. shader: string;
  14330. };
  14331. }
  14332. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14333. /** @hidden */
  14334. export var imageProcessingDeclaration: {
  14335. name: string;
  14336. shader: string;
  14337. };
  14338. }
  14339. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14340. /** @hidden */
  14341. export var imageProcessingFunctions: {
  14342. name: string;
  14343. shader: string;
  14344. };
  14345. }
  14346. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14347. /** @hidden */
  14348. export var clipPlaneFragment: {
  14349. name: string;
  14350. shader: string;
  14351. };
  14352. }
  14353. declare module "babylonjs/Shaders/particles.fragment" {
  14354. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14355. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14357. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14359. /** @hidden */
  14360. export var particlesPixelShader: {
  14361. name: string;
  14362. shader: string;
  14363. };
  14364. }
  14365. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14366. /** @hidden */
  14367. export var clipPlaneVertexDeclaration: {
  14368. name: string;
  14369. shader: string;
  14370. };
  14371. }
  14372. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14373. /** @hidden */
  14374. export var clipPlaneVertex: {
  14375. name: string;
  14376. shader: string;
  14377. };
  14378. }
  14379. declare module "babylonjs/Shaders/particles.vertex" {
  14380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14381. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14382. /** @hidden */
  14383. export var particlesVertexShader: {
  14384. name: string;
  14385. shader: string;
  14386. };
  14387. }
  14388. declare module "babylonjs/Particles/particleSystem" {
  14389. import { Nullable } from "babylonjs/types";
  14390. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14391. import { Observable } from "babylonjs/Misc/observable";
  14392. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14393. import { Effect } from "babylonjs/Materials/effect";
  14394. import { Scene, IDisposable } from "babylonjs/scene";
  14395. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14396. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14397. import { Particle } from "babylonjs/Particles/particle";
  14398. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14399. import "babylonjs/Shaders/particles.fragment";
  14400. import "babylonjs/Shaders/particles.vertex";
  14401. /**
  14402. * This represents a particle system in Babylon.
  14403. * 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.
  14404. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14405. * @example https://doc.babylonjs.com/babylon101/particles
  14406. */
  14407. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14408. /**
  14409. * Billboard mode will only apply to Y axis
  14410. */
  14411. static readonly BILLBOARDMODE_Y: number;
  14412. /**
  14413. * Billboard mode will apply to all axes
  14414. */
  14415. static readonly BILLBOARDMODE_ALL: number;
  14416. /**
  14417. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14418. */
  14419. static readonly BILLBOARDMODE_STRETCHED: number;
  14420. /**
  14421. * This function can be defined to provide custom update for active particles.
  14422. * This function will be called instead of regular update (age, position, color, etc.).
  14423. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14424. */
  14425. updateFunction: (particles: Particle[]) => void;
  14426. private _emitterWorldMatrix;
  14427. /**
  14428. * This function can be defined to specify initial direction for every new particle.
  14429. * It by default use the emitterType defined function
  14430. */
  14431. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14432. /**
  14433. * This function can be defined to specify initial position for every new particle.
  14434. * It by default use the emitterType defined function
  14435. */
  14436. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14437. /**
  14438. * @hidden
  14439. */
  14440. _inheritedVelocityOffset: Vector3;
  14441. /**
  14442. * An event triggered when the system is disposed
  14443. */
  14444. onDisposeObservable: Observable<ParticleSystem>;
  14445. private _onDisposeObserver;
  14446. /**
  14447. * Sets a callback that will be triggered when the system is disposed
  14448. */
  14449. onDispose: () => void;
  14450. private _particles;
  14451. private _epsilon;
  14452. private _capacity;
  14453. private _stockParticles;
  14454. private _newPartsExcess;
  14455. private _vertexData;
  14456. private _vertexBuffer;
  14457. private _vertexBuffers;
  14458. private _spriteBuffer;
  14459. private _indexBuffer;
  14460. private _effect;
  14461. private _customEffect;
  14462. private _cachedDefines;
  14463. private _scaledColorStep;
  14464. private _colorDiff;
  14465. private _scaledDirection;
  14466. private _scaledGravity;
  14467. private _currentRenderId;
  14468. private _alive;
  14469. private _useInstancing;
  14470. private _started;
  14471. private _stopped;
  14472. private _actualFrame;
  14473. private _scaledUpdateSpeed;
  14474. private _vertexBufferSize;
  14475. /** @hidden */
  14476. _currentEmitRateGradient: Nullable<FactorGradient>;
  14477. /** @hidden */
  14478. _currentEmitRate1: number;
  14479. /** @hidden */
  14480. _currentEmitRate2: number;
  14481. /** @hidden */
  14482. _currentStartSizeGradient: Nullable<FactorGradient>;
  14483. /** @hidden */
  14484. _currentStartSize1: number;
  14485. /** @hidden */
  14486. _currentStartSize2: number;
  14487. private readonly _rawTextureWidth;
  14488. private _rampGradientsTexture;
  14489. private _useRampGradients;
  14490. /** Gets or sets a boolean indicating that ramp gradients must be used
  14491. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14492. */
  14493. useRampGradients: boolean;
  14494. /**
  14495. * 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.
  14496. * 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: [])
  14497. */
  14498. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14499. private _subEmitters;
  14500. /**
  14501. * @hidden
  14502. * If the particle systems emitter should be disposed when the particle system is disposed
  14503. */
  14504. _disposeEmitterOnDispose: boolean;
  14505. /**
  14506. * The current active Sub-systems, this property is used by the root particle system only.
  14507. */
  14508. activeSubSystems: Array<ParticleSystem>;
  14509. private _rootParticleSystem;
  14510. /**
  14511. * Gets the current list of active particles
  14512. */
  14513. readonly particles: Particle[];
  14514. /**
  14515. * Returns the string "ParticleSystem"
  14516. * @returns a string containing the class name
  14517. */
  14518. getClassName(): string;
  14519. /**
  14520. * Instantiates a particle system.
  14521. * 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.
  14522. * @param name The name of the particle system
  14523. * @param capacity The max number of particles alive at the same time
  14524. * @param scene The scene the particle system belongs to
  14525. * @param customEffect a custom effect used to change the way particles are rendered by default
  14526. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14527. * @param epsilon Offset used to render the particles
  14528. */
  14529. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14530. private _addFactorGradient;
  14531. private _removeFactorGradient;
  14532. /**
  14533. * Adds a new life time gradient
  14534. * @param gradient defines the gradient to use (between 0 and 1)
  14535. * @param factor defines the life time factor to affect to the specified gradient
  14536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14537. * @returns the current particle system
  14538. */
  14539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14540. /**
  14541. * Remove a specific life time gradient
  14542. * @param gradient defines the gradient to remove
  14543. * @returns the current particle system
  14544. */
  14545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14546. /**
  14547. * Adds a new size gradient
  14548. * @param gradient defines the gradient to use (between 0 and 1)
  14549. * @param factor defines the size factor to affect to the specified gradient
  14550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14551. * @returns the current particle system
  14552. */
  14553. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14554. /**
  14555. * Remove a specific size gradient
  14556. * @param gradient defines the gradient to remove
  14557. * @returns the current particle system
  14558. */
  14559. removeSizeGradient(gradient: number): IParticleSystem;
  14560. /**
  14561. * Adds a new color remap gradient
  14562. * @param gradient defines the gradient to use (between 0 and 1)
  14563. * @param min defines the color remap minimal range
  14564. * @param max defines the color remap maximal range
  14565. * @returns the current particle system
  14566. */
  14567. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14568. /**
  14569. * Remove a specific color remap gradient
  14570. * @param gradient defines the gradient to remove
  14571. * @returns the current particle system
  14572. */
  14573. removeColorRemapGradient(gradient: number): IParticleSystem;
  14574. /**
  14575. * Adds a new alpha remap gradient
  14576. * @param gradient defines the gradient to use (between 0 and 1)
  14577. * @param min defines the alpha remap minimal range
  14578. * @param max defines the alpha remap maximal range
  14579. * @returns the current particle system
  14580. */
  14581. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14582. /**
  14583. * Remove a specific alpha remap gradient
  14584. * @param gradient defines the gradient to remove
  14585. * @returns the current particle system
  14586. */
  14587. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14588. /**
  14589. * Adds a new angular speed gradient
  14590. * @param gradient defines the gradient to use (between 0 and 1)
  14591. * @param factor defines the angular speed to affect to the specified gradient
  14592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14593. * @returns the current particle system
  14594. */
  14595. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14596. /**
  14597. * Remove a specific angular speed gradient
  14598. * @param gradient defines the gradient to remove
  14599. * @returns the current particle system
  14600. */
  14601. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14602. /**
  14603. * Adds a new velocity gradient
  14604. * @param gradient defines the gradient to use (between 0 and 1)
  14605. * @param factor defines the velocity to affect to the specified gradient
  14606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14607. * @returns the current particle system
  14608. */
  14609. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14610. /**
  14611. * Remove a specific velocity gradient
  14612. * @param gradient defines the gradient to remove
  14613. * @returns the current particle system
  14614. */
  14615. removeVelocityGradient(gradient: number): IParticleSystem;
  14616. /**
  14617. * Adds a new limit velocity gradient
  14618. * @param gradient defines the gradient to use (between 0 and 1)
  14619. * @param factor defines the limit velocity value to affect to the specified gradient
  14620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14621. * @returns the current particle system
  14622. */
  14623. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14624. /**
  14625. * Remove a specific limit velocity gradient
  14626. * @param gradient defines the gradient to remove
  14627. * @returns the current particle system
  14628. */
  14629. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14630. /**
  14631. * Adds a new drag gradient
  14632. * @param gradient defines the gradient to use (between 0 and 1)
  14633. * @param factor defines the drag value to affect to the specified gradient
  14634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14635. * @returns the current particle system
  14636. */
  14637. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14638. /**
  14639. * Remove a specific drag gradient
  14640. * @param gradient defines the gradient to remove
  14641. * @returns the current particle system
  14642. */
  14643. removeDragGradient(gradient: number): IParticleSystem;
  14644. /**
  14645. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14646. * @param gradient defines the gradient to use (between 0 and 1)
  14647. * @param factor defines the emit rate value to affect to the specified gradient
  14648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14649. * @returns the current particle system
  14650. */
  14651. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14652. /**
  14653. * Remove a specific emit rate gradient
  14654. * @param gradient defines the gradient to remove
  14655. * @returns the current particle system
  14656. */
  14657. removeEmitRateGradient(gradient: number): IParticleSystem;
  14658. /**
  14659. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14660. * @param gradient defines the gradient to use (between 0 and 1)
  14661. * @param factor defines the start size value to affect to the specified gradient
  14662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14663. * @returns the current particle system
  14664. */
  14665. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14666. /**
  14667. * Remove a specific start size gradient
  14668. * @param gradient defines the gradient to remove
  14669. * @returns the current particle system
  14670. */
  14671. removeStartSizeGradient(gradient: number): IParticleSystem;
  14672. private _createRampGradientTexture;
  14673. /**
  14674. * Gets the current list of ramp gradients.
  14675. * You must use addRampGradient and removeRampGradient to udpate this list
  14676. * @returns the list of ramp gradients
  14677. */
  14678. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14679. /**
  14680. * Adds a new ramp gradient used to remap particle colors
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color defines the color to affect to the specified gradient
  14683. * @returns the current particle system
  14684. */
  14685. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14686. /**
  14687. * Remove a specific ramp gradient
  14688. * @param gradient defines the gradient to remove
  14689. * @returns the current particle system
  14690. */
  14691. removeRampGradient(gradient: number): ParticleSystem;
  14692. /**
  14693. * Adds a new color gradient
  14694. * @param gradient defines the gradient to use (between 0 and 1)
  14695. * @param color1 defines the color to affect to the specified gradient
  14696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14697. * @returns this particle system
  14698. */
  14699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14700. /**
  14701. * Remove a specific color gradient
  14702. * @param gradient defines the gradient to remove
  14703. * @returns this particle system
  14704. */
  14705. removeColorGradient(gradient: number): IParticleSystem;
  14706. private _fetchR;
  14707. protected _reset(): void;
  14708. private _resetEffect;
  14709. private _createVertexBuffers;
  14710. private _createIndexBuffer;
  14711. /**
  14712. * Gets the maximum number of particles active at the same time.
  14713. * @returns The max number of active particles.
  14714. */
  14715. getCapacity(): number;
  14716. /**
  14717. * Gets whether there are still active particles in the system.
  14718. * @returns True if it is alive, otherwise false.
  14719. */
  14720. isAlive(): boolean;
  14721. /**
  14722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14723. * @returns True if it has been started, otherwise false.
  14724. */
  14725. isStarted(): boolean;
  14726. private _prepareSubEmitterInternalArray;
  14727. /**
  14728. * Starts the particle system and begins to emit
  14729. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14730. */
  14731. start(delay?: number): void;
  14732. /**
  14733. * Stops the particle system.
  14734. * @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.
  14735. */
  14736. stop(stopSubEmitters?: boolean): void;
  14737. /**
  14738. * Remove all active particles
  14739. */
  14740. reset(): void;
  14741. /**
  14742. * @hidden (for internal use only)
  14743. */
  14744. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14745. /**
  14746. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14747. * Its lifetime will start back at 0.
  14748. */
  14749. recycleParticle: (particle: Particle) => void;
  14750. private _stopSubEmitters;
  14751. private _createParticle;
  14752. private _removeFromRoot;
  14753. private _emitFromParticle;
  14754. private _update;
  14755. /** @hidden */
  14756. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14757. /** @hidden */
  14758. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14759. /** @hidden */
  14760. private _getEffect;
  14761. /**
  14762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14763. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14764. */
  14765. animate(preWarmOnly?: boolean): void;
  14766. private _appendParticleVertices;
  14767. /**
  14768. * Rebuilds the particle system.
  14769. */
  14770. rebuild(): void;
  14771. /**
  14772. * Is this system ready to be used/rendered
  14773. * @return true if the system is ready
  14774. */
  14775. isReady(): boolean;
  14776. private _render;
  14777. /**
  14778. * Renders the particle system in its current state.
  14779. * @returns the current number of particles
  14780. */
  14781. render(): number;
  14782. /**
  14783. * Disposes the particle system and free the associated resources
  14784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14785. */
  14786. dispose(disposeTexture?: boolean): void;
  14787. /**
  14788. * Clones the particle system.
  14789. * @param name The name of the cloned object
  14790. * @param newEmitter The new emitter to use
  14791. * @returns the cloned particle system
  14792. */
  14793. clone(name: string, newEmitter: any): ParticleSystem;
  14794. /**
  14795. * Serializes the particle system to a JSON object.
  14796. * @returns the JSON object
  14797. */
  14798. serialize(): any;
  14799. /** @hidden */
  14800. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14801. /** @hidden */
  14802. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14803. /**
  14804. * Parses a JSON object to create a particle system.
  14805. * @param parsedParticleSystem The JSON object to parse
  14806. * @param scene The scene to create the particle system in
  14807. * @param rootUrl The root url to use to load external dependencies like texture
  14808. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14809. * @returns the Parsed particle system
  14810. */
  14811. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14812. }
  14813. }
  14814. declare module "babylonjs/Particles/particle" {
  14815. import { Nullable } from "babylonjs/types";
  14816. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  14817. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14818. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14819. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  14820. /**
  14821. * A particle represents one of the element emitted by a particle system.
  14822. * This is mainly define by its coordinates, direction, velocity and age.
  14823. */
  14824. export class Particle {
  14825. /**
  14826. * The particle system the particle belongs to.
  14827. */
  14828. particleSystem: ParticleSystem;
  14829. private static _Count;
  14830. /**
  14831. * Unique ID of the particle
  14832. */
  14833. id: number;
  14834. /**
  14835. * The world position of the particle in the scene.
  14836. */
  14837. position: Vector3;
  14838. /**
  14839. * The world direction of the particle in the scene.
  14840. */
  14841. direction: Vector3;
  14842. /**
  14843. * The color of the particle.
  14844. */
  14845. color: Color4;
  14846. /**
  14847. * The color change of the particle per step.
  14848. */
  14849. colorStep: Color4;
  14850. /**
  14851. * Defines how long will the life of the particle be.
  14852. */
  14853. lifeTime: number;
  14854. /**
  14855. * The current age of the particle.
  14856. */
  14857. age: number;
  14858. /**
  14859. * The current size of the particle.
  14860. */
  14861. size: number;
  14862. /**
  14863. * The current scale of the particle.
  14864. */
  14865. scale: Vector2;
  14866. /**
  14867. * The current angle of the particle.
  14868. */
  14869. angle: number;
  14870. /**
  14871. * Defines how fast is the angle changing.
  14872. */
  14873. angularSpeed: number;
  14874. /**
  14875. * Defines the cell index used by the particle to be rendered from a sprite.
  14876. */
  14877. cellIndex: number;
  14878. /**
  14879. * The information required to support color remapping
  14880. */
  14881. remapData: Vector4;
  14882. /** @hidden */
  14883. _randomCellOffset?: number;
  14884. /** @hidden */
  14885. _initialDirection: Nullable<Vector3>;
  14886. /** @hidden */
  14887. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14888. /** @hidden */
  14889. _initialStartSpriteCellID: number;
  14890. /** @hidden */
  14891. _initialEndSpriteCellID: number;
  14892. /** @hidden */
  14893. _currentColorGradient: Nullable<ColorGradient>;
  14894. /** @hidden */
  14895. _currentColor1: Color4;
  14896. /** @hidden */
  14897. _currentColor2: Color4;
  14898. /** @hidden */
  14899. _currentSizeGradient: Nullable<FactorGradient>;
  14900. /** @hidden */
  14901. _currentSize1: number;
  14902. /** @hidden */
  14903. _currentSize2: number;
  14904. /** @hidden */
  14905. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14906. /** @hidden */
  14907. _currentAngularSpeed1: number;
  14908. /** @hidden */
  14909. _currentAngularSpeed2: number;
  14910. /** @hidden */
  14911. _currentVelocityGradient: Nullable<FactorGradient>;
  14912. /** @hidden */
  14913. _currentVelocity1: number;
  14914. /** @hidden */
  14915. _currentVelocity2: number;
  14916. /** @hidden */
  14917. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14918. /** @hidden */
  14919. _currentLimitVelocity1: number;
  14920. /** @hidden */
  14921. _currentLimitVelocity2: number;
  14922. /** @hidden */
  14923. _currentDragGradient: Nullable<FactorGradient>;
  14924. /** @hidden */
  14925. _currentDrag1: number;
  14926. /** @hidden */
  14927. _currentDrag2: number;
  14928. /** @hidden */
  14929. _randomNoiseCoordinates1: Vector3;
  14930. /** @hidden */
  14931. _randomNoiseCoordinates2: Vector3;
  14932. /**
  14933. * Creates a new instance Particle
  14934. * @param particleSystem the particle system the particle belongs to
  14935. */
  14936. constructor(
  14937. /**
  14938. * The particle system the particle belongs to.
  14939. */
  14940. particleSystem: ParticleSystem);
  14941. private updateCellInfoFromSystem;
  14942. /**
  14943. * Defines how the sprite cell index is updated for the particle
  14944. */
  14945. updateCellIndex(): void;
  14946. /** @hidden */
  14947. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14948. /** @hidden */
  14949. _inheritParticleInfoToSubEmitters(): void;
  14950. /** @hidden */
  14951. _reset(): void;
  14952. /**
  14953. * Copy the properties of particle to another one.
  14954. * @param other the particle to copy the information to.
  14955. */
  14956. copyTo(other: Particle): void;
  14957. }
  14958. }
  14959. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  14960. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14961. import { Effect } from "babylonjs/Materials/effect";
  14962. import { Particle } from "babylonjs/Particles/particle";
  14963. /**
  14964. * Particle emitter represents a volume emitting particles.
  14965. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14966. */
  14967. export interface IParticleEmitterType {
  14968. /**
  14969. * Called by the particle System when the direction is computed for the created particle.
  14970. * @param worldMatrix is the world matrix of the particle system
  14971. * @param directionToUpdate is the direction vector to update with the result
  14972. * @param particle is the particle we are computed the direction for
  14973. */
  14974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14975. /**
  14976. * Called by the particle System when the position is computed for the created particle.
  14977. * @param worldMatrix is the world matrix of the particle system
  14978. * @param positionToUpdate is the position vector to update with the result
  14979. * @param particle is the particle we are computed the position for
  14980. */
  14981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14982. /**
  14983. * Clones the current emitter and returns a copy of it
  14984. * @returns the new emitter
  14985. */
  14986. clone(): IParticleEmitterType;
  14987. /**
  14988. * Called by the GPUParticleSystem to setup the update shader
  14989. * @param effect defines the update shader
  14990. */
  14991. applyToShader(effect: Effect): void;
  14992. /**
  14993. * Returns a string to use to update the GPU particles update shader
  14994. * @returns the effect defines string
  14995. */
  14996. getEffectDefines(): string;
  14997. /**
  14998. * Returns a string representing the class name
  14999. * @returns a string containing the class name
  15000. */
  15001. getClassName(): string;
  15002. /**
  15003. * Serializes the particle system to a JSON object.
  15004. * @returns the JSON object
  15005. */
  15006. serialize(): any;
  15007. /**
  15008. * Parse properties from a JSON object
  15009. * @param serializationObject defines the JSON object
  15010. */
  15011. parse(serializationObject: any): void;
  15012. }
  15013. }
  15014. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15015. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15016. import { Effect } from "babylonjs/Materials/effect";
  15017. import { Particle } from "babylonjs/Particles/particle";
  15018. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15019. /**
  15020. * Particle emitter emitting particles from the inside of a box.
  15021. * It emits the particles randomly between 2 given directions.
  15022. */
  15023. export class BoxParticleEmitter implements IParticleEmitterType {
  15024. /**
  15025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15026. */
  15027. direction1: Vector3;
  15028. /**
  15029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15030. */
  15031. direction2: Vector3;
  15032. /**
  15033. * 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.
  15034. */
  15035. minEmitBox: Vector3;
  15036. /**
  15037. * 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.
  15038. */
  15039. maxEmitBox: Vector3;
  15040. /**
  15041. * Creates a new instance BoxParticleEmitter
  15042. */
  15043. constructor();
  15044. /**
  15045. * Called by the particle System when the direction is computed for the created particle.
  15046. * @param worldMatrix is the world matrix of the particle system
  15047. * @param directionToUpdate is the direction vector to update with the result
  15048. * @param particle is the particle we are computed the direction for
  15049. */
  15050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15051. /**
  15052. * Called by the particle System when the position is computed for the created particle.
  15053. * @param worldMatrix is the world matrix of the particle system
  15054. * @param positionToUpdate is the position vector to update with the result
  15055. * @param particle is the particle we are computed the position for
  15056. */
  15057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15058. /**
  15059. * Clones the current emitter and returns a copy of it
  15060. * @returns the new emitter
  15061. */
  15062. clone(): BoxParticleEmitter;
  15063. /**
  15064. * Called by the GPUParticleSystem to setup the update shader
  15065. * @param effect defines the update shader
  15066. */
  15067. applyToShader(effect: Effect): void;
  15068. /**
  15069. * Returns a string to use to update the GPU particles update shader
  15070. * @returns a string containng the defines string
  15071. */
  15072. getEffectDefines(): string;
  15073. /**
  15074. * Returns the string "BoxParticleEmitter"
  15075. * @returns a string containing the class name
  15076. */
  15077. getClassName(): string;
  15078. /**
  15079. * Serializes the particle system to a JSON object.
  15080. * @returns the JSON object
  15081. */
  15082. serialize(): any;
  15083. /**
  15084. * Parse properties from a JSON object
  15085. * @param serializationObject defines the JSON object
  15086. */
  15087. parse(serializationObject: any): void;
  15088. }
  15089. }
  15090. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15091. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15092. import { Effect } from "babylonjs/Materials/effect";
  15093. import { Particle } from "babylonjs/Particles/particle";
  15094. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15095. /**
  15096. * Particle emitter emitting particles from the inside of a cone.
  15097. * It emits the particles alongside the cone volume from the base to the particle.
  15098. * The emission direction might be randomized.
  15099. */
  15100. export class ConeParticleEmitter implements IParticleEmitterType {
  15101. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15102. directionRandomizer: number;
  15103. private _radius;
  15104. private _angle;
  15105. private _height;
  15106. /**
  15107. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15108. */
  15109. radiusRange: number;
  15110. /**
  15111. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15112. */
  15113. heightRange: number;
  15114. /**
  15115. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15116. */
  15117. emitFromSpawnPointOnly: boolean;
  15118. /**
  15119. * Gets or sets the radius of the emission cone
  15120. */
  15121. radius: number;
  15122. /**
  15123. * Gets or sets the angle of the emission cone
  15124. */
  15125. angle: number;
  15126. private _buildHeight;
  15127. /**
  15128. * Creates a new instance ConeParticleEmitter
  15129. * @param radius the radius of the emission cone (1 by default)
  15130. * @param angles the cone base angle (PI by default)
  15131. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15132. */
  15133. constructor(radius?: number, angle?: number,
  15134. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15135. directionRandomizer?: number);
  15136. /**
  15137. * Called by the particle System when the direction is computed for the created particle.
  15138. * @param worldMatrix is the world matrix of the particle system
  15139. * @param directionToUpdate is the direction vector to update with the result
  15140. * @param particle is the particle we are computed the direction for
  15141. */
  15142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15143. /**
  15144. * Called by the particle System when the position is computed for the created particle.
  15145. * @param worldMatrix is the world matrix of the particle system
  15146. * @param positionToUpdate is the position vector to update with the result
  15147. * @param particle is the particle we are computed the position for
  15148. */
  15149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15150. /**
  15151. * Clones the current emitter and returns a copy of it
  15152. * @returns the new emitter
  15153. */
  15154. clone(): ConeParticleEmitter;
  15155. /**
  15156. * Called by the GPUParticleSystem to setup the update shader
  15157. * @param effect defines the update shader
  15158. */
  15159. applyToShader(effect: Effect): void;
  15160. /**
  15161. * Returns a string to use to update the GPU particles update shader
  15162. * @returns a string containng the defines string
  15163. */
  15164. getEffectDefines(): string;
  15165. /**
  15166. * Returns the string "ConeParticleEmitter"
  15167. * @returns a string containing the class name
  15168. */
  15169. getClassName(): string;
  15170. /**
  15171. * Serializes the particle system to a JSON object.
  15172. * @returns the JSON object
  15173. */
  15174. serialize(): any;
  15175. /**
  15176. * Parse properties from a JSON object
  15177. * @param serializationObject defines the JSON object
  15178. */
  15179. parse(serializationObject: any): void;
  15180. }
  15181. }
  15182. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15183. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15184. import { Effect } from "babylonjs/Materials/effect";
  15185. import { Particle } from "babylonjs/Particles/particle";
  15186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15187. /**
  15188. * Particle emitter emitting particles from the inside of a cylinder.
  15189. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15190. */
  15191. export class CylinderParticleEmitter implements IParticleEmitterType {
  15192. /**
  15193. * The radius of the emission cylinder.
  15194. */
  15195. radius: number;
  15196. /**
  15197. * The height of the emission cylinder.
  15198. */
  15199. height: number;
  15200. /**
  15201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15202. */
  15203. radiusRange: number;
  15204. /**
  15205. * How much to randomize the particle direction [0-1].
  15206. */
  15207. directionRandomizer: number;
  15208. /**
  15209. * Creates a new instance CylinderParticleEmitter
  15210. * @param radius the radius of the emission cylinder (1 by default)
  15211. * @param height the height of the emission cylinder (1 by default)
  15212. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15213. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15214. */
  15215. constructor(
  15216. /**
  15217. * The radius of the emission cylinder.
  15218. */
  15219. radius?: number,
  15220. /**
  15221. * The height of the emission cylinder.
  15222. */
  15223. height?: number,
  15224. /**
  15225. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15226. */
  15227. radiusRange?: number,
  15228. /**
  15229. * How much to randomize the particle direction [0-1].
  15230. */
  15231. directionRandomizer?: number);
  15232. /**
  15233. * Called by the particle System when the direction is computed for the created particle.
  15234. * @param worldMatrix is the world matrix of the particle system
  15235. * @param directionToUpdate is the direction vector to update with the result
  15236. * @param particle is the particle we are computed the direction for
  15237. */
  15238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15239. /**
  15240. * Called by the particle System when the position is computed for the created particle.
  15241. * @param worldMatrix is the world matrix of the particle system
  15242. * @param positionToUpdate is the position vector to update with the result
  15243. * @param particle is the particle we are computed the position for
  15244. */
  15245. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15246. /**
  15247. * Clones the current emitter and returns a copy of it
  15248. * @returns the new emitter
  15249. */
  15250. clone(): CylinderParticleEmitter;
  15251. /**
  15252. * Called by the GPUParticleSystem to setup the update shader
  15253. * @param effect defines the update shader
  15254. */
  15255. applyToShader(effect: Effect): void;
  15256. /**
  15257. * Returns a string to use to update the GPU particles update shader
  15258. * @returns a string containng the defines string
  15259. */
  15260. getEffectDefines(): string;
  15261. /**
  15262. * Returns the string "CylinderParticleEmitter"
  15263. * @returns a string containing the class name
  15264. */
  15265. getClassName(): string;
  15266. /**
  15267. * Serializes the particle system to a JSON object.
  15268. * @returns the JSON object
  15269. */
  15270. serialize(): any;
  15271. /**
  15272. * Parse properties from a JSON object
  15273. * @param serializationObject defines the JSON object
  15274. */
  15275. parse(serializationObject: any): void;
  15276. }
  15277. /**
  15278. * Particle emitter emitting particles from the inside of a cylinder.
  15279. * It emits the particles randomly between two vectors.
  15280. */
  15281. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15282. /**
  15283. * The min limit of the emission direction.
  15284. */
  15285. direction1: Vector3;
  15286. /**
  15287. * The max limit of the emission direction.
  15288. */
  15289. direction2: Vector3;
  15290. /**
  15291. * Creates a new instance CylinderDirectedParticleEmitter
  15292. * @param radius the radius of the emission cylinder (1 by default)
  15293. * @param height the height of the emission cylinder (1 by default)
  15294. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15295. * @param direction1 the min limit of the emission direction (up vector by default)
  15296. * @param direction2 the max limit of the emission direction (up vector by default)
  15297. */
  15298. constructor(radius?: number, height?: number, radiusRange?: number,
  15299. /**
  15300. * The min limit of the emission direction.
  15301. */
  15302. direction1?: Vector3,
  15303. /**
  15304. * The max limit of the emission direction.
  15305. */
  15306. direction2?: Vector3);
  15307. /**
  15308. * Called by the particle System when the direction is computed for the created particle.
  15309. * @param worldMatrix is the world matrix of the particle system
  15310. * @param directionToUpdate is the direction vector to update with the result
  15311. * @param particle is the particle we are computed the direction for
  15312. */
  15313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15314. /**
  15315. * Clones the current emitter and returns a copy of it
  15316. * @returns the new emitter
  15317. */
  15318. clone(): CylinderDirectedParticleEmitter;
  15319. /**
  15320. * Called by the GPUParticleSystem to setup the update shader
  15321. * @param effect defines the update shader
  15322. */
  15323. applyToShader(effect: Effect): void;
  15324. /**
  15325. * Returns a string to use to update the GPU particles update shader
  15326. * @returns a string containng the defines string
  15327. */
  15328. getEffectDefines(): string;
  15329. /**
  15330. * Returns the string "CylinderDirectedParticleEmitter"
  15331. * @returns a string containing the class name
  15332. */
  15333. getClassName(): string;
  15334. /**
  15335. * Serializes the particle system to a JSON object.
  15336. * @returns the JSON object
  15337. */
  15338. serialize(): any;
  15339. /**
  15340. * Parse properties from a JSON object
  15341. * @param serializationObject defines the JSON object
  15342. */
  15343. parse(serializationObject: any): void;
  15344. }
  15345. }
  15346. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15347. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15348. import { Effect } from "babylonjs/Materials/effect";
  15349. import { Particle } from "babylonjs/Particles/particle";
  15350. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15351. /**
  15352. * Particle emitter emitting particles from the inside of a hemisphere.
  15353. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15354. */
  15355. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15356. /**
  15357. * The radius of the emission hemisphere.
  15358. */
  15359. radius: number;
  15360. /**
  15361. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15362. */
  15363. radiusRange: number;
  15364. /**
  15365. * How much to randomize the particle direction [0-1].
  15366. */
  15367. directionRandomizer: number;
  15368. /**
  15369. * Creates a new instance HemisphericParticleEmitter
  15370. * @param radius the radius of the emission hemisphere (1 by default)
  15371. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15372. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15373. */
  15374. constructor(
  15375. /**
  15376. * The radius of the emission hemisphere.
  15377. */
  15378. radius?: number,
  15379. /**
  15380. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15381. */
  15382. radiusRange?: number,
  15383. /**
  15384. * How much to randomize the particle direction [0-1].
  15385. */
  15386. directionRandomizer?: number);
  15387. /**
  15388. * Called by the particle System when the direction is computed for the created particle.
  15389. * @param worldMatrix is the world matrix of the particle system
  15390. * @param directionToUpdate is the direction vector to update with the result
  15391. * @param particle is the particle we are computed the direction for
  15392. */
  15393. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15394. /**
  15395. * Called by the particle System when the position is computed for the created particle.
  15396. * @param worldMatrix is the world matrix of the particle system
  15397. * @param positionToUpdate is the position vector to update with the result
  15398. * @param particle is the particle we are computed the position for
  15399. */
  15400. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15401. /**
  15402. * Clones the current emitter and returns a copy of it
  15403. * @returns the new emitter
  15404. */
  15405. clone(): HemisphericParticleEmitter;
  15406. /**
  15407. * Called by the GPUParticleSystem to setup the update shader
  15408. * @param effect defines the update shader
  15409. */
  15410. applyToShader(effect: Effect): void;
  15411. /**
  15412. * Returns a string to use to update the GPU particles update shader
  15413. * @returns a string containng the defines string
  15414. */
  15415. getEffectDefines(): string;
  15416. /**
  15417. * Returns the string "HemisphericParticleEmitter"
  15418. * @returns a string containing the class name
  15419. */
  15420. getClassName(): string;
  15421. /**
  15422. * Serializes the particle system to a JSON object.
  15423. * @returns the JSON object
  15424. */
  15425. serialize(): any;
  15426. /**
  15427. * Parse properties from a JSON object
  15428. * @param serializationObject defines the JSON object
  15429. */
  15430. parse(serializationObject: any): void;
  15431. }
  15432. }
  15433. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15434. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15435. import { Effect } from "babylonjs/Materials/effect";
  15436. import { Particle } from "babylonjs/Particles/particle";
  15437. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15438. /**
  15439. * Particle emitter emitting particles from a point.
  15440. * It emits the particles randomly between 2 given directions.
  15441. */
  15442. export class PointParticleEmitter implements IParticleEmitterType {
  15443. /**
  15444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15445. */
  15446. direction1: Vector3;
  15447. /**
  15448. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15449. */
  15450. direction2: Vector3;
  15451. /**
  15452. * Creates a new instance PointParticleEmitter
  15453. */
  15454. constructor();
  15455. /**
  15456. * Called by the particle System when the direction is computed for the created particle.
  15457. * @param worldMatrix is the world matrix of the particle system
  15458. * @param directionToUpdate is the direction vector to update with the result
  15459. * @param particle is the particle we are computed the direction for
  15460. */
  15461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15462. /**
  15463. * Called by the particle System when the position is computed for the created particle.
  15464. * @param worldMatrix is the world matrix of the particle system
  15465. * @param positionToUpdate is the position vector to update with the result
  15466. * @param particle is the particle we are computed the position for
  15467. */
  15468. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15469. /**
  15470. * Clones the current emitter and returns a copy of it
  15471. * @returns the new emitter
  15472. */
  15473. clone(): PointParticleEmitter;
  15474. /**
  15475. * Called by the GPUParticleSystem to setup the update shader
  15476. * @param effect defines the update shader
  15477. */
  15478. applyToShader(effect: Effect): void;
  15479. /**
  15480. * Returns a string to use to update the GPU particles update shader
  15481. * @returns a string containng the defines string
  15482. */
  15483. getEffectDefines(): string;
  15484. /**
  15485. * Returns the string "PointParticleEmitter"
  15486. * @returns a string containing the class name
  15487. */
  15488. getClassName(): string;
  15489. /**
  15490. * Serializes the particle system to a JSON object.
  15491. * @returns the JSON object
  15492. */
  15493. serialize(): any;
  15494. /**
  15495. * Parse properties from a JSON object
  15496. * @param serializationObject defines the JSON object
  15497. */
  15498. parse(serializationObject: any): void;
  15499. }
  15500. }
  15501. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15502. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15503. import { Effect } from "babylonjs/Materials/effect";
  15504. import { Particle } from "babylonjs/Particles/particle";
  15505. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15506. /**
  15507. * Particle emitter emitting particles from the inside of a sphere.
  15508. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15509. */
  15510. export class SphereParticleEmitter implements IParticleEmitterType {
  15511. /**
  15512. * The radius of the emission sphere.
  15513. */
  15514. radius: number;
  15515. /**
  15516. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15517. */
  15518. radiusRange: number;
  15519. /**
  15520. * How much to randomize the particle direction [0-1].
  15521. */
  15522. directionRandomizer: number;
  15523. /**
  15524. * Creates a new instance SphereParticleEmitter
  15525. * @param radius the radius of the emission sphere (1 by default)
  15526. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15527. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15528. */
  15529. constructor(
  15530. /**
  15531. * The radius of the emission sphere.
  15532. */
  15533. radius?: number,
  15534. /**
  15535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15536. */
  15537. radiusRange?: number,
  15538. /**
  15539. * How much to randomize the particle direction [0-1].
  15540. */
  15541. directionRandomizer?: number);
  15542. /**
  15543. * Called by the particle System when the direction is computed for the created particle.
  15544. * @param worldMatrix is the world matrix of the particle system
  15545. * @param directionToUpdate is the direction vector to update with the result
  15546. * @param particle is the particle we are computed the direction for
  15547. */
  15548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15549. /**
  15550. * Called by the particle System when the position is computed for the created particle.
  15551. * @param worldMatrix is the world matrix of the particle system
  15552. * @param positionToUpdate is the position vector to update with the result
  15553. * @param particle is the particle we are computed the position for
  15554. */
  15555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15556. /**
  15557. * Clones the current emitter and returns a copy of it
  15558. * @returns the new emitter
  15559. */
  15560. clone(): SphereParticleEmitter;
  15561. /**
  15562. * Called by the GPUParticleSystem to setup the update shader
  15563. * @param effect defines the update shader
  15564. */
  15565. applyToShader(effect: Effect): void;
  15566. /**
  15567. * Returns a string to use to update the GPU particles update shader
  15568. * @returns a string containng the defines string
  15569. */
  15570. getEffectDefines(): string;
  15571. /**
  15572. * Returns the string "SphereParticleEmitter"
  15573. * @returns a string containing the class name
  15574. */
  15575. getClassName(): string;
  15576. /**
  15577. * Serializes the particle system to a JSON object.
  15578. * @returns the JSON object
  15579. */
  15580. serialize(): any;
  15581. /**
  15582. * Parse properties from a JSON object
  15583. * @param serializationObject defines the JSON object
  15584. */
  15585. parse(serializationObject: any): void;
  15586. }
  15587. /**
  15588. * Particle emitter emitting particles from the inside of a sphere.
  15589. * It emits the particles randomly between two vectors.
  15590. */
  15591. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15592. /**
  15593. * The min limit of the emission direction.
  15594. */
  15595. direction1: Vector3;
  15596. /**
  15597. * The max limit of the emission direction.
  15598. */
  15599. direction2: Vector3;
  15600. /**
  15601. * Creates a new instance SphereDirectedParticleEmitter
  15602. * @param radius the radius of the emission sphere (1 by default)
  15603. * @param direction1 the min limit of the emission direction (up vector by default)
  15604. * @param direction2 the max limit of the emission direction (up vector by default)
  15605. */
  15606. constructor(radius?: number,
  15607. /**
  15608. * The min limit of the emission direction.
  15609. */
  15610. direction1?: Vector3,
  15611. /**
  15612. * The max limit of the emission direction.
  15613. */
  15614. direction2?: Vector3);
  15615. /**
  15616. * Called by the particle System when the direction is computed for the created particle.
  15617. * @param worldMatrix is the world matrix of the particle system
  15618. * @param directionToUpdate is the direction vector to update with the result
  15619. * @param particle is the particle we are computed the direction for
  15620. */
  15621. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15622. /**
  15623. * Clones the current emitter and returns a copy of it
  15624. * @returns the new emitter
  15625. */
  15626. clone(): SphereDirectedParticleEmitter;
  15627. /**
  15628. * Called by the GPUParticleSystem to setup the update shader
  15629. * @param effect defines the update shader
  15630. */
  15631. applyToShader(effect: Effect): void;
  15632. /**
  15633. * Returns a string to use to update the GPU particles update shader
  15634. * @returns a string containng the defines string
  15635. */
  15636. getEffectDefines(): string;
  15637. /**
  15638. * Returns the string "SphereDirectedParticleEmitter"
  15639. * @returns a string containing the class name
  15640. */
  15641. getClassName(): string;
  15642. /**
  15643. * Serializes the particle system to a JSON object.
  15644. * @returns the JSON object
  15645. */
  15646. serialize(): any;
  15647. /**
  15648. * Parse properties from a JSON object
  15649. * @param serializationObject defines the JSON object
  15650. */
  15651. parse(serializationObject: any): void;
  15652. }
  15653. }
  15654. declare module "babylonjs/Particles/EmitterTypes/index" {
  15655. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15656. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15657. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15658. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15659. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15660. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15661. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15662. }
  15663. declare module "babylonjs/Particles/IParticleSystem" {
  15664. import { Nullable } from "babylonjs/types";
  15665. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15668. import { Texture } from "babylonjs/Materials/Textures/texture";
  15669. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15670. import { Scene } from "babylonjs/scene";
  15671. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15672. import { Animation } from "babylonjs/Animations/animation";
  15673. /**
  15674. * Interface representing a particle system in Babylon.js.
  15675. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15676. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15677. */
  15678. export interface IParticleSystem {
  15679. /**
  15680. * List of animations used by the particle system.
  15681. */
  15682. animations: Animation[];
  15683. /**
  15684. * The id of the Particle system.
  15685. */
  15686. id: string;
  15687. /**
  15688. * The name of the Particle system.
  15689. */
  15690. name: string;
  15691. /**
  15692. * The emitter represents the Mesh or position we are attaching the particle system to.
  15693. */
  15694. emitter: Nullable<AbstractMesh | Vector3>;
  15695. /**
  15696. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15697. */
  15698. isBillboardBased: boolean;
  15699. /**
  15700. * The rendering group used by the Particle system to chose when to render.
  15701. */
  15702. renderingGroupId: number;
  15703. /**
  15704. * The layer mask we are rendering the particles through.
  15705. */
  15706. layerMask: number;
  15707. /**
  15708. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15709. */
  15710. updateSpeed: number;
  15711. /**
  15712. * The amount of time the particle system is running (depends of the overall update speed).
  15713. */
  15714. targetStopDuration: number;
  15715. /**
  15716. * The texture used to render each particle. (this can be a spritesheet)
  15717. */
  15718. particleTexture: Nullable<Texture>;
  15719. /**
  15720. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15721. */
  15722. blendMode: number;
  15723. /**
  15724. * Minimum life time of emitting particles.
  15725. */
  15726. minLifeTime: number;
  15727. /**
  15728. * Maximum life time of emitting particles.
  15729. */
  15730. maxLifeTime: number;
  15731. /**
  15732. * Minimum Size of emitting particles.
  15733. */
  15734. minSize: number;
  15735. /**
  15736. * Maximum Size of emitting particles.
  15737. */
  15738. maxSize: number;
  15739. /**
  15740. * Minimum scale of emitting particles on X axis.
  15741. */
  15742. minScaleX: number;
  15743. /**
  15744. * Maximum scale of emitting particles on X axis.
  15745. */
  15746. maxScaleX: number;
  15747. /**
  15748. * Minimum scale of emitting particles on Y axis.
  15749. */
  15750. minScaleY: number;
  15751. /**
  15752. * Maximum scale of emitting particles on Y axis.
  15753. */
  15754. maxScaleY: number;
  15755. /**
  15756. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15757. */
  15758. color1: Color4;
  15759. /**
  15760. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15761. */
  15762. color2: Color4;
  15763. /**
  15764. * Color the particle will have at the end of its lifetime.
  15765. */
  15766. colorDead: Color4;
  15767. /**
  15768. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15769. */
  15770. emitRate: number;
  15771. /**
  15772. * You can use gravity if you want to give an orientation to your particles.
  15773. */
  15774. gravity: Vector3;
  15775. /**
  15776. * Minimum power of emitting particles.
  15777. */
  15778. minEmitPower: number;
  15779. /**
  15780. * Maximum power of emitting particles.
  15781. */
  15782. maxEmitPower: number;
  15783. /**
  15784. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15785. */
  15786. minAngularSpeed: number;
  15787. /**
  15788. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15789. */
  15790. maxAngularSpeed: number;
  15791. /**
  15792. * Gets or sets the minimal initial rotation in radians.
  15793. */
  15794. minInitialRotation: number;
  15795. /**
  15796. * Gets or sets the maximal initial rotation in radians.
  15797. */
  15798. maxInitialRotation: number;
  15799. /**
  15800. * The particle emitter type defines the emitter used by the particle system.
  15801. * It can be for example box, sphere, or cone...
  15802. */
  15803. particleEmitterType: Nullable<IParticleEmitterType>;
  15804. /**
  15805. * Defines the delay in milliseconds before starting the system (0 by default)
  15806. */
  15807. startDelay: number;
  15808. /**
  15809. * 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
  15810. */
  15811. preWarmCycles: number;
  15812. /**
  15813. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15814. */
  15815. preWarmStepOffset: number;
  15816. /**
  15817. * 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)
  15818. */
  15819. spriteCellChangeSpeed: number;
  15820. /**
  15821. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15822. */
  15823. startSpriteCellID: number;
  15824. /**
  15825. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15826. */
  15827. endSpriteCellID: number;
  15828. /**
  15829. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15830. */
  15831. spriteCellWidth: number;
  15832. /**
  15833. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15834. */
  15835. spriteCellHeight: number;
  15836. /**
  15837. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15838. */
  15839. spriteRandomStartCell: boolean;
  15840. /**
  15841. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15842. */
  15843. isAnimationSheetEnabled: boolean;
  15844. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15845. translationPivot: Vector2;
  15846. /**
  15847. * Gets or sets a texture used to add random noise to particle positions
  15848. */
  15849. noiseTexture: Nullable<BaseTexture>;
  15850. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15851. noiseStrength: Vector3;
  15852. /**
  15853. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15854. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15855. */
  15856. billboardMode: number;
  15857. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15858. limitVelocityDamping: number;
  15859. /**
  15860. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15861. */
  15862. beginAnimationOnStart: boolean;
  15863. /**
  15864. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15865. */
  15866. beginAnimationFrom: number;
  15867. /**
  15868. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15869. */
  15870. beginAnimationTo: number;
  15871. /**
  15872. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15873. */
  15874. beginAnimationLoop: boolean;
  15875. /**
  15876. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15877. */
  15878. disposeOnStop: boolean;
  15879. /**
  15880. * Gets the maximum number of particles active at the same time.
  15881. * @returns The max number of active particles.
  15882. */
  15883. getCapacity(): number;
  15884. /**
  15885. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15886. * @returns True if it has been started, otherwise false.
  15887. */
  15888. isStarted(): boolean;
  15889. /**
  15890. * Animates the particle system for this frame.
  15891. */
  15892. animate(): void;
  15893. /**
  15894. * Renders the particle system in its current state.
  15895. * @returns the current number of particles
  15896. */
  15897. render(): number;
  15898. /**
  15899. * Dispose the particle system and frees its associated resources.
  15900. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15901. */
  15902. dispose(disposeTexture?: boolean): void;
  15903. /**
  15904. * Clones the particle system.
  15905. * @param name The name of the cloned object
  15906. * @param newEmitter The new emitter to use
  15907. * @returns the cloned particle system
  15908. */
  15909. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15910. /**
  15911. * Serializes the particle system to a JSON object.
  15912. * @returns the JSON object
  15913. */
  15914. serialize(): any;
  15915. /**
  15916. * Rebuild the particle system
  15917. */
  15918. rebuild(): void;
  15919. /**
  15920. * Starts the particle system and begins to emit
  15921. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15922. */
  15923. start(delay?: number): void;
  15924. /**
  15925. * Stops the particle system.
  15926. */
  15927. stop(): void;
  15928. /**
  15929. * Remove all active particles
  15930. */
  15931. reset(): void;
  15932. /**
  15933. * Is this system ready to be used/rendered
  15934. * @return true if the system is ready
  15935. */
  15936. isReady(): boolean;
  15937. /**
  15938. * Adds a new color gradient
  15939. * @param gradient defines the gradient to use (between 0 and 1)
  15940. * @param color1 defines the color to affect to the specified gradient
  15941. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15942. * @returns the current particle system
  15943. */
  15944. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15945. /**
  15946. * Remove a specific color gradient
  15947. * @param gradient defines the gradient to remove
  15948. * @returns the current particle system
  15949. */
  15950. removeColorGradient(gradient: number): IParticleSystem;
  15951. /**
  15952. * Adds a new size gradient
  15953. * @param gradient defines the gradient to use (between 0 and 1)
  15954. * @param factor defines the size factor to affect to the specified gradient
  15955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15956. * @returns the current particle system
  15957. */
  15958. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15959. /**
  15960. * Remove a specific size gradient
  15961. * @param gradient defines the gradient to remove
  15962. * @returns the current particle system
  15963. */
  15964. removeSizeGradient(gradient: number): IParticleSystem;
  15965. /**
  15966. * Gets the current list of color gradients.
  15967. * You must use addColorGradient and removeColorGradient to udpate this list
  15968. * @returns the list of color gradients
  15969. */
  15970. getColorGradients(): Nullable<Array<ColorGradient>>;
  15971. /**
  15972. * Gets the current list of size gradients.
  15973. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15974. * @returns the list of size gradients
  15975. */
  15976. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15977. /**
  15978. * Gets the current list of angular speed gradients.
  15979. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15980. * @returns the list of angular speed gradients
  15981. */
  15982. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15983. /**
  15984. * Adds a new angular speed gradient
  15985. * @param gradient defines the gradient to use (between 0 and 1)
  15986. * @param factor defines the angular speed to affect to the specified gradient
  15987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15988. * @returns the current particle system
  15989. */
  15990. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15991. /**
  15992. * Remove a specific angular speed gradient
  15993. * @param gradient defines the gradient to remove
  15994. * @returns the current particle system
  15995. */
  15996. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15997. /**
  15998. * Gets the current list of velocity gradients.
  15999. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16000. * @returns the list of velocity gradients
  16001. */
  16002. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16003. /**
  16004. * Adds a new velocity gradient
  16005. * @param gradient defines the gradient to use (between 0 and 1)
  16006. * @param factor defines the velocity to affect to the specified gradient
  16007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16008. * @returns the current particle system
  16009. */
  16010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16011. /**
  16012. * Remove a specific velocity gradient
  16013. * @param gradient defines the gradient to remove
  16014. * @returns the current particle system
  16015. */
  16016. removeVelocityGradient(gradient: number): IParticleSystem;
  16017. /**
  16018. * Gets the current list of limit velocity gradients.
  16019. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16020. * @returns the list of limit velocity gradients
  16021. */
  16022. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16023. /**
  16024. * Adds a new limit velocity gradient
  16025. * @param gradient defines the gradient to use (between 0 and 1)
  16026. * @param factor defines the limit velocity to affect to the specified gradient
  16027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16028. * @returns the current particle system
  16029. */
  16030. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16031. /**
  16032. * Remove a specific limit velocity gradient
  16033. * @param gradient defines the gradient to remove
  16034. * @returns the current particle system
  16035. */
  16036. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16037. /**
  16038. * Adds a new drag gradient
  16039. * @param gradient defines the gradient to use (between 0 and 1)
  16040. * @param factor defines the drag to affect to the specified gradient
  16041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16042. * @returns the current particle system
  16043. */
  16044. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16045. /**
  16046. * Remove a specific drag gradient
  16047. * @param gradient defines the gradient to remove
  16048. * @returns the current particle system
  16049. */
  16050. removeDragGradient(gradient: number): IParticleSystem;
  16051. /**
  16052. * Gets the current list of drag gradients.
  16053. * You must use addDragGradient and removeDragGradient to udpate this list
  16054. * @returns the list of drag gradients
  16055. */
  16056. getDragGradients(): Nullable<Array<FactorGradient>>;
  16057. /**
  16058. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16059. * @param gradient defines the gradient to use (between 0 and 1)
  16060. * @param factor defines the emit rate to affect to the specified gradient
  16061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16062. * @returns the current particle system
  16063. */
  16064. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16065. /**
  16066. * Remove a specific emit rate gradient
  16067. * @param gradient defines the gradient to remove
  16068. * @returns the current particle system
  16069. */
  16070. removeEmitRateGradient(gradient: number): IParticleSystem;
  16071. /**
  16072. * Gets the current list of emit rate gradients.
  16073. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16074. * @returns the list of emit rate gradients
  16075. */
  16076. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16077. /**
  16078. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16079. * @param gradient defines the gradient to use (between 0 and 1)
  16080. * @param factor defines the start size to affect to the specified gradient
  16081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16082. * @returns the current particle system
  16083. */
  16084. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16085. /**
  16086. * Remove a specific start size gradient
  16087. * @param gradient defines the gradient to remove
  16088. * @returns the current particle system
  16089. */
  16090. removeStartSizeGradient(gradient: number): IParticleSystem;
  16091. /**
  16092. * Gets the current list of start size gradients.
  16093. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16094. * @returns the list of start size gradients
  16095. */
  16096. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16097. /**
  16098. * Adds a new life time gradient
  16099. * @param gradient defines the gradient to use (between 0 and 1)
  16100. * @param factor defines the life time factor to affect to the specified gradient
  16101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16102. * @returns the current particle system
  16103. */
  16104. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16105. /**
  16106. * Remove a specific life time gradient
  16107. * @param gradient defines the gradient to remove
  16108. * @returns the current particle system
  16109. */
  16110. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16111. /**
  16112. * Gets the current list of life time gradients.
  16113. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16114. * @returns the list of life time gradients
  16115. */
  16116. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16117. /**
  16118. * Gets the current list of color gradients.
  16119. * You must use addColorGradient and removeColorGradient to udpate this list
  16120. * @returns the list of color gradients
  16121. */
  16122. getColorGradients(): Nullable<Array<ColorGradient>>;
  16123. /**
  16124. * Adds a new ramp gradient used to remap particle colors
  16125. * @param gradient defines the gradient to use (between 0 and 1)
  16126. * @param color defines the color to affect to the specified gradient
  16127. * @returns the current particle system
  16128. */
  16129. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16130. /**
  16131. * Gets the current list of ramp gradients.
  16132. * You must use addRampGradient and removeRampGradient to udpate this list
  16133. * @returns the list of ramp gradients
  16134. */
  16135. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16136. /** Gets or sets a boolean indicating that ramp gradients must be used
  16137. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16138. */
  16139. useRampGradients: boolean;
  16140. /**
  16141. * Adds a new color remap gradient
  16142. * @param gradient defines the gradient to use (between 0 and 1)
  16143. * @param min defines the color remap minimal range
  16144. * @param max defines the color remap maximal range
  16145. * @returns the current particle system
  16146. */
  16147. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16148. /**
  16149. * Gets the current list of color remap gradients.
  16150. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16151. * @returns the list of color remap gradients
  16152. */
  16153. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16154. /**
  16155. * Adds a new alpha remap gradient
  16156. * @param gradient defines the gradient to use (between 0 and 1)
  16157. * @param min defines the alpha remap minimal range
  16158. * @param max defines the alpha remap maximal range
  16159. * @returns the current particle system
  16160. */
  16161. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16162. /**
  16163. * Gets the current list of alpha remap gradients.
  16164. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16165. * @returns the list of alpha remap gradients
  16166. */
  16167. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16168. /**
  16169. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16170. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16171. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16172. * @returns the emitter
  16173. */
  16174. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16175. /**
  16176. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16177. * @param radius The radius of the hemisphere to emit from
  16178. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16179. * @returns the emitter
  16180. */
  16181. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16182. /**
  16183. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16184. * @param radius The radius of the sphere to emit from
  16185. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16186. * @returns the emitter
  16187. */
  16188. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16189. /**
  16190. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16191. * @param radius The radius of the sphere to emit from
  16192. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16193. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16194. * @returns the emitter
  16195. */
  16196. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16197. /**
  16198. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16199. * @param radius The radius of the emission cylinder
  16200. * @param height The height of the emission cylinder
  16201. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16202. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16203. * @returns the emitter
  16204. */
  16205. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16206. /**
  16207. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16208. * @param radius The radius of the cylinder to emit from
  16209. * @param height The height of the emission cylinder
  16210. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16213. * @returns the emitter
  16214. */
  16215. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16216. /**
  16217. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16218. * @param radius The radius of the cone to emit from
  16219. * @param angle The base angle of the cone
  16220. * @returns the emitter
  16221. */
  16222. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16223. /**
  16224. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16225. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16226. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16227. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16228. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16229. * @returns the emitter
  16230. */
  16231. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16232. /**
  16233. * Get hosting scene
  16234. * @returns the scene
  16235. */
  16236. getScene(): Scene;
  16237. }
  16238. }
  16239. declare module "babylonjs/Meshes/instancedMesh" {
  16240. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16241. import { Vector3 } from "babylonjs/Maths/math";
  16242. import { Camera } from "babylonjs/Cameras/camera";
  16243. import { Node } from "babylonjs/node";
  16244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16245. import { Mesh } from "babylonjs/Meshes/mesh";
  16246. import { Material } from "babylonjs/Materials/material";
  16247. import { Skeleton } from "babylonjs/Bones/skeleton";
  16248. /**
  16249. * Creates an instance based on a source mesh.
  16250. */
  16251. export class InstancedMesh extends AbstractMesh {
  16252. private _sourceMesh;
  16253. private _currentLOD;
  16254. /** @hidden */
  16255. _indexInSourceMeshInstanceArray: number;
  16256. constructor(name: string, source: Mesh);
  16257. /**
  16258. * Returns the string "InstancedMesh".
  16259. */
  16260. getClassName(): string;
  16261. /**
  16262. * If the source mesh receives shadows
  16263. */
  16264. readonly receiveShadows: boolean;
  16265. /**
  16266. * The material of the source mesh
  16267. */
  16268. readonly material: Nullable<Material>;
  16269. /**
  16270. * Visibility of the source mesh
  16271. */
  16272. readonly visibility: number;
  16273. /**
  16274. * Skeleton of the source mesh
  16275. */
  16276. readonly skeleton: Nullable<Skeleton>;
  16277. /**
  16278. * Rendering ground id of the source mesh
  16279. */
  16280. renderingGroupId: number;
  16281. /**
  16282. * Returns the total number of vertices (integer).
  16283. */
  16284. getTotalVertices(): number;
  16285. /**
  16286. * Returns a positive integer : the total number of indices in this mesh geometry.
  16287. * @returns the numner of indices or zero if the mesh has no geometry.
  16288. */
  16289. getTotalIndices(): number;
  16290. /**
  16291. * The source mesh of the instance
  16292. */
  16293. readonly sourceMesh: Mesh;
  16294. /**
  16295. * Is this node ready to be used/rendered
  16296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16297. * @return {boolean} is it ready
  16298. */
  16299. isReady(completeCheck?: boolean): boolean;
  16300. /**
  16301. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16302. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16303. * @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.
  16304. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16305. */
  16306. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16307. /**
  16308. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16309. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16310. * The `data` are either a numeric array either a Float32Array.
  16311. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16312. * 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).
  16313. * Note that a new underlying VertexBuffer object is created each call.
  16314. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16315. *
  16316. * Possible `kind` values :
  16317. * - VertexBuffer.PositionKind
  16318. * - VertexBuffer.UVKind
  16319. * - VertexBuffer.UV2Kind
  16320. * - VertexBuffer.UV3Kind
  16321. * - VertexBuffer.UV4Kind
  16322. * - VertexBuffer.UV5Kind
  16323. * - VertexBuffer.UV6Kind
  16324. * - VertexBuffer.ColorKind
  16325. * - VertexBuffer.MatricesIndicesKind
  16326. * - VertexBuffer.MatricesIndicesExtraKind
  16327. * - VertexBuffer.MatricesWeightsKind
  16328. * - VertexBuffer.MatricesWeightsExtraKind
  16329. *
  16330. * Returns the Mesh.
  16331. */
  16332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16333. /**
  16334. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16335. * If the mesh has no geometry, it is simply returned as it is.
  16336. * The `data` are either a numeric array either a Float32Array.
  16337. * No new underlying VertexBuffer object is created.
  16338. * 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.
  16339. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16340. *
  16341. * Possible `kind` values :
  16342. * - VertexBuffer.PositionKind
  16343. * - VertexBuffer.UVKind
  16344. * - VertexBuffer.UV2Kind
  16345. * - VertexBuffer.UV3Kind
  16346. * - VertexBuffer.UV4Kind
  16347. * - VertexBuffer.UV5Kind
  16348. * - VertexBuffer.UV6Kind
  16349. * - VertexBuffer.ColorKind
  16350. * - VertexBuffer.MatricesIndicesKind
  16351. * - VertexBuffer.MatricesIndicesExtraKind
  16352. * - VertexBuffer.MatricesWeightsKind
  16353. * - VertexBuffer.MatricesWeightsExtraKind
  16354. *
  16355. * Returns the Mesh.
  16356. */
  16357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16358. /**
  16359. * Sets the mesh indices.
  16360. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16361. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16362. * This method creates a new index buffer each call.
  16363. * Returns the Mesh.
  16364. */
  16365. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16366. /**
  16367. * Boolean : True if the mesh owns the requested kind of data.
  16368. */
  16369. isVerticesDataPresent(kind: string): boolean;
  16370. /**
  16371. * Returns an array of indices (IndicesArray).
  16372. */
  16373. getIndices(): Nullable<IndicesArray>;
  16374. readonly _positions: Nullable<Vector3[]>;
  16375. /**
  16376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16377. * This means the mesh underlying bounding box and sphere are recomputed.
  16378. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16379. * @returns the current mesh
  16380. */
  16381. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16382. /** @hidden */
  16383. _preActivate(): InstancedMesh;
  16384. /** @hidden */
  16385. _activate(renderId: number): InstancedMesh;
  16386. /**
  16387. * Returns the current associated LOD AbstractMesh.
  16388. */
  16389. getLOD(camera: Camera): AbstractMesh;
  16390. /** @hidden */
  16391. _syncSubMeshes(): InstancedMesh;
  16392. /** @hidden */
  16393. _generatePointsArray(): boolean;
  16394. /**
  16395. * Creates a new InstancedMesh from the current mesh.
  16396. * - name (string) : the cloned mesh name
  16397. * - newParent (optional Node) : the optional Node to parent the clone to.
  16398. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16399. *
  16400. * Returns the clone.
  16401. */
  16402. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16403. /**
  16404. * Disposes the InstancedMesh.
  16405. * Returns nothing.
  16406. */
  16407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16408. }
  16409. }
  16410. declare module "babylonjs/Materials/shaderMaterial" {
  16411. import { Scene } from "babylonjs/scene";
  16412. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16414. import { Mesh } from "babylonjs/Meshes/mesh";
  16415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16416. import { Texture } from "babylonjs/Materials/Textures/texture";
  16417. import { Material } from "babylonjs/Materials/material";
  16418. /**
  16419. * Defines the options associated with the creation of a shader material.
  16420. */
  16421. export interface IShaderMaterialOptions {
  16422. /**
  16423. * Does the material work in alpha blend mode
  16424. */
  16425. needAlphaBlending: boolean;
  16426. /**
  16427. * Does the material work in alpha test mode
  16428. */
  16429. needAlphaTesting: boolean;
  16430. /**
  16431. * The list of attribute names used in the shader
  16432. */
  16433. attributes: string[];
  16434. /**
  16435. * The list of unifrom names used in the shader
  16436. */
  16437. uniforms: string[];
  16438. /**
  16439. * The list of UBO names used in the shader
  16440. */
  16441. uniformBuffers: string[];
  16442. /**
  16443. * The list of sampler names used in the shader
  16444. */
  16445. samplers: string[];
  16446. /**
  16447. * The list of defines used in the shader
  16448. */
  16449. defines: string[];
  16450. }
  16451. /**
  16452. * 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.
  16453. *
  16454. * This returned material effects how the mesh will look based on the code in the shaders.
  16455. *
  16456. * @see http://doc.babylonjs.com/how_to/shader_material
  16457. */
  16458. export class ShaderMaterial extends Material {
  16459. private _shaderPath;
  16460. private _options;
  16461. private _textures;
  16462. private _textureArrays;
  16463. private _floats;
  16464. private _ints;
  16465. private _floatsArrays;
  16466. private _colors3;
  16467. private _colors3Arrays;
  16468. private _colors4;
  16469. private _vectors2;
  16470. private _vectors3;
  16471. private _vectors4;
  16472. private _matrices;
  16473. private _matrices3x3;
  16474. private _matrices2x2;
  16475. private _vectors2Arrays;
  16476. private _vectors3Arrays;
  16477. private _cachedWorldViewMatrix;
  16478. private _renderId;
  16479. /**
  16480. * Instantiate a new shader material.
  16481. * 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.
  16482. * This returned material effects how the mesh will look based on the code in the shaders.
  16483. * @see http://doc.babylonjs.com/how_to/shader_material
  16484. * @param name Define the name of the material in the scene
  16485. * @param scene Define the scene the material belongs to
  16486. * @param shaderPath Defines the route to the shader code in one of three ways:
  16487. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16488. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16489. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16490. * @param options Define the options used to create the shader
  16491. */
  16492. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16493. /**
  16494. * Gets the current class name of the material e.g. "ShaderMaterial"
  16495. * Mainly use in serialization.
  16496. * @returns the class name
  16497. */
  16498. getClassName(): string;
  16499. /**
  16500. * Specifies if the material will require alpha blending
  16501. * @returns a boolean specifying if alpha blending is needed
  16502. */
  16503. needAlphaBlending(): boolean;
  16504. /**
  16505. * Specifies if this material should be rendered in alpha test mode
  16506. * @returns a boolean specifying if an alpha test is needed.
  16507. */
  16508. needAlphaTesting(): boolean;
  16509. private _checkUniform;
  16510. /**
  16511. * Set a texture in the shader.
  16512. * @param name Define the name of the uniform samplers as defined in the shader
  16513. * @param texture Define the texture to bind to this sampler
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setTexture(name: string, texture: Texture): ShaderMaterial;
  16517. /**
  16518. * Set a texture array in the shader.
  16519. * @param name Define the name of the uniform sampler array as defined in the shader
  16520. * @param textures Define the list of textures to bind to this sampler
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16524. /**
  16525. * Set a float in the shader.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setFloat(name: string, value: number): ShaderMaterial;
  16531. /**
  16532. * Set a int in the shader.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the material itself allowing "fluent" like uniform updates
  16536. */
  16537. setInt(name: string, value: number): ShaderMaterial;
  16538. /**
  16539. * Set an array of floats in the shader.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the material itself allowing "fluent" like uniform updates
  16543. */
  16544. setFloats(name: string, value: number[]): ShaderMaterial;
  16545. /**
  16546. * Set a vec3 in the shader from a Color3.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the material itself allowing "fluent" like uniform updates
  16550. */
  16551. setColor3(name: string, value: Color3): ShaderMaterial;
  16552. /**
  16553. * Set a vec3 array in the shader from a Color3 array.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the material itself allowing "fluent" like uniform updates
  16557. */
  16558. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16559. /**
  16560. * Set a vec4 in the shader from a Color4.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the material itself allowing "fluent" like uniform updates
  16564. */
  16565. setColor4(name: string, value: Color4): ShaderMaterial;
  16566. /**
  16567. * Set a vec2 in the shader from a Vector2.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the material itself allowing "fluent" like uniform updates
  16571. */
  16572. setVector2(name: string, value: Vector2): ShaderMaterial;
  16573. /**
  16574. * Set a vec3 in the shader from a Vector3.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the material itself allowing "fluent" like uniform updates
  16578. */
  16579. setVector3(name: string, value: Vector3): ShaderMaterial;
  16580. /**
  16581. * Set a vec4 in the shader from a Vector4.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the material itself allowing "fluent" like uniform updates
  16585. */
  16586. setVector4(name: string, value: Vector4): ShaderMaterial;
  16587. /**
  16588. * Set a mat4 in the shader from a Matrix.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the material itself allowing "fluent" like uniform updates
  16592. */
  16593. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16594. /**
  16595. * Set a mat3 in the shader from a Float32Array.
  16596. * @param name Define the name of the uniform as defined in the shader
  16597. * @param value Define the value to give to the uniform
  16598. * @return the material itself allowing "fluent" like uniform updates
  16599. */
  16600. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16601. /**
  16602. * Set a mat2 in the shader from a Float32Array.
  16603. * @param name Define the name of the uniform as defined in the shader
  16604. * @param value Define the value to give to the uniform
  16605. * @return the material itself allowing "fluent" like uniform updates
  16606. */
  16607. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16608. /**
  16609. * Set a vec2 array in the shader from a number array.
  16610. * @param name Define the name of the uniform as defined in the shader
  16611. * @param value Define the value to give to the uniform
  16612. * @return the material itself allowing "fluent" like uniform updates
  16613. */
  16614. setArray2(name: string, value: number[]): ShaderMaterial;
  16615. /**
  16616. * Set a vec3 array in the shader from a number array.
  16617. * @param name Define the name of the uniform as defined in the shader
  16618. * @param value Define the value to give to the uniform
  16619. * @return the material itself allowing "fluent" like uniform updates
  16620. */
  16621. setArray3(name: string, value: number[]): ShaderMaterial;
  16622. private _checkCache;
  16623. /**
  16624. * Checks if the material is ready to render the requested mesh
  16625. * @param mesh Define the mesh to render
  16626. * @param useInstances Define whether or not the material is used with instances
  16627. * @returns true if ready, otherwise false
  16628. */
  16629. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16630. /**
  16631. * Binds the world matrix to the material
  16632. * @param world defines the world transformation matrix
  16633. */
  16634. bindOnlyWorldMatrix(world: Matrix): void;
  16635. /**
  16636. * Binds the material to the mesh
  16637. * @param world defines the world transformation matrix
  16638. * @param mesh defines the mesh to bind the material to
  16639. */
  16640. bind(world: Matrix, mesh?: Mesh): void;
  16641. /**
  16642. * Gets the active textures from the material
  16643. * @returns an array of textures
  16644. */
  16645. getActiveTextures(): BaseTexture[];
  16646. /**
  16647. * Specifies if the material uses a texture
  16648. * @param texture defines the texture to check against the material
  16649. * @returns a boolean specifying if the material uses the texture
  16650. */
  16651. hasTexture(texture: BaseTexture): boolean;
  16652. /**
  16653. * Makes a duplicate of the material, and gives it a new name
  16654. * @param name defines the new name for the duplicated material
  16655. * @returns the cloned material
  16656. */
  16657. clone(name: string): ShaderMaterial;
  16658. /**
  16659. * Disposes the material
  16660. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16661. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16662. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16663. */
  16664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16665. /**
  16666. * Serializes this material in a JSON representation
  16667. * @returns the serialized material object
  16668. */
  16669. serialize(): any;
  16670. /**
  16671. * Creates a shader material from parsed shader material data
  16672. * @param source defines the JSON represnetation of the material
  16673. * @param scene defines the hosting scene
  16674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16675. * @returns a new material
  16676. */
  16677. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16678. }
  16679. }
  16680. declare module "babylonjs/Shaders/color.fragment" {
  16681. /** @hidden */
  16682. export var colorPixelShader: {
  16683. name: string;
  16684. shader: string;
  16685. };
  16686. }
  16687. declare module "babylonjs/Shaders/color.vertex" {
  16688. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16690. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16691. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16692. /** @hidden */
  16693. export var colorVertexShader: {
  16694. name: string;
  16695. shader: string;
  16696. };
  16697. }
  16698. declare module "babylonjs/Meshes/linesMesh" {
  16699. import { Nullable } from "babylonjs/types";
  16700. import { Scene } from "babylonjs/scene";
  16701. import { Color3 } from "babylonjs/Maths/math";
  16702. import { Node } from "babylonjs/node";
  16703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16704. import { Mesh } from "babylonjs/Meshes/mesh";
  16705. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16706. import { Effect } from "babylonjs/Materials/effect";
  16707. import { Material } from "babylonjs/Materials/material";
  16708. import "babylonjs/Shaders/color.fragment";
  16709. import "babylonjs/Shaders/color.vertex";
  16710. /**
  16711. * Line mesh
  16712. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16713. */
  16714. export class LinesMesh extends Mesh {
  16715. /**
  16716. * If vertex color should be applied to the mesh
  16717. */
  16718. useVertexColor?: boolean | undefined;
  16719. /**
  16720. * If vertex alpha should be applied to the mesh
  16721. */
  16722. useVertexAlpha?: boolean | undefined;
  16723. /**
  16724. * Color of the line (Default: White)
  16725. */
  16726. color: Color3;
  16727. /**
  16728. * Alpha of the line (Default: 1)
  16729. */
  16730. alpha: number;
  16731. /**
  16732. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16733. * This margin is expressed in world space coordinates, so its value may vary.
  16734. * Default value is 0.1
  16735. */
  16736. intersectionThreshold: number;
  16737. private _colorShader;
  16738. /**
  16739. * Creates a new LinesMesh
  16740. * @param name defines the name
  16741. * @param scene defines the hosting scene
  16742. * @param parent defines the parent mesh if any
  16743. * @param source defines the optional source LinesMesh used to clone data from
  16744. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16745. * When false, achieved by calling a clone(), also passing False.
  16746. * This will make creation of children, recursive.
  16747. * @param useVertexColor defines if this LinesMesh supports vertex color
  16748. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16749. */
  16750. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16751. /**
  16752. * If vertex color should be applied to the mesh
  16753. */
  16754. useVertexColor?: boolean | undefined,
  16755. /**
  16756. * If vertex alpha should be applied to the mesh
  16757. */
  16758. useVertexAlpha?: boolean | undefined);
  16759. /**
  16760. * Returns the string "LineMesh"
  16761. */
  16762. getClassName(): string;
  16763. /**
  16764. * @hidden
  16765. */
  16766. /**
  16767. * @hidden
  16768. */
  16769. material: Material;
  16770. /**
  16771. * @hidden
  16772. */
  16773. readonly checkCollisions: boolean;
  16774. /** @hidden */
  16775. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16776. /** @hidden */
  16777. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16778. /**
  16779. * Disposes of the line mesh
  16780. * @param doNotRecurse If children should be disposed
  16781. */
  16782. dispose(doNotRecurse?: boolean): void;
  16783. /**
  16784. * Returns a new LineMesh object cloned from the current one.
  16785. */
  16786. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16787. /**
  16788. * Creates a new InstancedLinesMesh object from the mesh model.
  16789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16790. * @param name defines the name of the new instance
  16791. * @returns a new InstancedLinesMesh
  16792. */
  16793. createInstance(name: string): InstancedLinesMesh;
  16794. }
  16795. /**
  16796. * Creates an instance based on a source LinesMesh
  16797. */
  16798. export class InstancedLinesMesh extends InstancedMesh {
  16799. /**
  16800. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16801. * This margin is expressed in world space coordinates, so its value may vary.
  16802. * Initilized with the intersectionThreshold value of the source LinesMesh
  16803. */
  16804. intersectionThreshold: number;
  16805. constructor(name: string, source: LinesMesh);
  16806. /**
  16807. * Returns the string "InstancedLinesMesh".
  16808. */
  16809. getClassName(): string;
  16810. }
  16811. }
  16812. declare module "babylonjs/Shaders/line.fragment" {
  16813. /** @hidden */
  16814. export var linePixelShader: {
  16815. name: string;
  16816. shader: string;
  16817. };
  16818. }
  16819. declare module "babylonjs/Shaders/line.vertex" {
  16820. /** @hidden */
  16821. export var lineVertexShader: {
  16822. name: string;
  16823. shader: string;
  16824. };
  16825. }
  16826. declare module "babylonjs/Rendering/edgesRenderer" {
  16827. import { Nullable } from "babylonjs/types";
  16828. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16830. import { Vector3 } from "babylonjs/Maths/math";
  16831. import { IDisposable } from "babylonjs/scene";
  16832. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16833. import "babylonjs/Shaders/line.fragment";
  16834. import "babylonjs/Shaders/line.vertex";
  16835. module "babylonjs/Meshes/abstractMesh" {
  16836. interface AbstractMesh {
  16837. /**
  16838. * Disables the mesh edge rendering mode
  16839. * @returns the currentAbstractMesh
  16840. */
  16841. disableEdgesRendering(): AbstractMesh;
  16842. /**
  16843. * Enables the edge rendering mode on the mesh.
  16844. * This mode makes the mesh edges visible
  16845. * @param epsilon defines the maximal distance between two angles to detect a face
  16846. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16847. * @returns the currentAbstractMesh
  16848. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16849. */
  16850. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16851. /**
  16852. * Gets the edgesRenderer associated with the mesh
  16853. */
  16854. edgesRenderer: Nullable<EdgesRenderer>;
  16855. }
  16856. }
  16857. module "babylonjs/Meshes/linesMesh" {
  16858. interface LinesMesh {
  16859. /**
  16860. * Enables the edge rendering mode on the mesh.
  16861. * This mode makes the mesh edges visible
  16862. * @param epsilon defines the maximal distance between two angles to detect a face
  16863. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16864. * @returns the currentAbstractMesh
  16865. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16866. */
  16867. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16868. }
  16869. }
  16870. module "babylonjs/Meshes/linesMesh" {
  16871. interface InstancedLinesMesh {
  16872. /**
  16873. * Enables the edge rendering mode on the mesh.
  16874. * This mode makes the mesh edges visible
  16875. * @param epsilon defines the maximal distance between two angles to detect a face
  16876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16877. * @returns the current InstancedLinesMesh
  16878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16879. */
  16880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16881. }
  16882. }
  16883. /**
  16884. * Defines the minimum contract an Edges renderer should follow.
  16885. */
  16886. export interface IEdgesRenderer extends IDisposable {
  16887. /**
  16888. * Gets or sets a boolean indicating if the edgesRenderer is active
  16889. */
  16890. isEnabled: boolean;
  16891. /**
  16892. * Renders the edges of the attached mesh,
  16893. */
  16894. render(): void;
  16895. /**
  16896. * Checks wether or not the edges renderer is ready to render.
  16897. * @return true if ready, otherwise false.
  16898. */
  16899. isReady(): boolean;
  16900. }
  16901. /**
  16902. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16903. */
  16904. export class EdgesRenderer implements IEdgesRenderer {
  16905. /**
  16906. * Define the size of the edges with an orthographic camera
  16907. */
  16908. edgesWidthScalerForOrthographic: number;
  16909. /**
  16910. * Define the size of the edges with a perspective camera
  16911. */
  16912. edgesWidthScalerForPerspective: number;
  16913. protected _source: AbstractMesh;
  16914. protected _linesPositions: number[];
  16915. protected _linesNormals: number[];
  16916. protected _linesIndices: number[];
  16917. protected _epsilon: number;
  16918. protected _indicesCount: number;
  16919. protected _lineShader: ShaderMaterial;
  16920. protected _ib: WebGLBuffer;
  16921. protected _buffers: {
  16922. [key: string]: Nullable<VertexBuffer>;
  16923. };
  16924. protected _checkVerticesInsteadOfIndices: boolean;
  16925. private _meshRebuildObserver;
  16926. private _meshDisposeObserver;
  16927. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16928. isEnabled: boolean;
  16929. /**
  16930. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16931. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16932. * @param source Mesh used to create edges
  16933. * @param epsilon sum of angles in adjacency to check for edge
  16934. * @param checkVerticesInsteadOfIndices
  16935. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16936. */
  16937. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16938. protected _prepareRessources(): void;
  16939. /** @hidden */
  16940. _rebuild(): void;
  16941. /**
  16942. * Releases the required resources for the edges renderer
  16943. */
  16944. dispose(): void;
  16945. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16946. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16947. /**
  16948. * Checks if the pair of p0 and p1 is en edge
  16949. * @param faceIndex
  16950. * @param edge
  16951. * @param faceNormals
  16952. * @param p0
  16953. * @param p1
  16954. * @private
  16955. */
  16956. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16957. /**
  16958. * push line into the position, normal and index buffer
  16959. * @protected
  16960. */
  16961. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16962. /**
  16963. * Generates lines edges from adjacencjes
  16964. * @private
  16965. */
  16966. _generateEdgesLines(): void;
  16967. /**
  16968. * Checks wether or not the edges renderer is ready to render.
  16969. * @return true if ready, otherwise false.
  16970. */
  16971. isReady(): boolean;
  16972. /**
  16973. * Renders the edges of the attached mesh,
  16974. */
  16975. render(): void;
  16976. }
  16977. /**
  16978. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16979. */
  16980. export class LineEdgesRenderer extends EdgesRenderer {
  16981. /**
  16982. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16983. * @param source LineMesh used to generate edges
  16984. * @param epsilon not important (specified angle for edge detection)
  16985. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16986. */
  16987. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16988. /**
  16989. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16990. */
  16991. _generateEdgesLines(): void;
  16992. }
  16993. }
  16994. declare module "babylonjs/Rendering/renderingGroup" {
  16995. import { SmartArray } from "babylonjs/Misc/smartArray";
  16996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16998. import { Nullable } from "babylonjs/types";
  16999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17000. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17001. import { Material } from "babylonjs/Materials/material";
  17002. import { Scene } from "babylonjs/scene";
  17003. /**
  17004. * This represents the object necessary to create a rendering group.
  17005. * This is exclusively used and created by the rendering manager.
  17006. * To modify the behavior, you use the available helpers in your scene or meshes.
  17007. * @hidden
  17008. */
  17009. export class RenderingGroup {
  17010. index: number;
  17011. private _scene;
  17012. private _opaqueSubMeshes;
  17013. private _transparentSubMeshes;
  17014. private _alphaTestSubMeshes;
  17015. private _depthOnlySubMeshes;
  17016. private _particleSystems;
  17017. private _spriteManagers;
  17018. private _opaqueSortCompareFn;
  17019. private _alphaTestSortCompareFn;
  17020. private _transparentSortCompareFn;
  17021. private _renderOpaque;
  17022. private _renderAlphaTest;
  17023. private _renderTransparent;
  17024. private _edgesRenderers;
  17025. onBeforeTransparentRendering: () => void;
  17026. /**
  17027. * Set the opaque sort comparison function.
  17028. * If null the sub meshes will be render in the order they were created
  17029. */
  17030. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17031. /**
  17032. * Set the alpha test sort comparison function.
  17033. * If null the sub meshes will be render in the order they were created
  17034. */
  17035. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17036. /**
  17037. * Set the transparent sort comparison function.
  17038. * If null the sub meshes will be render in the order they were created
  17039. */
  17040. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17041. /**
  17042. * Creates a new rendering group.
  17043. * @param index The rendering group index
  17044. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17045. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17046. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17047. */
  17048. 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>);
  17049. /**
  17050. * Render all the sub meshes contained in the group.
  17051. * @param customRenderFunction Used to override the default render behaviour of the group.
  17052. * @returns true if rendered some submeshes.
  17053. */
  17054. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17055. /**
  17056. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17057. * @param subMeshes The submeshes to render
  17058. */
  17059. private renderOpaqueSorted;
  17060. /**
  17061. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17062. * @param subMeshes The submeshes to render
  17063. */
  17064. private renderAlphaTestSorted;
  17065. /**
  17066. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17067. * @param subMeshes The submeshes to render
  17068. */
  17069. private renderTransparentSorted;
  17070. /**
  17071. * Renders the submeshes in a specified order.
  17072. * @param subMeshes The submeshes to sort before render
  17073. * @param sortCompareFn The comparison function use to sort
  17074. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17075. * @param transparent Specifies to activate blending if true
  17076. */
  17077. private static renderSorted;
  17078. /**
  17079. * Renders the submeshes in the order they were dispatched (no sort applied).
  17080. * @param subMeshes The submeshes to render
  17081. */
  17082. private static renderUnsorted;
  17083. /**
  17084. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17085. * are rendered back to front if in the same alpha index.
  17086. *
  17087. * @param a The first submesh
  17088. * @param b The second submesh
  17089. * @returns The result of the comparison
  17090. */
  17091. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17092. /**
  17093. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17094. * are rendered back to front.
  17095. *
  17096. * @param a The first submesh
  17097. * @param b The second submesh
  17098. * @returns The result of the comparison
  17099. */
  17100. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17101. /**
  17102. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17103. * are rendered front to back (prevent overdraw).
  17104. *
  17105. * @param a The first submesh
  17106. * @param b The second submesh
  17107. * @returns The result of the comparison
  17108. */
  17109. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17110. /**
  17111. * Resets the different lists of submeshes to prepare a new frame.
  17112. */
  17113. prepare(): void;
  17114. dispose(): void;
  17115. /**
  17116. * Inserts the submesh in its correct queue depending on its material.
  17117. * @param subMesh The submesh to dispatch
  17118. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17119. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17120. */
  17121. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17122. dispatchSprites(spriteManager: ISpriteManager): void;
  17123. dispatchParticles(particleSystem: IParticleSystem): void;
  17124. private _renderParticles;
  17125. private _renderSprites;
  17126. }
  17127. }
  17128. declare module "babylonjs/Rendering/renderingManager" {
  17129. import { Nullable } from "babylonjs/types";
  17130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17131. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17132. import { SmartArray } from "babylonjs/Misc/smartArray";
  17133. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17134. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17135. import { Material } from "babylonjs/Materials/material";
  17136. import { Scene } from "babylonjs/scene";
  17137. import { Camera } from "babylonjs/Cameras/camera";
  17138. /**
  17139. * Interface describing the different options available in the rendering manager
  17140. * regarding Auto Clear between groups.
  17141. */
  17142. export interface IRenderingManagerAutoClearSetup {
  17143. /**
  17144. * Defines whether or not autoclear is enable.
  17145. */
  17146. autoClear: boolean;
  17147. /**
  17148. * Defines whether or not to autoclear the depth buffer.
  17149. */
  17150. depth: boolean;
  17151. /**
  17152. * Defines whether or not to autoclear the stencil buffer.
  17153. */
  17154. stencil: boolean;
  17155. }
  17156. /**
  17157. * This class is used by the onRenderingGroupObservable
  17158. */
  17159. export class RenderingGroupInfo {
  17160. /**
  17161. * The Scene that being rendered
  17162. */
  17163. scene: Scene;
  17164. /**
  17165. * The camera currently used for the rendering pass
  17166. */
  17167. camera: Nullable<Camera>;
  17168. /**
  17169. * The ID of the renderingGroup being processed
  17170. */
  17171. renderingGroupId: number;
  17172. }
  17173. /**
  17174. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17175. * It is enable to manage the different groups as well as the different necessary sort functions.
  17176. * This should not be used directly aside of the few static configurations
  17177. */
  17178. export class RenderingManager {
  17179. /**
  17180. * The max id used for rendering groups (not included)
  17181. */
  17182. static MAX_RENDERINGGROUPS: number;
  17183. /**
  17184. * The min id used for rendering groups (included)
  17185. */
  17186. static MIN_RENDERINGGROUPS: number;
  17187. /**
  17188. * Used to globally prevent autoclearing scenes.
  17189. */
  17190. static AUTOCLEAR: boolean;
  17191. /**
  17192. * @hidden
  17193. */
  17194. _useSceneAutoClearSetup: boolean;
  17195. private _scene;
  17196. private _renderingGroups;
  17197. private _depthStencilBufferAlreadyCleaned;
  17198. private _autoClearDepthStencil;
  17199. private _customOpaqueSortCompareFn;
  17200. private _customAlphaTestSortCompareFn;
  17201. private _customTransparentSortCompareFn;
  17202. private _renderingGroupInfo;
  17203. /**
  17204. * Instantiates a new rendering group for a particular scene
  17205. * @param scene Defines the scene the groups belongs to
  17206. */
  17207. constructor(scene: Scene);
  17208. private _clearDepthStencilBuffer;
  17209. /**
  17210. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17211. * @hidden
  17212. */
  17213. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17214. /**
  17215. * Resets the different information of the group to prepare a new frame
  17216. * @hidden
  17217. */
  17218. reset(): void;
  17219. /**
  17220. * Dispose and release the group and its associated resources.
  17221. * @hidden
  17222. */
  17223. dispose(): void;
  17224. /**
  17225. * Clear the info related to rendering groups preventing retention points during dispose.
  17226. */
  17227. freeRenderingGroups(): void;
  17228. private _prepareRenderingGroup;
  17229. /**
  17230. * Add a sprite manager to the rendering manager in order to render it this frame.
  17231. * @param spriteManager Define the sprite manager to render
  17232. */
  17233. dispatchSprites(spriteManager: ISpriteManager): void;
  17234. /**
  17235. * Add a particle system to the rendering manager in order to render it this frame.
  17236. * @param particleSystem Define the particle system to render
  17237. */
  17238. dispatchParticles(particleSystem: IParticleSystem): void;
  17239. /**
  17240. * Add a submesh to the manager in order to render it this frame
  17241. * @param subMesh The submesh to dispatch
  17242. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17243. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17244. */
  17245. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17246. /**
  17247. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17248. * This allowed control for front to back rendering or reversly depending of the special needs.
  17249. *
  17250. * @param renderingGroupId The rendering group id corresponding to its index
  17251. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17252. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17253. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17254. */
  17255. 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;
  17256. /**
  17257. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17258. *
  17259. * @param renderingGroupId The rendering group id corresponding to its index
  17260. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17261. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17262. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17263. */
  17264. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17265. /**
  17266. * Gets the current auto clear configuration for one rendering group of the rendering
  17267. * manager.
  17268. * @param index the rendering group index to get the information for
  17269. * @returns The auto clear setup for the requested rendering group
  17270. */
  17271. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17272. }
  17273. }
  17274. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17275. import { Observable } from "babylonjs/Misc/observable";
  17276. import { SmartArray } from "babylonjs/Misc/smartArray";
  17277. import { Nullable } from "babylonjs/types";
  17278. import { Camera } from "babylonjs/Cameras/camera";
  17279. import { Scene } from "babylonjs/scene";
  17280. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17281. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17285. import { Texture } from "babylonjs/Materials/Textures/texture";
  17286. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17287. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17288. import { Engine } from "babylonjs/Engines/engine";
  17289. /**
  17290. * This Helps creating a texture that will be created from a camera in your scene.
  17291. * It is basically a dynamic texture that could be used to create special effects for instance.
  17292. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17293. */
  17294. export class RenderTargetTexture extends Texture {
  17295. isCube: boolean;
  17296. /**
  17297. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17298. */
  17299. static readonly REFRESHRATE_RENDER_ONCE: number;
  17300. /**
  17301. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17302. */
  17303. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17304. /**
  17305. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17306. * the central point of your effect and can save a lot of performances.
  17307. */
  17308. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17309. /**
  17310. * Use this predicate to dynamically define the list of mesh you want to render.
  17311. * If set, the renderList property will be overwritten.
  17312. */
  17313. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17314. private _renderList;
  17315. /**
  17316. * Use this list to define the list of mesh you want to render.
  17317. */
  17318. renderList: Nullable<Array<AbstractMesh>>;
  17319. private _hookArray;
  17320. /**
  17321. * Define if particles should be rendered in your texture.
  17322. */
  17323. renderParticles: boolean;
  17324. /**
  17325. * Define if sprites should be rendered in your texture.
  17326. */
  17327. renderSprites: boolean;
  17328. /**
  17329. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17330. */
  17331. coordinatesMode: number;
  17332. /**
  17333. * Define the camera used to render the texture.
  17334. */
  17335. activeCamera: Nullable<Camera>;
  17336. /**
  17337. * Override the render function of the texture with your own one.
  17338. */
  17339. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17340. /**
  17341. * Define if camera post processes should be use while rendering the texture.
  17342. */
  17343. useCameraPostProcesses: boolean;
  17344. /**
  17345. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17346. */
  17347. ignoreCameraViewport: boolean;
  17348. private _postProcessManager;
  17349. private _postProcesses;
  17350. private _resizeObserver;
  17351. /**
  17352. * An event triggered when the texture is unbind.
  17353. */
  17354. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17355. /**
  17356. * An event triggered when the texture is unbind.
  17357. */
  17358. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17359. private _onAfterUnbindObserver;
  17360. /**
  17361. * Set a after unbind callback in the texture.
  17362. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17363. */
  17364. onAfterUnbind: () => void;
  17365. /**
  17366. * An event triggered before rendering the texture
  17367. */
  17368. onBeforeRenderObservable: Observable<number>;
  17369. private _onBeforeRenderObserver;
  17370. /**
  17371. * Set a before render callback in the texture.
  17372. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17373. */
  17374. onBeforeRender: (faceIndex: number) => void;
  17375. /**
  17376. * An event triggered after rendering the texture
  17377. */
  17378. onAfterRenderObservable: Observable<number>;
  17379. private _onAfterRenderObserver;
  17380. /**
  17381. * Set a after render callback in the texture.
  17382. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17383. */
  17384. onAfterRender: (faceIndex: number) => void;
  17385. /**
  17386. * An event triggered after the texture clear
  17387. */
  17388. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17389. private _onClearObserver;
  17390. /**
  17391. * Set a clear callback in the texture.
  17392. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17393. */
  17394. onClear: (Engine: Engine) => void;
  17395. /**
  17396. * Define the clear color of the Render Target if it should be different from the scene.
  17397. */
  17398. clearColor: Color4;
  17399. protected _size: number | {
  17400. width: number;
  17401. height: number;
  17402. };
  17403. protected _initialSizeParameter: number | {
  17404. width: number;
  17405. height: number;
  17406. } | {
  17407. ratio: number;
  17408. };
  17409. protected _sizeRatio: Nullable<number>;
  17410. /** @hidden */
  17411. _generateMipMaps: boolean;
  17412. protected _renderingManager: RenderingManager;
  17413. /** @hidden */
  17414. _waitingRenderList: string[];
  17415. protected _doNotChangeAspectRatio: boolean;
  17416. protected _currentRefreshId: number;
  17417. protected _refreshRate: number;
  17418. protected _textureMatrix: Matrix;
  17419. protected _samples: number;
  17420. protected _renderTargetOptions: RenderTargetCreationOptions;
  17421. /**
  17422. * Gets render target creation options that were used.
  17423. */
  17424. readonly renderTargetOptions: RenderTargetCreationOptions;
  17425. protected _engine: Engine;
  17426. protected _onRatioRescale(): void;
  17427. /**
  17428. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17429. * It must define where the camera used to render the texture is set
  17430. */
  17431. boundingBoxPosition: Vector3;
  17432. private _boundingBoxSize;
  17433. /**
  17434. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17435. * When defined, the cubemap will switch to local mode
  17436. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17437. * @example https://www.babylonjs-playground.com/#RNASML
  17438. */
  17439. boundingBoxSize: Vector3;
  17440. /**
  17441. * In case the RTT has been created with a depth texture, get the associated
  17442. * depth texture.
  17443. * Otherwise, return null.
  17444. */
  17445. depthStencilTexture: Nullable<InternalTexture>;
  17446. /**
  17447. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17448. * or used a shadow, depth texture...
  17449. * @param name The friendly name of the texture
  17450. * @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)
  17451. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17452. * @param generateMipMaps True if mip maps need to be generated after render.
  17453. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17454. * @param type The type of the buffer in the RTT (int, half float, float...)
  17455. * @param isCube True if a cube texture needs to be created
  17456. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17457. * @param generateDepthBuffer True to generate a depth buffer
  17458. * @param generateStencilBuffer True to generate a stencil buffer
  17459. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17460. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17461. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17462. */
  17463. constructor(name: string, size: number | {
  17464. width: number;
  17465. height: number;
  17466. } | {
  17467. ratio: number;
  17468. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17469. /**
  17470. * Creates a depth stencil texture.
  17471. * This is only available in WebGL 2 or with the depth texture extension available.
  17472. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17473. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17474. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17475. */
  17476. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17477. private _processSizeParameter;
  17478. /**
  17479. * Define the number of samples to use in case of MSAA.
  17480. * It defaults to one meaning no MSAA has been enabled.
  17481. */
  17482. samples: number;
  17483. /**
  17484. * Resets the refresh counter of the texture and start bak from scratch.
  17485. * Could be useful to regenerate the texture if it is setup to render only once.
  17486. */
  17487. resetRefreshCounter(): void;
  17488. /**
  17489. * Define the refresh rate of the texture or the rendering frequency.
  17490. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17491. */
  17492. refreshRate: number;
  17493. /**
  17494. * Adds a post process to the render target rendering passes.
  17495. * @param postProcess define the post process to add
  17496. */
  17497. addPostProcess(postProcess: PostProcess): void;
  17498. /**
  17499. * Clear all the post processes attached to the render target
  17500. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17501. */
  17502. clearPostProcesses(dispose?: boolean): void;
  17503. /**
  17504. * Remove one of the post process from the list of attached post processes to the texture
  17505. * @param postProcess define the post process to remove from the list
  17506. */
  17507. removePostProcess(postProcess: PostProcess): void;
  17508. /** @hidden */
  17509. _shouldRender(): boolean;
  17510. /**
  17511. * Gets the actual render size of the texture.
  17512. * @returns the width of the render size
  17513. */
  17514. getRenderSize(): number;
  17515. /**
  17516. * Gets the actual render width of the texture.
  17517. * @returns the width of the render size
  17518. */
  17519. getRenderWidth(): number;
  17520. /**
  17521. * Gets the actual render height of the texture.
  17522. * @returns the height of the render size
  17523. */
  17524. getRenderHeight(): number;
  17525. /**
  17526. * Get if the texture can be rescaled or not.
  17527. */
  17528. readonly canRescale: boolean;
  17529. /**
  17530. * Resize the texture using a ratio.
  17531. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17532. */
  17533. scale(ratio: number): void;
  17534. /**
  17535. * Get the texture reflection matrix used to rotate/transform the reflection.
  17536. * @returns the reflection matrix
  17537. */
  17538. getReflectionTextureMatrix(): Matrix;
  17539. /**
  17540. * Resize the texture to a new desired size.
  17541. * Be carrefull as it will recreate all the data in the new texture.
  17542. * @param size Define the new size. It can be:
  17543. * - a number for squared texture,
  17544. * - an object containing { width: number, height: number }
  17545. * - or an object containing a ratio { ratio: number }
  17546. */
  17547. resize(size: number | {
  17548. width: number;
  17549. height: number;
  17550. } | {
  17551. ratio: number;
  17552. }): void;
  17553. /**
  17554. * Renders all the objects from the render list into the texture.
  17555. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17556. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17557. */
  17558. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17559. private _bestReflectionRenderTargetDimension;
  17560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17561. private renderToTarget;
  17562. /**
  17563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17564. * This allowed control for front to back rendering or reversly depending of the special needs.
  17565. *
  17566. * @param renderingGroupId The rendering group id corresponding to its index
  17567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17570. */
  17571. 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;
  17572. /**
  17573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17574. *
  17575. * @param renderingGroupId The rendering group id corresponding to its index
  17576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17577. */
  17578. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17579. /**
  17580. * Clones the texture.
  17581. * @returns the cloned texture
  17582. */
  17583. clone(): RenderTargetTexture;
  17584. /**
  17585. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17586. * @returns The JSON representation of the texture
  17587. */
  17588. serialize(): any;
  17589. /**
  17590. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17591. */
  17592. disposeFramebufferObjects(): void;
  17593. /**
  17594. * Dispose the texture and release its associated resources.
  17595. */
  17596. dispose(): void;
  17597. /** @hidden */
  17598. _rebuild(): void;
  17599. /**
  17600. * Clear the info related to rendering groups preventing retention point in material dispose.
  17601. */
  17602. freeRenderingGroups(): void;
  17603. }
  17604. }
  17605. declare module "babylonjs/Materials/material" {
  17606. import { IAnimatable } from "babylonjs/Misc/tools";
  17607. import { SmartArray } from "babylonjs/Misc/smartArray";
  17608. import { Observable } from "babylonjs/Misc/observable";
  17609. import { Nullable } from "babylonjs/types";
  17610. import { Scene } from "babylonjs/scene";
  17611. import { Matrix } from "babylonjs/Maths/math";
  17612. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  17613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17614. import { Mesh } from "babylonjs/Meshes/mesh";
  17615. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17616. import { Effect } from "babylonjs/Materials/effect";
  17617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17619. import { Animation } from "babylonjs/Animations/animation";
  17620. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17621. /**
  17622. * Base class for the main features of a material in Babylon.js
  17623. */
  17624. export class Material implements IAnimatable {
  17625. /**
  17626. * Returns the triangle fill mode
  17627. */
  17628. static readonly TriangleFillMode: number;
  17629. /**
  17630. * Returns the wireframe mode
  17631. */
  17632. static readonly WireFrameFillMode: number;
  17633. /**
  17634. * Returns the point fill mode
  17635. */
  17636. static readonly PointFillMode: number;
  17637. /**
  17638. * Returns the point list draw mode
  17639. */
  17640. static readonly PointListDrawMode: number;
  17641. /**
  17642. * Returns the line list draw mode
  17643. */
  17644. static readonly LineListDrawMode: number;
  17645. /**
  17646. * Returns the line loop draw mode
  17647. */
  17648. static readonly LineLoopDrawMode: number;
  17649. /**
  17650. * Returns the line strip draw mode
  17651. */
  17652. static readonly LineStripDrawMode: number;
  17653. /**
  17654. * Returns the triangle strip draw mode
  17655. */
  17656. static readonly TriangleStripDrawMode: number;
  17657. /**
  17658. * Returns the triangle fan draw mode
  17659. */
  17660. static readonly TriangleFanDrawMode: number;
  17661. /**
  17662. * Stores the clock-wise side orientation
  17663. */
  17664. static readonly ClockWiseSideOrientation: number;
  17665. /**
  17666. * Stores the counter clock-wise side orientation
  17667. */
  17668. static readonly CounterClockWiseSideOrientation: number;
  17669. /**
  17670. * The dirty texture flag value
  17671. */
  17672. static readonly TextureDirtyFlag: number;
  17673. /**
  17674. * The dirty light flag value
  17675. */
  17676. static readonly LightDirtyFlag: number;
  17677. /**
  17678. * The dirty fresnel flag value
  17679. */
  17680. static readonly FresnelDirtyFlag: number;
  17681. /**
  17682. * The dirty attribute flag value
  17683. */
  17684. static readonly AttributesDirtyFlag: number;
  17685. /**
  17686. * The dirty misc flag value
  17687. */
  17688. static readonly MiscDirtyFlag: number;
  17689. /**
  17690. * The all dirty flag value
  17691. */
  17692. static readonly AllDirtyFlag: number;
  17693. /**
  17694. * The ID of the material
  17695. */
  17696. id: string;
  17697. /**
  17698. * Gets or sets the unique id of the material
  17699. */
  17700. uniqueId: number;
  17701. /**
  17702. * The name of the material
  17703. */
  17704. name: string;
  17705. /**
  17706. * Gets or sets user defined metadata
  17707. */
  17708. metadata: any;
  17709. /**
  17710. * For internal use only. Please do not use.
  17711. */
  17712. reservedDataStore: any;
  17713. /**
  17714. * Specifies if the ready state should be checked on each call
  17715. */
  17716. checkReadyOnEveryCall: boolean;
  17717. /**
  17718. * Specifies if the ready state should be checked once
  17719. */
  17720. checkReadyOnlyOnce: boolean;
  17721. /**
  17722. * The state of the material
  17723. */
  17724. state: string;
  17725. /**
  17726. * The alpha value of the material
  17727. */
  17728. protected _alpha: number;
  17729. /**
  17730. * Sets the alpha value of the material
  17731. */
  17732. /**
  17733. * Gets the alpha value of the material
  17734. */
  17735. alpha: number;
  17736. /**
  17737. * Specifies if back face culling is enabled
  17738. */
  17739. protected _backFaceCulling: boolean;
  17740. /**
  17741. * Sets the back-face culling state
  17742. */
  17743. /**
  17744. * Gets the back-face culling state
  17745. */
  17746. backFaceCulling: boolean;
  17747. /**
  17748. * Stores the value for side orientation
  17749. */
  17750. sideOrientation: number;
  17751. /**
  17752. * Callback triggered when the material is compiled
  17753. */
  17754. onCompiled: (effect: Effect) => void;
  17755. /**
  17756. * Callback triggered when an error occurs
  17757. */
  17758. onError: (effect: Effect, errors: string) => void;
  17759. /**
  17760. * Callback triggered to get the render target textures
  17761. */
  17762. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17763. /**
  17764. * Gets a boolean indicating that current material needs to register RTT
  17765. */
  17766. readonly hasRenderTargetTextures: boolean;
  17767. /**
  17768. * Specifies if the material should be serialized
  17769. */
  17770. doNotSerialize: boolean;
  17771. /**
  17772. * @hidden
  17773. */
  17774. _storeEffectOnSubMeshes: boolean;
  17775. /**
  17776. * Stores the animations for the material
  17777. */
  17778. animations: Array<Animation>;
  17779. /**
  17780. * An event triggered when the material is disposed
  17781. */
  17782. onDisposeObservable: Observable<Material>;
  17783. /**
  17784. * An observer which watches for dispose events
  17785. */
  17786. private _onDisposeObserver;
  17787. private _onUnBindObservable;
  17788. /**
  17789. * Called during a dispose event
  17790. */
  17791. onDispose: () => void;
  17792. private _onBindObservable;
  17793. /**
  17794. * An event triggered when the material is bound
  17795. */
  17796. readonly onBindObservable: Observable<AbstractMesh>;
  17797. /**
  17798. * An observer which watches for bind events
  17799. */
  17800. private _onBindObserver;
  17801. /**
  17802. * Called during a bind event
  17803. */
  17804. onBind: (Mesh: AbstractMesh) => void;
  17805. /**
  17806. * An event triggered when the material is unbound
  17807. */
  17808. readonly onUnBindObservable: Observable<Material>;
  17809. /**
  17810. * Stores the value of the alpha mode
  17811. */
  17812. private _alphaMode;
  17813. /**
  17814. * Sets the value of the alpha mode.
  17815. *
  17816. * | Value | Type | Description |
  17817. * | --- | --- | --- |
  17818. * | 0 | ALPHA_DISABLE | |
  17819. * | 1 | ALPHA_ADD | |
  17820. * | 2 | ALPHA_COMBINE | |
  17821. * | 3 | ALPHA_SUBTRACT | |
  17822. * | 4 | ALPHA_MULTIPLY | |
  17823. * | 5 | ALPHA_MAXIMIZED | |
  17824. * | 6 | ALPHA_ONEONE | |
  17825. * | 7 | ALPHA_PREMULTIPLIED | |
  17826. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17827. * | 9 | ALPHA_INTERPOLATE | |
  17828. * | 10 | ALPHA_SCREENMODE | |
  17829. *
  17830. */
  17831. /**
  17832. * Gets the value of the alpha mode
  17833. */
  17834. alphaMode: number;
  17835. /**
  17836. * Stores the state of the need depth pre-pass value
  17837. */
  17838. private _needDepthPrePass;
  17839. /**
  17840. * Sets the need depth pre-pass value
  17841. */
  17842. /**
  17843. * Gets the depth pre-pass value
  17844. */
  17845. needDepthPrePass: boolean;
  17846. /**
  17847. * Specifies if depth writing should be disabled
  17848. */
  17849. disableDepthWrite: boolean;
  17850. /**
  17851. * Specifies if depth writing should be forced
  17852. */
  17853. forceDepthWrite: boolean;
  17854. /**
  17855. * Specifies if there should be a separate pass for culling
  17856. */
  17857. separateCullingPass: boolean;
  17858. /**
  17859. * Stores the state specifing if fog should be enabled
  17860. */
  17861. private _fogEnabled;
  17862. /**
  17863. * Sets the state for enabling fog
  17864. */
  17865. /**
  17866. * Gets the value of the fog enabled state
  17867. */
  17868. fogEnabled: boolean;
  17869. /**
  17870. * Stores the size of points
  17871. */
  17872. pointSize: number;
  17873. /**
  17874. * Stores the z offset value
  17875. */
  17876. zOffset: number;
  17877. /**
  17878. * Gets a value specifying if wireframe mode is enabled
  17879. */
  17880. /**
  17881. * Sets the state of wireframe mode
  17882. */
  17883. wireframe: boolean;
  17884. /**
  17885. * Gets the value specifying if point clouds are enabled
  17886. */
  17887. /**
  17888. * Sets the state of point cloud mode
  17889. */
  17890. pointsCloud: boolean;
  17891. /**
  17892. * Gets the material fill mode
  17893. */
  17894. /**
  17895. * Sets the material fill mode
  17896. */
  17897. fillMode: number;
  17898. /**
  17899. * @hidden
  17900. * Stores the effects for the material
  17901. */
  17902. _effect: Nullable<Effect>;
  17903. /**
  17904. * @hidden
  17905. * Specifies if the material was previously ready
  17906. */
  17907. _wasPreviouslyReady: boolean;
  17908. /**
  17909. * Specifies if uniform buffers should be used
  17910. */
  17911. private _useUBO;
  17912. /**
  17913. * Stores a reference to the scene
  17914. */
  17915. private _scene;
  17916. /**
  17917. * Stores the fill mode state
  17918. */
  17919. private _fillMode;
  17920. /**
  17921. * Specifies if the depth write state should be cached
  17922. */
  17923. private _cachedDepthWriteState;
  17924. /**
  17925. * Stores the uniform buffer
  17926. */
  17927. protected _uniformBuffer: UniformBuffer;
  17928. /** @hidden */
  17929. _indexInSceneMaterialArray: number;
  17930. /** @hidden */
  17931. meshMap: Nullable<{
  17932. [id: string]: AbstractMesh | undefined;
  17933. }>;
  17934. /**
  17935. * Creates a material instance
  17936. * @param name defines the name of the material
  17937. * @param scene defines the scene to reference
  17938. * @param doNotAdd specifies if the material should be added to the scene
  17939. */
  17940. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17941. /**
  17942. * Returns a string representation of the current material
  17943. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17944. * @returns a string with material information
  17945. */
  17946. toString(fullDetails?: boolean): string;
  17947. /**
  17948. * Gets the class name of the material
  17949. * @returns a string with the class name of the material
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * Specifies if updates for the material been locked
  17954. */
  17955. readonly isFrozen: boolean;
  17956. /**
  17957. * Locks updates for the material
  17958. */
  17959. freeze(): void;
  17960. /**
  17961. * Unlocks updates for the material
  17962. */
  17963. unfreeze(): void;
  17964. /**
  17965. * Specifies if the material is ready to be used
  17966. * @param mesh defines the mesh to check
  17967. * @param useInstances specifies if instances should be used
  17968. * @returns a boolean indicating if the material is ready to be used
  17969. */
  17970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17971. /**
  17972. * Specifies that the submesh is ready to be used
  17973. * @param mesh defines the mesh to check
  17974. * @param subMesh defines which submesh to check
  17975. * @param useInstances specifies that instances should be used
  17976. * @returns a boolean indicating that the submesh is ready or not
  17977. */
  17978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17979. /**
  17980. * Returns the material effect
  17981. * @returns the effect associated with the material
  17982. */
  17983. getEffect(): Nullable<Effect>;
  17984. /**
  17985. * Returns the current scene
  17986. * @returns a Scene
  17987. */
  17988. getScene(): Scene;
  17989. /**
  17990. * Specifies if the material will require alpha blending
  17991. * @returns a boolean specifying if alpha blending is needed
  17992. */
  17993. needAlphaBlending(): boolean;
  17994. /**
  17995. * Specifies if the mesh will require alpha blending
  17996. * @param mesh defines the mesh to check
  17997. * @returns a boolean specifying if alpha blending is needed for the mesh
  17998. */
  17999. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18000. /**
  18001. * Specifies if this material should be rendered in alpha test mode
  18002. * @returns a boolean specifying if an alpha test is needed.
  18003. */
  18004. needAlphaTesting(): boolean;
  18005. /**
  18006. * Gets the texture used for the alpha test
  18007. * @returns the texture to use for alpha testing
  18008. */
  18009. getAlphaTestTexture(): Nullable<BaseTexture>;
  18010. /**
  18011. * Marks the material to indicate that it needs to be re-calculated
  18012. */
  18013. markDirty(): void;
  18014. /** @hidden */
  18015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18016. /**
  18017. * Binds the material to the mesh
  18018. * @param world defines the world transformation matrix
  18019. * @param mesh defines the mesh to bind the material to
  18020. */
  18021. bind(world: Matrix, mesh?: Mesh): void;
  18022. /**
  18023. * Binds the submesh to the material
  18024. * @param world defines the world transformation matrix
  18025. * @param mesh defines the mesh containing the submesh
  18026. * @param subMesh defines the submesh to bind the material to
  18027. */
  18028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18029. /**
  18030. * Binds the world matrix to the material
  18031. * @param world defines the world transformation matrix
  18032. */
  18033. bindOnlyWorldMatrix(world: Matrix): void;
  18034. /**
  18035. * Binds the scene's uniform buffer to the effect.
  18036. * @param effect defines the effect to bind to the scene uniform buffer
  18037. * @param sceneUbo defines the uniform buffer storing scene data
  18038. */
  18039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18040. /**
  18041. * Binds the view matrix to the effect
  18042. * @param effect defines the effect to bind the view matrix to
  18043. */
  18044. bindView(effect: Effect): void;
  18045. /**
  18046. * Binds the view projection matrix to the effect
  18047. * @param effect defines the effect to bind the view projection matrix to
  18048. */
  18049. bindViewProjection(effect: Effect): void;
  18050. /**
  18051. * Specifies if material alpha testing should be turned on for the mesh
  18052. * @param mesh defines the mesh to check
  18053. */
  18054. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18055. /**
  18056. * Processes to execute after binding the material to a mesh
  18057. * @param mesh defines the rendered mesh
  18058. */
  18059. protected _afterBind(mesh?: Mesh): void;
  18060. /**
  18061. * Unbinds the material from the mesh
  18062. */
  18063. unbind(): void;
  18064. /**
  18065. * Gets the active textures from the material
  18066. * @returns an array of textures
  18067. */
  18068. getActiveTextures(): BaseTexture[];
  18069. /**
  18070. * Specifies if the material uses a texture
  18071. * @param texture defines the texture to check against the material
  18072. * @returns a boolean specifying if the material uses the texture
  18073. */
  18074. hasTexture(texture: BaseTexture): boolean;
  18075. /**
  18076. * Makes a duplicate of the material, and gives it a new name
  18077. * @param name defines the new name for the duplicated material
  18078. * @returns the cloned material
  18079. */
  18080. clone(name: string): Nullable<Material>;
  18081. /**
  18082. * Gets the meshes bound to the material
  18083. * @returns an array of meshes bound to the material
  18084. */
  18085. getBindedMeshes(): AbstractMesh[];
  18086. /**
  18087. * Force shader compilation
  18088. * @param mesh defines the mesh associated with this material
  18089. * @param onCompiled defines a function to execute once the material is compiled
  18090. * @param options defines the options to configure the compilation
  18091. */
  18092. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18093. clipPlane: boolean;
  18094. }>): void;
  18095. /**
  18096. * Force shader compilation
  18097. * @param mesh defines the mesh that will use this material
  18098. * @param options defines additional options for compiling the shaders
  18099. * @returns a promise that resolves when the compilation completes
  18100. */
  18101. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18102. clipPlane: boolean;
  18103. }>): Promise<void>;
  18104. private static readonly _ImageProcessingDirtyCallBack;
  18105. private static readonly _TextureDirtyCallBack;
  18106. private static readonly _FresnelDirtyCallBack;
  18107. private static readonly _MiscDirtyCallBack;
  18108. private static readonly _LightsDirtyCallBack;
  18109. private static readonly _AttributeDirtyCallBack;
  18110. private static _FresnelAndMiscDirtyCallBack;
  18111. private static _TextureAndMiscDirtyCallBack;
  18112. private static readonly _DirtyCallbackArray;
  18113. private static readonly _RunDirtyCallBacks;
  18114. /**
  18115. * Marks a define in the material to indicate that it needs to be re-computed
  18116. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18117. */
  18118. markAsDirty(flag: number): void;
  18119. /**
  18120. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18121. * @param func defines a function which checks material defines against the submeshes
  18122. */
  18123. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18124. /**
  18125. * Indicates that image processing needs to be re-calculated for all submeshes
  18126. */
  18127. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18128. /**
  18129. * Indicates that textures need to be re-calculated for all submeshes
  18130. */
  18131. protected _markAllSubMeshesAsTexturesDirty(): void;
  18132. /**
  18133. * Indicates that fresnel needs to be re-calculated for all submeshes
  18134. */
  18135. protected _markAllSubMeshesAsFresnelDirty(): void;
  18136. /**
  18137. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18138. */
  18139. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18140. /**
  18141. * Indicates that lights need to be re-calculated for all submeshes
  18142. */
  18143. protected _markAllSubMeshesAsLightsDirty(): void;
  18144. /**
  18145. * Indicates that attributes need to be re-calculated for all submeshes
  18146. */
  18147. protected _markAllSubMeshesAsAttributesDirty(): void;
  18148. /**
  18149. * Indicates that misc needs to be re-calculated for all submeshes
  18150. */
  18151. protected _markAllSubMeshesAsMiscDirty(): void;
  18152. /**
  18153. * Indicates that textures and misc need to be re-calculated for all submeshes
  18154. */
  18155. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18156. /**
  18157. * Disposes the material
  18158. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18159. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18160. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18161. */
  18162. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18163. /** @hidden */
  18164. private releaseVertexArrayObject;
  18165. /**
  18166. * Serializes this material
  18167. * @returns the serialized material object
  18168. */
  18169. serialize(): any;
  18170. /**
  18171. * Creates a material from parsed material data
  18172. * @param parsedMaterial defines parsed material data
  18173. * @param scene defines the hosting scene
  18174. * @param rootUrl defines the root URL to use to load textures
  18175. * @returns a new material
  18176. */
  18177. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18178. }
  18179. }
  18180. declare module "babylonjs/Loading/sceneLoaderFlags" {
  18181. /**
  18182. * Class used to represent data loading progression
  18183. */
  18184. export class SceneLoaderFlags {
  18185. private static _ForceFullSceneLoadingForIncremental;
  18186. private static _ShowLoadingScreen;
  18187. private static _CleanBoneMatrixWeights;
  18188. private static _loggingLevel;
  18189. /**
  18190. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  18191. */
  18192. static ForceFullSceneLoadingForIncremental: boolean;
  18193. /**
  18194. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  18195. */
  18196. static ShowLoadingScreen: boolean;
  18197. /**
  18198. * Defines the current logging level (while loading the scene)
  18199. * @ignorenaming
  18200. */
  18201. static loggingLevel: number;
  18202. /**
  18203. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  18204. */
  18205. static CleanBoneMatrixWeights: boolean;
  18206. }
  18207. }
  18208. declare module "babylonjs/Morph/morphTarget" {
  18209. import { IAnimatable } from "babylonjs/Misc/tools";
  18210. import { Observable } from "babylonjs/Misc/observable";
  18211. import { Nullable, FloatArray } from "babylonjs/types";
  18212. import { Scene } from "babylonjs/scene";
  18213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18214. import { Animation } from "babylonjs/Animations/animation";
  18215. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18216. /**
  18217. * Defines a target to use with MorphTargetManager
  18218. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18219. */
  18220. export class MorphTarget implements IAnimatable {
  18221. /** defines the name of the target */
  18222. name: string;
  18223. /**
  18224. * Gets or sets the list of animations
  18225. */
  18226. animations: Animation[];
  18227. private _scene;
  18228. private _positions;
  18229. private _normals;
  18230. private _tangents;
  18231. private _influence;
  18232. /**
  18233. * Observable raised when the influence changes
  18234. */
  18235. onInfluenceChanged: Observable<boolean>;
  18236. /** @hidden */
  18237. _onDataLayoutChanged: Observable<void>;
  18238. /**
  18239. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18240. */
  18241. influence: number;
  18242. /**
  18243. * Gets or sets the id of the morph Target
  18244. */
  18245. id: string;
  18246. private _animationPropertiesOverride;
  18247. /**
  18248. * Gets or sets the animation properties override
  18249. */
  18250. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18251. /**
  18252. * Creates a new MorphTarget
  18253. * @param name defines the name of the target
  18254. * @param influence defines the influence to use
  18255. */
  18256. constructor(
  18257. /** defines the name of the target */
  18258. name: string, influence?: number, scene?: Nullable<Scene>);
  18259. /**
  18260. * Gets a boolean defining if the target contains position data
  18261. */
  18262. readonly hasPositions: boolean;
  18263. /**
  18264. * Gets a boolean defining if the target contains normal data
  18265. */
  18266. readonly hasNormals: boolean;
  18267. /**
  18268. * Gets a boolean defining if the target contains tangent data
  18269. */
  18270. readonly hasTangents: boolean;
  18271. /**
  18272. * Affects position data to this target
  18273. * @param data defines the position data to use
  18274. */
  18275. setPositions(data: Nullable<FloatArray>): void;
  18276. /**
  18277. * Gets the position data stored in this target
  18278. * @returns a FloatArray containing the position data (or null if not present)
  18279. */
  18280. getPositions(): Nullable<FloatArray>;
  18281. /**
  18282. * Affects normal data to this target
  18283. * @param data defines the normal data to use
  18284. */
  18285. setNormals(data: Nullable<FloatArray>): void;
  18286. /**
  18287. * Gets the normal data stored in this target
  18288. * @returns a FloatArray containing the normal data (or null if not present)
  18289. */
  18290. getNormals(): Nullable<FloatArray>;
  18291. /**
  18292. * Affects tangent data to this target
  18293. * @param data defines the tangent data to use
  18294. */
  18295. setTangents(data: Nullable<FloatArray>): void;
  18296. /**
  18297. * Gets the tangent data stored in this target
  18298. * @returns a FloatArray containing the tangent data (or null if not present)
  18299. */
  18300. getTangents(): Nullable<FloatArray>;
  18301. /**
  18302. * Serializes the current target into a Serialization object
  18303. * @returns the serialized object
  18304. */
  18305. serialize(): any;
  18306. /**
  18307. * Returns the string "MorphTarget"
  18308. * @returns "MorphTarget"
  18309. */
  18310. getClassName(): string;
  18311. /**
  18312. * Creates a new target from serialized data
  18313. * @param serializationObject defines the serialized data to use
  18314. * @returns a new MorphTarget
  18315. */
  18316. static Parse(serializationObject: any): MorphTarget;
  18317. /**
  18318. * Creates a MorphTarget from mesh data
  18319. * @param mesh defines the source mesh
  18320. * @param name defines the name to use for the new target
  18321. * @param influence defines the influence to attach to the target
  18322. * @returns a new MorphTarget
  18323. */
  18324. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18325. }
  18326. }
  18327. declare module "babylonjs/Morph/morphTargetManager" {
  18328. import { Nullable } from "babylonjs/types";
  18329. import { Scene } from "babylonjs/scene";
  18330. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  18331. /**
  18332. * This class is used to deform meshes using morphing between different targets
  18333. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18334. */
  18335. export class MorphTargetManager {
  18336. private _targets;
  18337. private _targetInfluenceChangedObservers;
  18338. private _targetDataLayoutChangedObservers;
  18339. private _activeTargets;
  18340. private _scene;
  18341. private _influences;
  18342. private _supportsNormals;
  18343. private _supportsTangents;
  18344. private _vertexCount;
  18345. private _uniqueId;
  18346. private _tempInfluences;
  18347. /**
  18348. * Creates a new MorphTargetManager
  18349. * @param scene defines the current scene
  18350. */
  18351. constructor(scene?: Nullable<Scene>);
  18352. /**
  18353. * Gets the unique ID of this manager
  18354. */
  18355. readonly uniqueId: number;
  18356. /**
  18357. * Gets the number of vertices handled by this manager
  18358. */
  18359. readonly vertexCount: number;
  18360. /**
  18361. * Gets a boolean indicating if this manager supports morphing of normals
  18362. */
  18363. readonly supportsNormals: boolean;
  18364. /**
  18365. * Gets a boolean indicating if this manager supports morphing of tangents
  18366. */
  18367. readonly supportsTangents: boolean;
  18368. /**
  18369. * Gets the number of targets stored in this manager
  18370. */
  18371. readonly numTargets: number;
  18372. /**
  18373. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18374. */
  18375. readonly numInfluencers: number;
  18376. /**
  18377. * Gets the list of influences (one per target)
  18378. */
  18379. readonly influences: Float32Array;
  18380. /**
  18381. * Gets the active target at specified index. An active target is a target with an influence > 0
  18382. * @param index defines the index to check
  18383. * @returns the requested target
  18384. */
  18385. getActiveTarget(index: number): MorphTarget;
  18386. /**
  18387. * Gets the target at specified index
  18388. * @param index defines the index to check
  18389. * @returns the requested target
  18390. */
  18391. getTarget(index: number): MorphTarget;
  18392. /**
  18393. * Add a new target to this manager
  18394. * @param target defines the target to add
  18395. */
  18396. addTarget(target: MorphTarget): void;
  18397. /**
  18398. * Removes a target from the manager
  18399. * @param target defines the target to remove
  18400. */
  18401. removeTarget(target: MorphTarget): void;
  18402. /**
  18403. * Serializes the current manager into a Serialization object
  18404. * @returns the serialized object
  18405. */
  18406. serialize(): any;
  18407. private _syncActiveTargets;
  18408. /**
  18409. * Syncrhonize the targets with all the meshes using this morph target manager
  18410. */
  18411. synchronize(): void;
  18412. /**
  18413. * Creates a new MorphTargetManager from serialized data
  18414. * @param serializationObject defines the serialized data
  18415. * @param scene defines the hosting scene
  18416. * @returns the new MorphTargetManager
  18417. */
  18418. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18419. }
  18420. }
  18421. declare module "babylonjs/Physics/physicsJoint" {
  18422. import { Vector3 } from "babylonjs/Maths/math";
  18423. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18424. /**
  18425. * Interface for Physics-Joint data
  18426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18427. */
  18428. export interface PhysicsJointData {
  18429. /**
  18430. * The main pivot of the joint
  18431. */
  18432. mainPivot?: Vector3;
  18433. /**
  18434. * The connected pivot of the joint
  18435. */
  18436. connectedPivot?: Vector3;
  18437. /**
  18438. * The main axis of the joint
  18439. */
  18440. mainAxis?: Vector3;
  18441. /**
  18442. * The connected axis of the joint
  18443. */
  18444. connectedAxis?: Vector3;
  18445. /**
  18446. * The collision of the joint
  18447. */
  18448. collision?: boolean;
  18449. /**
  18450. * Native Oimo/Cannon/Energy data
  18451. */
  18452. nativeParams?: any;
  18453. }
  18454. /**
  18455. * This is a holder class for the physics joint created by the physics plugin
  18456. * It holds a set of functions to control the underlying joint
  18457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18458. */
  18459. export class PhysicsJoint {
  18460. /**
  18461. * The type of the physics joint
  18462. */
  18463. type: number;
  18464. /**
  18465. * The data for the physics joint
  18466. */
  18467. jointData: PhysicsJointData;
  18468. private _physicsJoint;
  18469. protected _physicsPlugin: IPhysicsEnginePlugin;
  18470. /**
  18471. * Initializes the physics joint
  18472. * @param type The type of the physics joint
  18473. * @param jointData The data for the physics joint
  18474. */
  18475. constructor(
  18476. /**
  18477. * The type of the physics joint
  18478. */
  18479. type: number,
  18480. /**
  18481. * The data for the physics joint
  18482. */
  18483. jointData: PhysicsJointData);
  18484. /**
  18485. * Gets the physics joint
  18486. */
  18487. /**
  18488. * Sets the physics joint
  18489. */
  18490. physicsJoint: any;
  18491. /**
  18492. * Sets the physics plugin
  18493. */
  18494. physicsPlugin: IPhysicsEnginePlugin;
  18495. /**
  18496. * Execute a function that is physics-plugin specific.
  18497. * @param {Function} func the function that will be executed.
  18498. * It accepts two parameters: the physics world and the physics joint
  18499. */
  18500. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18501. /**
  18502. * Distance-Joint type
  18503. */
  18504. static DistanceJoint: number;
  18505. /**
  18506. * Hinge-Joint type
  18507. */
  18508. static HingeJoint: number;
  18509. /**
  18510. * Ball-and-Socket joint type
  18511. */
  18512. static BallAndSocketJoint: number;
  18513. /**
  18514. * Wheel-Joint type
  18515. */
  18516. static WheelJoint: number;
  18517. /**
  18518. * Slider-Joint type
  18519. */
  18520. static SliderJoint: number;
  18521. /**
  18522. * Prismatic-Joint type
  18523. */
  18524. static PrismaticJoint: number;
  18525. /**
  18526. * Universal-Joint type
  18527. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18528. */
  18529. static UniversalJoint: number;
  18530. /**
  18531. * Hinge-Joint 2 type
  18532. */
  18533. static Hinge2Joint: number;
  18534. /**
  18535. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18536. */
  18537. static PointToPointJoint: number;
  18538. /**
  18539. * Spring-Joint type
  18540. */
  18541. static SpringJoint: number;
  18542. /**
  18543. * Lock-Joint type
  18544. */
  18545. static LockJoint: number;
  18546. }
  18547. /**
  18548. * A class representing a physics distance joint
  18549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18550. */
  18551. export class DistanceJoint extends PhysicsJoint {
  18552. /**
  18553. *
  18554. * @param jointData The data for the Distance-Joint
  18555. */
  18556. constructor(jointData: DistanceJointData);
  18557. /**
  18558. * Update the predefined distance.
  18559. * @param maxDistance The maximum preferred distance
  18560. * @param minDistance The minimum preferred distance
  18561. */
  18562. updateDistance(maxDistance: number, minDistance?: number): void;
  18563. }
  18564. /**
  18565. * Represents a Motor-Enabled Joint
  18566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18567. */
  18568. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18569. /**
  18570. * Initializes the Motor-Enabled Joint
  18571. * @param type The type of the joint
  18572. * @param jointData The physica joint data for the joint
  18573. */
  18574. constructor(type: number, jointData: PhysicsJointData);
  18575. /**
  18576. * Set the motor values.
  18577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18578. * @param force the force to apply
  18579. * @param maxForce max force for this motor.
  18580. */
  18581. setMotor(force?: number, maxForce?: number): void;
  18582. /**
  18583. * Set the motor's limits.
  18584. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18585. * @param upperLimit The upper limit of the motor
  18586. * @param lowerLimit The lower limit of the motor
  18587. */
  18588. setLimit(upperLimit: number, lowerLimit?: number): void;
  18589. }
  18590. /**
  18591. * This class represents a single physics Hinge-Joint
  18592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18593. */
  18594. export class HingeJoint extends MotorEnabledJoint {
  18595. /**
  18596. * Initializes the Hinge-Joint
  18597. * @param jointData The joint data for the Hinge-Joint
  18598. */
  18599. constructor(jointData: PhysicsJointData);
  18600. /**
  18601. * Set the motor values.
  18602. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18603. * @param {number} force the force to apply
  18604. * @param {number} maxForce max force for this motor.
  18605. */
  18606. setMotor(force?: number, maxForce?: number): void;
  18607. /**
  18608. * Set the motor's limits.
  18609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18610. * @param upperLimit The upper limit of the motor
  18611. * @param lowerLimit The lower limit of the motor
  18612. */
  18613. setLimit(upperLimit: number, lowerLimit?: number): void;
  18614. }
  18615. /**
  18616. * This class represents a dual hinge physics joint (same as wheel joint)
  18617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18618. */
  18619. export class Hinge2Joint extends MotorEnabledJoint {
  18620. /**
  18621. * Initializes the Hinge2-Joint
  18622. * @param jointData The joint data for the Hinge2-Joint
  18623. */
  18624. constructor(jointData: PhysicsJointData);
  18625. /**
  18626. * Set the motor values.
  18627. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18628. * @param {number} force the force to apply
  18629. * @param {number} maxForce max force for this motor.
  18630. * @param {motorIndex} the motor's index, 0 or 1.
  18631. */
  18632. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18633. /**
  18634. * Set the motor limits.
  18635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18636. * @param {number} upperLimit the upper limit
  18637. * @param {number} lowerLimit lower limit
  18638. * @param {motorIndex} the motor's index, 0 or 1.
  18639. */
  18640. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18641. }
  18642. /**
  18643. * Interface for a motor enabled joint
  18644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18645. */
  18646. export interface IMotorEnabledJoint {
  18647. /**
  18648. * Physics joint
  18649. */
  18650. physicsJoint: any;
  18651. /**
  18652. * Sets the motor of the motor-enabled joint
  18653. * @param force The force of the motor
  18654. * @param maxForce The maximum force of the motor
  18655. * @param motorIndex The index of the motor
  18656. */
  18657. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18658. /**
  18659. * Sets the limit of the motor
  18660. * @param upperLimit The upper limit of the motor
  18661. * @param lowerLimit The lower limit of the motor
  18662. * @param motorIndex The index of the motor
  18663. */
  18664. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18665. }
  18666. /**
  18667. * Joint data for a Distance-Joint
  18668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18669. */
  18670. export interface DistanceJointData extends PhysicsJointData {
  18671. /**
  18672. * Max distance the 2 joint objects can be apart
  18673. */
  18674. maxDistance: number;
  18675. }
  18676. /**
  18677. * Joint data from a spring joint
  18678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18679. */
  18680. export interface SpringJointData extends PhysicsJointData {
  18681. /**
  18682. * Length of the spring
  18683. */
  18684. length: number;
  18685. /**
  18686. * Stiffness of the spring
  18687. */
  18688. stiffness: number;
  18689. /**
  18690. * Damping of the spring
  18691. */
  18692. damping: number;
  18693. /** this callback will be called when applying the force to the impostors. */
  18694. forceApplicationCallback: () => void;
  18695. }
  18696. }
  18697. declare module "babylonjs/Physics/IPhysicsEngine" {
  18698. import { Nullable } from "babylonjs/types";
  18699. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18701. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18702. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18703. /**
  18704. * Interface used to describe a physics joint
  18705. */
  18706. export interface PhysicsImpostorJoint {
  18707. /** Defines the main impostor to which the joint is linked */
  18708. mainImpostor: PhysicsImpostor;
  18709. /** Defines the impostor that is connected to the main impostor using this joint */
  18710. connectedImpostor: PhysicsImpostor;
  18711. /** Defines the joint itself */
  18712. joint: PhysicsJoint;
  18713. }
  18714. /** @hidden */
  18715. export interface IPhysicsEnginePlugin {
  18716. world: any;
  18717. name: string;
  18718. setGravity(gravity: Vector3): void;
  18719. setTimeStep(timeStep: number): void;
  18720. getTimeStep(): number;
  18721. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18724. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18725. removePhysicsBody(impostor: PhysicsImpostor): void;
  18726. generateJoint(joint: PhysicsImpostorJoint): void;
  18727. removeJoint(joint: PhysicsImpostorJoint): void;
  18728. isSupported(): boolean;
  18729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18736. getBodyMass(impostor: PhysicsImpostor): number;
  18737. getBodyFriction(impostor: PhysicsImpostor): number;
  18738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18739. getBodyRestitution(impostor: PhysicsImpostor): number;
  18740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18741. sleepBody(impostor: PhysicsImpostor): void;
  18742. wakeUpBody(impostor: PhysicsImpostor): void;
  18743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18746. getRadius(impostor: PhysicsImpostor): number;
  18747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18749. dispose(): void;
  18750. }
  18751. /**
  18752. * Interface used to define a physics engine
  18753. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18754. */
  18755. export interface IPhysicsEngine {
  18756. /**
  18757. * Gets the gravity vector used by the simulation
  18758. */
  18759. gravity: Vector3;
  18760. /**
  18761. * Sets the gravity vector used by the simulation
  18762. * @param gravity defines the gravity vector to use
  18763. */
  18764. setGravity(gravity: Vector3): void;
  18765. /**
  18766. * Set the time step of the physics engine.
  18767. * Default is 1/60.
  18768. * To slow it down, enter 1/600 for example.
  18769. * To speed it up, 1/30
  18770. * @param newTimeStep the new timestep to apply to this world.
  18771. */
  18772. setTimeStep(newTimeStep: number): void;
  18773. /**
  18774. * Get the time step of the physics engine.
  18775. * @returns the current time step
  18776. */
  18777. getTimeStep(): number;
  18778. /**
  18779. * Release all resources
  18780. */
  18781. dispose(): void;
  18782. /**
  18783. * Gets the name of the current physics plugin
  18784. * @returns the name of the plugin
  18785. */
  18786. getPhysicsPluginName(): string;
  18787. /**
  18788. * Adding a new impostor for the impostor tracking.
  18789. * This will be done by the impostor itself.
  18790. * @param impostor the impostor to add
  18791. */
  18792. addImpostor(impostor: PhysicsImpostor): void;
  18793. /**
  18794. * Remove an impostor from the engine.
  18795. * This impostor and its mesh will not longer be updated by the physics engine.
  18796. * @param impostor the impostor to remove
  18797. */
  18798. removeImpostor(impostor: PhysicsImpostor): void;
  18799. /**
  18800. * Add a joint to the physics engine
  18801. * @param mainImpostor defines the main impostor to which the joint is added.
  18802. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18803. * @param joint defines the joint that will connect both impostors.
  18804. */
  18805. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18806. /**
  18807. * Removes a joint from the simulation
  18808. * @param mainImpostor defines the impostor used with the joint
  18809. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18810. * @param joint defines the joint to remove
  18811. */
  18812. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18813. /**
  18814. * Gets the current plugin used to run the simulation
  18815. * @returns current plugin
  18816. */
  18817. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18818. /**
  18819. * Gets the list of physic impostors
  18820. * @returns an array of PhysicsImpostor
  18821. */
  18822. getImpostors(): Array<PhysicsImpostor>;
  18823. /**
  18824. * Gets the impostor for a physics enabled object
  18825. * @param object defines the object impersonated by the impostor
  18826. * @returns the PhysicsImpostor or null if not found
  18827. */
  18828. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18829. /**
  18830. * Gets the impostor for a physics body object
  18831. * @param body defines physics body used by the impostor
  18832. * @returns the PhysicsImpostor or null if not found
  18833. */
  18834. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18835. /**
  18836. * Called by the scene. No need to call it.
  18837. * @param delta defines the timespam between frames
  18838. */
  18839. _step(delta: number): void;
  18840. }
  18841. }
  18842. declare module "babylonjs/Physics/physicsImpostor" {
  18843. import { Nullable, IndicesArray } from "babylonjs/types";
  18844. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  18845. import { TransformNode } from "babylonjs/Meshes/transformNode";
  18846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18847. import { Scene } from "babylonjs/scene";
  18848. import { Bone } from "babylonjs/Bones/bone";
  18849. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  18850. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  18851. /**
  18852. * The interface for the physics imposter parameters
  18853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18854. */
  18855. export interface PhysicsImpostorParameters {
  18856. /**
  18857. * The mass of the physics imposter
  18858. */
  18859. mass: number;
  18860. /**
  18861. * The friction of the physics imposter
  18862. */
  18863. friction?: number;
  18864. /**
  18865. * The coefficient of restitution of the physics imposter
  18866. */
  18867. restitution?: number;
  18868. /**
  18869. * The native options of the physics imposter
  18870. */
  18871. nativeOptions?: any;
  18872. /**
  18873. * Specifies if the parent should be ignored
  18874. */
  18875. ignoreParent?: boolean;
  18876. /**
  18877. * Specifies if bi-directional transformations should be disabled
  18878. */
  18879. disableBidirectionalTransformation?: boolean;
  18880. }
  18881. /**
  18882. * Interface for a physics-enabled object
  18883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18884. */
  18885. export interface IPhysicsEnabledObject {
  18886. /**
  18887. * The position of the physics-enabled object
  18888. */
  18889. position: Vector3;
  18890. /**
  18891. * The rotation of the physics-enabled object
  18892. */
  18893. rotationQuaternion: Nullable<Quaternion>;
  18894. /**
  18895. * The scale of the physics-enabled object
  18896. */
  18897. scaling: Vector3;
  18898. /**
  18899. * The rotation of the physics-enabled object
  18900. */
  18901. rotation?: Vector3;
  18902. /**
  18903. * The parent of the physics-enabled object
  18904. */
  18905. parent?: any;
  18906. /**
  18907. * The bounding info of the physics-enabled object
  18908. * @returns The bounding info of the physics-enabled object
  18909. */
  18910. getBoundingInfo(): BoundingInfo;
  18911. /**
  18912. * Computes the world matrix
  18913. * @param force Specifies if the world matrix should be computed by force
  18914. * @returns A world matrix
  18915. */
  18916. computeWorldMatrix(force: boolean): Matrix;
  18917. /**
  18918. * Gets the world matrix
  18919. * @returns A world matrix
  18920. */
  18921. getWorldMatrix?(): Matrix;
  18922. /**
  18923. * Gets the child meshes
  18924. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18925. * @returns An array of abstract meshes
  18926. */
  18927. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18928. /**
  18929. * Gets the vertex data
  18930. * @param kind The type of vertex data
  18931. * @returns A nullable array of numbers, or a float32 array
  18932. */
  18933. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18934. /**
  18935. * Gets the indices from the mesh
  18936. * @returns A nullable array of index arrays
  18937. */
  18938. getIndices?(): Nullable<IndicesArray>;
  18939. /**
  18940. * Gets the scene from the mesh
  18941. * @returns the indices array or null
  18942. */
  18943. getScene?(): Scene;
  18944. /**
  18945. * Gets the absolute position from the mesh
  18946. * @returns the absolute position
  18947. */
  18948. getAbsolutePosition(): Vector3;
  18949. /**
  18950. * Gets the absolute pivot point from the mesh
  18951. * @returns the absolute pivot point
  18952. */
  18953. getAbsolutePivotPoint(): Vector3;
  18954. /**
  18955. * Rotates the mesh
  18956. * @param axis The axis of rotation
  18957. * @param amount The amount of rotation
  18958. * @param space The space of the rotation
  18959. * @returns The rotation transform node
  18960. */
  18961. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18962. /**
  18963. * Translates the mesh
  18964. * @param axis The axis of translation
  18965. * @param distance The distance of translation
  18966. * @param space The space of the translation
  18967. * @returns The transform node
  18968. */
  18969. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18970. /**
  18971. * Sets the absolute position of the mesh
  18972. * @param absolutePosition The absolute position of the mesh
  18973. * @returns The transform node
  18974. */
  18975. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18976. /**
  18977. * Gets the class name of the mesh
  18978. * @returns The class name
  18979. */
  18980. getClassName(): string;
  18981. }
  18982. /**
  18983. * Represents a physics imposter
  18984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18985. */
  18986. export class PhysicsImpostor {
  18987. /**
  18988. * The physics-enabled object used as the physics imposter
  18989. */
  18990. object: IPhysicsEnabledObject;
  18991. /**
  18992. * The type of the physics imposter
  18993. */
  18994. type: number;
  18995. private _options;
  18996. private _scene?;
  18997. /**
  18998. * The default object size of the imposter
  18999. */
  19000. static DEFAULT_OBJECT_SIZE: Vector3;
  19001. /**
  19002. * The identity quaternion of the imposter
  19003. */
  19004. static IDENTITY_QUATERNION: Quaternion;
  19005. /** @hidden */
  19006. _pluginData: any;
  19007. private _physicsEngine;
  19008. private _physicsBody;
  19009. private _bodyUpdateRequired;
  19010. private _onBeforePhysicsStepCallbacks;
  19011. private _onAfterPhysicsStepCallbacks;
  19012. /** @hidden */
  19013. _onPhysicsCollideCallbacks: Array<{
  19014. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19015. otherImpostors: Array<PhysicsImpostor>;
  19016. }>;
  19017. private _deltaPosition;
  19018. private _deltaRotation;
  19019. private _deltaRotationConjugated;
  19020. private _parent;
  19021. private _isDisposed;
  19022. private static _tmpVecs;
  19023. private static _tmpQuat;
  19024. /**
  19025. * Specifies if the physics imposter is disposed
  19026. */
  19027. readonly isDisposed: boolean;
  19028. /**
  19029. * Gets the mass of the physics imposter
  19030. */
  19031. mass: number;
  19032. /**
  19033. * Gets the coefficient of friction
  19034. */
  19035. /**
  19036. * Sets the coefficient of friction
  19037. */
  19038. friction: number;
  19039. /**
  19040. * Gets the coefficient of restitution
  19041. */
  19042. /**
  19043. * Sets the coefficient of restitution
  19044. */
  19045. restitution: number;
  19046. /**
  19047. * The unique id of the physics imposter
  19048. * set by the physics engine when adding this impostor to the array
  19049. */
  19050. uniqueId: number;
  19051. private _joints;
  19052. /**
  19053. * Initializes the physics imposter
  19054. * @param object The physics-enabled object used as the physics imposter
  19055. * @param type The type of the physics imposter
  19056. * @param _options The options for the physics imposter
  19057. * @param _scene The Babylon scene
  19058. */
  19059. constructor(
  19060. /**
  19061. * The physics-enabled object used as the physics imposter
  19062. */
  19063. object: IPhysicsEnabledObject,
  19064. /**
  19065. * The type of the physics imposter
  19066. */
  19067. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19068. /**
  19069. * This function will completly initialize this impostor.
  19070. * It will create a new body - but only if this mesh has no parent.
  19071. * If it has, this impostor will not be used other than to define the impostor
  19072. * of the child mesh.
  19073. * @hidden
  19074. */
  19075. _init(): void;
  19076. private _getPhysicsParent;
  19077. /**
  19078. * Should a new body be generated.
  19079. * @returns boolean specifying if body initialization is required
  19080. */
  19081. isBodyInitRequired(): boolean;
  19082. /**
  19083. * Sets the updated scaling
  19084. * @param updated Specifies if the scaling is updated
  19085. */
  19086. setScalingUpdated(): void;
  19087. /**
  19088. * Force a regeneration of this or the parent's impostor's body.
  19089. * Use under cautious - This will remove all joints already implemented.
  19090. */
  19091. forceUpdate(): void;
  19092. /**
  19093. * Gets the body that holds this impostor. Either its own, or its parent.
  19094. */
  19095. /**
  19096. * Set the physics body. Used mainly by the physics engine/plugin
  19097. */
  19098. physicsBody: any;
  19099. /**
  19100. * Get the parent of the physics imposter
  19101. * @returns Physics imposter or null
  19102. */
  19103. /**
  19104. * Sets the parent of the physics imposter
  19105. */
  19106. parent: Nullable<PhysicsImpostor>;
  19107. /**
  19108. * Resets the update flags
  19109. */
  19110. resetUpdateFlags(): void;
  19111. /**
  19112. * Gets the object extend size
  19113. * @returns the object extend size
  19114. */
  19115. getObjectExtendSize(): Vector3;
  19116. /**
  19117. * Gets the object center
  19118. * @returns The object center
  19119. */
  19120. getObjectCenter(): Vector3;
  19121. /**
  19122. * Get a specific parametes from the options parameter
  19123. * @param paramName The object parameter name
  19124. * @returns The object parameter
  19125. */
  19126. getParam(paramName: string): any;
  19127. /**
  19128. * Sets a specific parameter in the options given to the physics plugin
  19129. * @param paramName The parameter name
  19130. * @param value The value of the parameter
  19131. */
  19132. setParam(paramName: string, value: number): void;
  19133. /**
  19134. * Specifically change the body's mass option. Won't recreate the physics body object
  19135. * @param mass The mass of the physics imposter
  19136. */
  19137. setMass(mass: number): void;
  19138. /**
  19139. * Gets the linear velocity
  19140. * @returns linear velocity or null
  19141. */
  19142. getLinearVelocity(): Nullable<Vector3>;
  19143. /**
  19144. * Sets the linear velocity
  19145. * @param velocity linear velocity or null
  19146. */
  19147. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19148. /**
  19149. * Gets the angular velocity
  19150. * @returns angular velocity or null
  19151. */
  19152. getAngularVelocity(): Nullable<Vector3>;
  19153. /**
  19154. * Sets the angular velocity
  19155. * @param velocity The velocity or null
  19156. */
  19157. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19158. /**
  19159. * Execute a function with the physics plugin native code
  19160. * Provide a function the will have two variables - the world object and the physics body object
  19161. * @param func The function to execute with the physics plugin native code
  19162. */
  19163. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19164. /**
  19165. * Register a function that will be executed before the physics world is stepping forward
  19166. * @param func The function to execute before the physics world is stepped forward
  19167. */
  19168. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19169. /**
  19170. * Unregister a function that will be executed before the physics world is stepping forward
  19171. * @param func The function to execute before the physics world is stepped forward
  19172. */
  19173. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19174. /**
  19175. * Register a function that will be executed after the physics step
  19176. * @param func The function to execute after physics step
  19177. */
  19178. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19179. /**
  19180. * Unregisters a function that will be executed after the physics step
  19181. * @param func The function to execute after physics step
  19182. */
  19183. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19184. /**
  19185. * register a function that will be executed when this impostor collides against a different body
  19186. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19187. * @param func Callback that is executed on collision
  19188. */
  19189. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19190. /**
  19191. * Unregisters the physics imposter on contact
  19192. * @param collideAgainst The physics object to collide against
  19193. * @param func Callback to execute on collision
  19194. */
  19195. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19196. private _tmpQuat;
  19197. private _tmpQuat2;
  19198. /**
  19199. * Get the parent rotation
  19200. * @returns The parent rotation
  19201. */
  19202. getParentsRotation(): Quaternion;
  19203. /**
  19204. * this function is executed by the physics engine.
  19205. */
  19206. beforeStep: () => void;
  19207. /**
  19208. * this function is executed by the physics engine
  19209. */
  19210. afterStep: () => void;
  19211. /**
  19212. * Legacy collision detection event support
  19213. */
  19214. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19215. /**
  19216. * event and body object due to cannon's event-based architecture.
  19217. */
  19218. onCollide: (e: {
  19219. body: any;
  19220. }) => void;
  19221. /**
  19222. * Apply a force
  19223. * @param force The force to apply
  19224. * @param contactPoint The contact point for the force
  19225. * @returns The physics imposter
  19226. */
  19227. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19228. /**
  19229. * Apply an impulse
  19230. * @param force The impulse force
  19231. * @param contactPoint The contact point for the impulse force
  19232. * @returns The physics imposter
  19233. */
  19234. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19235. /**
  19236. * A help function to create a joint
  19237. * @param otherImpostor A physics imposter used to create a joint
  19238. * @param jointType The type of joint
  19239. * @param jointData The data for the joint
  19240. * @returns The physics imposter
  19241. */
  19242. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19243. /**
  19244. * Add a joint to this impostor with a different impostor
  19245. * @param otherImpostor A physics imposter used to add a joint
  19246. * @param joint The joint to add
  19247. * @returns The physics imposter
  19248. */
  19249. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19250. /**
  19251. * Will keep this body still, in a sleep mode.
  19252. * @returns the physics imposter
  19253. */
  19254. sleep(): PhysicsImpostor;
  19255. /**
  19256. * Wake the body up.
  19257. * @returns The physics imposter
  19258. */
  19259. wakeUp(): PhysicsImpostor;
  19260. /**
  19261. * Clones the physics imposter
  19262. * @param newObject The physics imposter clones to this physics-enabled object
  19263. * @returns A nullable physics imposter
  19264. */
  19265. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19266. /**
  19267. * Disposes the physics imposter
  19268. */
  19269. dispose(): void;
  19270. /**
  19271. * Sets the delta position
  19272. * @param position The delta position amount
  19273. */
  19274. setDeltaPosition(position: Vector3): void;
  19275. /**
  19276. * Sets the delta rotation
  19277. * @param rotation The delta rotation amount
  19278. */
  19279. setDeltaRotation(rotation: Quaternion): void;
  19280. /**
  19281. * Gets the box size of the physics imposter and stores the result in the input parameter
  19282. * @param result Stores the box size
  19283. * @returns The physics imposter
  19284. */
  19285. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19286. /**
  19287. * Gets the radius of the physics imposter
  19288. * @returns Radius of the physics imposter
  19289. */
  19290. getRadius(): number;
  19291. /**
  19292. * Sync a bone with this impostor
  19293. * @param bone The bone to sync to the impostor.
  19294. * @param boneMesh The mesh that the bone is influencing.
  19295. * @param jointPivot The pivot of the joint / bone in local space.
  19296. * @param distToJoint Optional distance from the impostor to the joint.
  19297. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19298. */
  19299. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19300. /**
  19301. * Sync impostor to a bone
  19302. * @param bone The bone that the impostor will be synced to.
  19303. * @param boneMesh The mesh that the bone is influencing.
  19304. * @param jointPivot The pivot of the joint / bone in local space.
  19305. * @param distToJoint Optional distance from the impostor to the joint.
  19306. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19307. * @param boneAxis Optional vector3 axis the bone is aligned with
  19308. */
  19309. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19310. /**
  19311. * No-Imposter type
  19312. */
  19313. static NoImpostor: number;
  19314. /**
  19315. * Sphere-Imposter type
  19316. */
  19317. static SphereImpostor: number;
  19318. /**
  19319. * Box-Imposter type
  19320. */
  19321. static BoxImpostor: number;
  19322. /**
  19323. * Plane-Imposter type
  19324. */
  19325. static PlaneImpostor: number;
  19326. /**
  19327. * Mesh-imposter type
  19328. */
  19329. static MeshImpostor: number;
  19330. /**
  19331. * Cylinder-Imposter type
  19332. */
  19333. static CylinderImpostor: number;
  19334. /**
  19335. * Particle-Imposter type
  19336. */
  19337. static ParticleImpostor: number;
  19338. /**
  19339. * Heightmap-Imposter type
  19340. */
  19341. static HeightmapImpostor: number;
  19342. }
  19343. }
  19344. declare module "babylonjs/Meshes/groundMesh" {
  19345. import { Scene } from "babylonjs/scene";
  19346. import { Vector3 } from "babylonjs/Maths/math";
  19347. import { Mesh } from "babylonjs/Meshes/mesh";
  19348. /**
  19349. * Mesh representing the gorund
  19350. */
  19351. export class GroundMesh extends Mesh {
  19352. /** If octree should be generated */
  19353. generateOctree: boolean;
  19354. private _heightQuads;
  19355. /** @hidden */
  19356. _subdivisionsX: number;
  19357. /** @hidden */
  19358. _subdivisionsY: number;
  19359. /** @hidden */
  19360. _width: number;
  19361. /** @hidden */
  19362. _height: number;
  19363. /** @hidden */
  19364. _minX: number;
  19365. /** @hidden */
  19366. _maxX: number;
  19367. /** @hidden */
  19368. _minZ: number;
  19369. /** @hidden */
  19370. _maxZ: number;
  19371. constructor(name: string, scene: Scene);
  19372. /**
  19373. * "GroundMesh"
  19374. * @returns "GroundMesh"
  19375. */
  19376. getClassName(): string;
  19377. /**
  19378. * The minimum of x and y subdivisions
  19379. */
  19380. readonly subdivisions: number;
  19381. /**
  19382. * X subdivisions
  19383. */
  19384. readonly subdivisionsX: number;
  19385. /**
  19386. * Y subdivisions
  19387. */
  19388. readonly subdivisionsY: number;
  19389. /**
  19390. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19391. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19392. * @param chunksCount the number of subdivisions for x and y
  19393. * @param octreeBlocksSize (Default: 32)
  19394. */
  19395. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19396. /**
  19397. * Returns a height (y) value in the Worl system :
  19398. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19399. * @param x x coordinate
  19400. * @param z z coordinate
  19401. * @returns the ground y position if (x, z) are outside the ground surface.
  19402. */
  19403. getHeightAtCoordinates(x: number, z: number): number;
  19404. /**
  19405. * Returns a normalized vector (Vector3) orthogonal to the ground
  19406. * at the ground coordinates (x, z) expressed in the World system.
  19407. * @param x x coordinate
  19408. * @param z z coordinate
  19409. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19410. */
  19411. getNormalAtCoordinates(x: number, z: number): Vector3;
  19412. /**
  19413. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19414. * at the ground coordinates (x, z) expressed in the World system.
  19415. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19416. * @param x x coordinate
  19417. * @param z z coordinate
  19418. * @param ref vector to store the result
  19419. * @returns the GroundMesh.
  19420. */
  19421. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19422. /**
  19423. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19424. * if the ground has been updated.
  19425. * This can be used in the render loop.
  19426. * @returns the GroundMesh.
  19427. */
  19428. updateCoordinateHeights(): GroundMesh;
  19429. private _getFacetAt;
  19430. private _initHeightQuads;
  19431. private _computeHeightQuads;
  19432. /**
  19433. * Serializes this ground mesh
  19434. * @param serializationObject object to write serialization to
  19435. */
  19436. serialize(serializationObject: any): void;
  19437. /**
  19438. * Parses a serialized ground mesh
  19439. * @param parsedMesh the serialized mesh
  19440. * @param scene the scene to create the ground mesh in
  19441. * @returns the created ground mesh
  19442. */
  19443. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19444. }
  19445. }
  19446. declare module "babylonjs/Meshes/mesh" {
  19447. import { Observable } from "babylonjs/Misc/observable";
  19448. import { IAnimatable } from "babylonjs/Misc/tools";
  19449. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19450. import { Camera } from "babylonjs/Cameras/camera";
  19451. import { Scene } from "babylonjs/scene";
  19452. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19453. import { Engine } from "babylonjs/Engines/engine";
  19454. import { Node } from "babylonjs/node";
  19455. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19456. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19457. import { Buffer } from "babylonjs/Meshes/buffer";
  19458. import { Geometry } from "babylonjs/Meshes/geometry";
  19459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19460. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19461. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19462. import { Effect } from "babylonjs/Materials/effect";
  19463. import { Material } from "babylonjs/Materials/material";
  19464. import { Skeleton } from "babylonjs/Bones/skeleton";
  19465. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19466. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19467. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19468. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19469. /**
  19470. * Class used to represent a specific level of detail of a mesh
  19471. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19472. */
  19473. export class MeshLODLevel {
  19474. /** Defines the distance where this level should star being displayed */
  19475. distance: number;
  19476. /** Defines the mesh to use to render this level */
  19477. mesh: Nullable<Mesh>;
  19478. /**
  19479. * Creates a new LOD level
  19480. * @param distance defines the distance where this level should star being displayed
  19481. * @param mesh defines the mesh to use to render this level
  19482. */
  19483. constructor(
  19484. /** Defines the distance where this level should star being displayed */
  19485. distance: number,
  19486. /** Defines the mesh to use to render this level */
  19487. mesh: Nullable<Mesh>);
  19488. }
  19489. /**
  19490. * @hidden
  19491. **/
  19492. export class _CreationDataStorage {
  19493. closePath?: boolean;
  19494. closeArray?: boolean;
  19495. idx: number[];
  19496. dashSize: number;
  19497. gapSize: number;
  19498. path3D: Path3D;
  19499. pathArray: Vector3[][];
  19500. arc: number;
  19501. radius: number;
  19502. cap: number;
  19503. tessellation: number;
  19504. }
  19505. /**
  19506. * @hidden
  19507. **/
  19508. class _InstanceDataStorage {
  19509. visibleInstances: any;
  19510. renderIdForInstances: number[];
  19511. batchCache: _InstancesBatch;
  19512. instancesBufferSize: number;
  19513. instancesBuffer: Nullable<Buffer>;
  19514. instancesData: Float32Array;
  19515. overridenInstanceCount: number;
  19516. }
  19517. /**
  19518. * @hidden
  19519. **/
  19520. export class _InstancesBatch {
  19521. mustReturn: boolean;
  19522. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19523. renderSelf: boolean[];
  19524. }
  19525. /**
  19526. * Class used to represent renderable models
  19527. */
  19528. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19529. /**
  19530. * Mesh side orientation : usually the external or front surface
  19531. */
  19532. static readonly FRONTSIDE: number;
  19533. /**
  19534. * Mesh side orientation : usually the internal or back surface
  19535. */
  19536. static readonly BACKSIDE: number;
  19537. /**
  19538. * Mesh side orientation : both internal and external or front and back surfaces
  19539. */
  19540. static readonly DOUBLESIDE: number;
  19541. /**
  19542. * Mesh side orientation : by default, `FRONTSIDE`
  19543. */
  19544. static readonly DEFAULTSIDE: number;
  19545. /**
  19546. * Mesh cap setting : no cap
  19547. */
  19548. static readonly NO_CAP: number;
  19549. /**
  19550. * Mesh cap setting : one cap at the beginning of the mesh
  19551. */
  19552. static readonly CAP_START: number;
  19553. /**
  19554. * Mesh cap setting : one cap at the end of the mesh
  19555. */
  19556. static readonly CAP_END: number;
  19557. /**
  19558. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19559. */
  19560. static readonly CAP_ALL: number;
  19561. private _onBeforeRenderObservable;
  19562. private _onAfterRenderObservable;
  19563. private _onBeforeDrawObservable;
  19564. /**
  19565. * An event triggered before rendering the mesh
  19566. */
  19567. readonly onBeforeRenderObservable: Observable<Mesh>;
  19568. /**
  19569. * An event triggered after rendering the mesh
  19570. */
  19571. readonly onAfterRenderObservable: Observable<Mesh>;
  19572. /**
  19573. * An event triggered before drawing the mesh
  19574. */
  19575. readonly onBeforeDrawObservable: Observable<Mesh>;
  19576. private _onBeforeDrawObserver;
  19577. /**
  19578. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19579. */
  19580. onBeforeDraw: () => void;
  19581. /**
  19582. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19583. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19584. */
  19585. delayLoadState: number;
  19586. /**
  19587. * Gets the list of instances created from this mesh
  19588. * it is not supposed to be modified manually.
  19589. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19590. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19591. */
  19592. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19593. /**
  19594. * Gets the file containing delay loading data for this mesh
  19595. */
  19596. delayLoadingFile: string;
  19597. /** @hidden */
  19598. _binaryInfo: any;
  19599. private _LODLevels;
  19600. /**
  19601. * User defined function used to change how LOD level selection is done
  19602. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19603. */
  19604. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19605. private _morphTargetManager;
  19606. /**
  19607. * Gets or sets the morph target manager
  19608. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19609. */
  19610. morphTargetManager: Nullable<MorphTargetManager>;
  19611. /** @hidden */
  19612. _creationDataStorage: Nullable<_CreationDataStorage>;
  19613. /** @hidden */
  19614. _geometry: Nullable<Geometry>;
  19615. /** @hidden */
  19616. _delayInfo: Array<string>;
  19617. /** @hidden */
  19618. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19619. /** @hidden */
  19620. _instanceDataStorage: _InstanceDataStorage;
  19621. private _effectiveMaterial;
  19622. /** @hidden */
  19623. _shouldGenerateFlatShading: boolean;
  19624. private _preActivateId;
  19625. /** @hidden */
  19626. _originalBuilderSideOrientation: number;
  19627. /**
  19628. * Use this property to change the original side orientation defined at construction time
  19629. */
  19630. overrideMaterialSideOrientation: Nullable<number>;
  19631. private _areNormalsFrozen;
  19632. private _sourcePositions;
  19633. private _sourceNormals;
  19634. private _source;
  19635. private meshMap;
  19636. /**
  19637. * Gets the source mesh (the one used to clone this one from)
  19638. */
  19639. readonly source: Nullable<Mesh>;
  19640. /**
  19641. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19642. */
  19643. isUnIndexed: boolean;
  19644. /**
  19645. * @constructor
  19646. * @param name The value used by scene.getMeshByName() to do a lookup.
  19647. * @param scene The scene to add this mesh to.
  19648. * @param parent The parent of this mesh, if it has one
  19649. * @param source An optional Mesh from which geometry is shared, cloned.
  19650. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19651. * When false, achieved by calling a clone(), also passing False.
  19652. * This will make creation of children, recursive.
  19653. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19654. */
  19655. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19656. /**
  19657. * Gets the class name
  19658. * @returns the string "Mesh".
  19659. */
  19660. getClassName(): string;
  19661. /** @hidden */
  19662. readonly _isMesh: boolean;
  19663. /**
  19664. * Returns a description of this mesh
  19665. * @param fullDetails define if full details about this mesh must be used
  19666. * @returns a descriptive string representing this mesh
  19667. */
  19668. toString(fullDetails?: boolean): string;
  19669. /** @hidden */
  19670. _unBindEffect(): void;
  19671. /**
  19672. * Gets a boolean indicating if this mesh has LOD
  19673. */
  19674. readonly hasLODLevels: boolean;
  19675. /**
  19676. * Gets the list of MeshLODLevel associated with the current mesh
  19677. * @returns an array of MeshLODLevel
  19678. */
  19679. getLODLevels(): MeshLODLevel[];
  19680. private _sortLODLevels;
  19681. /**
  19682. * Add a mesh as LOD level triggered at the given distance.
  19683. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19684. * @param distance The distance from the center of the object to show this level
  19685. * @param mesh The mesh to be added as LOD level (can be null)
  19686. * @return This mesh (for chaining)
  19687. */
  19688. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19689. /**
  19690. * Returns the LOD level mesh at the passed distance or null if not found.
  19691. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19692. * @param distance The distance from the center of the object to show this level
  19693. * @returns a Mesh or `null`
  19694. */
  19695. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19696. /**
  19697. * Remove a mesh from the LOD array
  19698. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19699. * @param mesh defines the mesh to be removed
  19700. * @return This mesh (for chaining)
  19701. */
  19702. removeLODLevel(mesh: Mesh): Mesh;
  19703. /**
  19704. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19705. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19706. * @param camera defines the camera to use to compute distance
  19707. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19708. * @return This mesh (for chaining)
  19709. */
  19710. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19711. /**
  19712. * Gets the mesh internal Geometry object
  19713. */
  19714. readonly geometry: Nullable<Geometry>;
  19715. /**
  19716. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19717. * @returns the total number of vertices
  19718. */
  19719. getTotalVertices(): number;
  19720. /**
  19721. * Returns the content of an associated vertex buffer
  19722. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19723. * - VertexBuffer.PositionKind
  19724. * - VertexBuffer.UVKind
  19725. * - VertexBuffer.UV2Kind
  19726. * - VertexBuffer.UV3Kind
  19727. * - VertexBuffer.UV4Kind
  19728. * - VertexBuffer.UV5Kind
  19729. * - VertexBuffer.UV6Kind
  19730. * - VertexBuffer.ColorKind
  19731. * - VertexBuffer.MatricesIndicesKind
  19732. * - VertexBuffer.MatricesIndicesExtraKind
  19733. * - VertexBuffer.MatricesWeightsKind
  19734. * - VertexBuffer.MatricesWeightsExtraKind
  19735. * @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
  19736. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19737. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19738. */
  19739. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19740. /**
  19741. * Returns the mesh VertexBuffer object from the requested `kind`
  19742. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19743. * - VertexBuffer.PositionKind
  19744. * - VertexBuffer.UVKind
  19745. * - VertexBuffer.UV2Kind
  19746. * - VertexBuffer.UV3Kind
  19747. * - VertexBuffer.UV4Kind
  19748. * - VertexBuffer.UV5Kind
  19749. * - VertexBuffer.UV6Kind
  19750. * - VertexBuffer.ColorKind
  19751. * - VertexBuffer.MatricesIndicesKind
  19752. * - VertexBuffer.MatricesIndicesExtraKind
  19753. * - VertexBuffer.MatricesWeightsKind
  19754. * - VertexBuffer.MatricesWeightsExtraKind
  19755. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19756. */
  19757. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19758. /**
  19759. * Tests if a specific vertex buffer is associated with this mesh
  19760. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19761. * - VertexBuffer.PositionKind
  19762. * - VertexBuffer.UVKind
  19763. * - VertexBuffer.UV2Kind
  19764. * - VertexBuffer.UV3Kind
  19765. * - VertexBuffer.UV4Kind
  19766. * - VertexBuffer.UV5Kind
  19767. * - VertexBuffer.UV6Kind
  19768. * - VertexBuffer.ColorKind
  19769. * - VertexBuffer.MatricesIndicesKind
  19770. * - VertexBuffer.MatricesIndicesExtraKind
  19771. * - VertexBuffer.MatricesWeightsKind
  19772. * - VertexBuffer.MatricesWeightsExtraKind
  19773. * @returns a boolean
  19774. */
  19775. isVerticesDataPresent(kind: string): boolean;
  19776. /**
  19777. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19778. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19779. * - VertexBuffer.PositionKind
  19780. * - VertexBuffer.UVKind
  19781. * - VertexBuffer.UV2Kind
  19782. * - VertexBuffer.UV3Kind
  19783. * - VertexBuffer.UV4Kind
  19784. * - VertexBuffer.UV5Kind
  19785. * - VertexBuffer.UV6Kind
  19786. * - VertexBuffer.ColorKind
  19787. * - VertexBuffer.MatricesIndicesKind
  19788. * - VertexBuffer.MatricesIndicesExtraKind
  19789. * - VertexBuffer.MatricesWeightsKind
  19790. * - VertexBuffer.MatricesWeightsExtraKind
  19791. * @returns a boolean
  19792. */
  19793. isVertexBufferUpdatable(kind: string): boolean;
  19794. /**
  19795. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19796. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19797. * - VertexBuffer.PositionKind
  19798. * - VertexBuffer.UVKind
  19799. * - VertexBuffer.UV2Kind
  19800. * - VertexBuffer.UV3Kind
  19801. * - VertexBuffer.UV4Kind
  19802. * - VertexBuffer.UV5Kind
  19803. * - VertexBuffer.UV6Kind
  19804. * - VertexBuffer.ColorKind
  19805. * - VertexBuffer.MatricesIndicesKind
  19806. * - VertexBuffer.MatricesIndicesExtraKind
  19807. * - VertexBuffer.MatricesWeightsKind
  19808. * - VertexBuffer.MatricesWeightsExtraKind
  19809. * @returns an array of strings
  19810. */
  19811. getVerticesDataKinds(): string[];
  19812. /**
  19813. * Returns a positive integer : the total number of indices in this mesh geometry.
  19814. * @returns the numner of indices or zero if the mesh has no geometry.
  19815. */
  19816. getTotalIndices(): number;
  19817. /**
  19818. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19819. * @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.
  19820. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19821. * @returns the indices array or an empty array if the mesh has no geometry
  19822. */
  19823. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19824. readonly isBlocked: boolean;
  19825. /**
  19826. * Determine if the current mesh is ready to be rendered
  19827. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19828. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19829. * @returns true if all associated assets are ready (material, textures, shaders)
  19830. */
  19831. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19832. /**
  19833. * 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.
  19834. */
  19835. readonly areNormalsFrozen: boolean;
  19836. /**
  19837. * 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.
  19838. * @returns the current mesh
  19839. */
  19840. freezeNormals(): Mesh;
  19841. /**
  19842. * 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
  19843. * @returns the current mesh
  19844. */
  19845. unfreezeNormals(): Mesh;
  19846. /**
  19847. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19848. */
  19849. overridenInstanceCount: number;
  19850. /** @hidden */
  19851. _preActivate(): Mesh;
  19852. /** @hidden */
  19853. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19854. /** @hidden */
  19855. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19856. /**
  19857. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19858. * This means the mesh underlying bounding box and sphere are recomputed.
  19859. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19860. * @returns the current mesh
  19861. */
  19862. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19863. /** @hidden */
  19864. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19865. /**
  19866. * This function will subdivide the mesh into multiple submeshes
  19867. * @param count defines the expected number of submeshes
  19868. */
  19869. subdivide(count: number): void;
  19870. /**
  19871. * Copy a FloatArray into a specific associated vertex buffer
  19872. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19873. * - VertexBuffer.PositionKind
  19874. * - VertexBuffer.UVKind
  19875. * - VertexBuffer.UV2Kind
  19876. * - VertexBuffer.UV3Kind
  19877. * - VertexBuffer.UV4Kind
  19878. * - VertexBuffer.UV5Kind
  19879. * - VertexBuffer.UV6Kind
  19880. * - VertexBuffer.ColorKind
  19881. * - VertexBuffer.MatricesIndicesKind
  19882. * - VertexBuffer.MatricesIndicesExtraKind
  19883. * - VertexBuffer.MatricesWeightsKind
  19884. * - VertexBuffer.MatricesWeightsExtraKind
  19885. * @param data defines the data source
  19886. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19887. * @param stride defines the data stride size (can be null)
  19888. * @returns the current mesh
  19889. */
  19890. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19891. /**
  19892. * Flags an associated vertex buffer as updatable
  19893. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19894. * - VertexBuffer.PositionKind
  19895. * - VertexBuffer.UVKind
  19896. * - VertexBuffer.UV2Kind
  19897. * - VertexBuffer.UV3Kind
  19898. * - VertexBuffer.UV4Kind
  19899. * - VertexBuffer.UV5Kind
  19900. * - VertexBuffer.UV6Kind
  19901. * - VertexBuffer.ColorKind
  19902. * - VertexBuffer.MatricesIndicesKind
  19903. * - VertexBuffer.MatricesIndicesExtraKind
  19904. * - VertexBuffer.MatricesWeightsKind
  19905. * - VertexBuffer.MatricesWeightsExtraKind
  19906. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19907. */
  19908. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19909. /**
  19910. * Sets the mesh global Vertex Buffer
  19911. * @param buffer defines the buffer to use
  19912. * @returns the current mesh
  19913. */
  19914. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19915. /**
  19916. * Update a specific associated vertex buffer
  19917. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19918. * - VertexBuffer.PositionKind
  19919. * - VertexBuffer.UVKind
  19920. * - VertexBuffer.UV2Kind
  19921. * - VertexBuffer.UV3Kind
  19922. * - VertexBuffer.UV4Kind
  19923. * - VertexBuffer.UV5Kind
  19924. * - VertexBuffer.UV6Kind
  19925. * - VertexBuffer.ColorKind
  19926. * - VertexBuffer.MatricesIndicesKind
  19927. * - VertexBuffer.MatricesIndicesExtraKind
  19928. * - VertexBuffer.MatricesWeightsKind
  19929. * - VertexBuffer.MatricesWeightsExtraKind
  19930. * @param data defines the data source
  19931. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19932. * @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)
  19933. * @returns the current mesh
  19934. */
  19935. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19936. /**
  19937. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19938. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19939. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19940. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19941. * @returns the current mesh
  19942. */
  19943. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19944. /**
  19945. * Creates a un-shared specific occurence of the geometry for the mesh.
  19946. * @returns the current mesh
  19947. */
  19948. makeGeometryUnique(): Mesh;
  19949. /**
  19950. * Set the index buffer of this mesh
  19951. * @param indices defines the source data
  19952. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19953. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19954. * @returns the current mesh
  19955. */
  19956. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19957. /**
  19958. * Update the current index buffer
  19959. * @param indices defines the source data
  19960. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19961. * @returns the current mesh
  19962. */
  19963. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19964. /**
  19965. * Invert the geometry to move from a right handed system to a left handed one.
  19966. * @returns the current mesh
  19967. */
  19968. toLeftHanded(): Mesh;
  19969. /** @hidden */
  19970. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19971. /** @hidden */
  19972. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19973. /**
  19974. * Registers for this mesh a javascript function called just before the rendering process
  19975. * @param func defines the function to call before rendering this mesh
  19976. * @returns the current mesh
  19977. */
  19978. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19979. /**
  19980. * Disposes a previously registered javascript function called before the rendering
  19981. * @param func defines the function to remove
  19982. * @returns the current mesh
  19983. */
  19984. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19985. /**
  19986. * Registers for this mesh a javascript function called just after the rendering is complete
  19987. * @param func defines the function to call after rendering this mesh
  19988. * @returns the current mesh
  19989. */
  19990. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19991. /**
  19992. * Disposes a previously registered javascript function called after the rendering.
  19993. * @param func defines the function to remove
  19994. * @returns the current mesh
  19995. */
  19996. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19997. /** @hidden */
  19998. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19999. /** @hidden */
  20000. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20001. /** @hidden */
  20002. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20003. /**
  20004. * 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
  20005. * @param subMesh defines the subMesh to render
  20006. * @param enableAlphaMode defines if alpha mode can be changed
  20007. * @returns the current mesh
  20008. */
  20009. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20010. private _onBeforeDraw;
  20011. /**
  20012. * Renormalize the mesh and patch it up if there are no weights
  20013. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20014. * However in the case of zero weights then we set just a single influence to 1.
  20015. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20016. */
  20017. cleanMatrixWeights(): void;
  20018. private normalizeSkinFourWeights;
  20019. private normalizeSkinWeightsAndExtra;
  20020. /**
  20021. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20022. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20023. * the user know there was an issue with importing the mesh
  20024. * @returns a validation object with skinned, valid and report string
  20025. */
  20026. validateSkinning(): {
  20027. skinned: boolean;
  20028. valid: boolean;
  20029. report: string;
  20030. };
  20031. /** @hidden */
  20032. _checkDelayState(): Mesh;
  20033. private _queueLoad;
  20034. /**
  20035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20036. * A mesh is in the frustum if its bounding box intersects the frustum
  20037. * @param frustumPlanes defines the frustum to test
  20038. * @returns true if the mesh is in the frustum planes
  20039. */
  20040. isInFrustum(frustumPlanes: Plane[]): boolean;
  20041. /**
  20042. * Sets the mesh material by the material or multiMaterial `id` property
  20043. * @param id is a string identifying the material or the multiMaterial
  20044. * @returns the current mesh
  20045. */
  20046. setMaterialByID(id: string): Mesh;
  20047. /**
  20048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20049. * @returns an array of IAnimatable
  20050. */
  20051. getAnimatables(): IAnimatable[];
  20052. /**
  20053. * Modifies the mesh geometry according to the passed transformation matrix.
  20054. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20055. * The mesh normals are modified using the same transformation.
  20056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20057. * @param transform defines the transform matrix to use
  20058. * @see http://doc.babylonjs.com/resources/baking_transformations
  20059. * @returns the current mesh
  20060. */
  20061. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20062. /**
  20063. * Modifies the mesh geometry according to its own current World Matrix.
  20064. * The mesh World Matrix is then reset.
  20065. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20066. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20067. * @see http://doc.babylonjs.com/resources/baking_transformations
  20068. * @returns the current mesh
  20069. */
  20070. bakeCurrentTransformIntoVertices(): Mesh;
  20071. /** @hidden */
  20072. readonly _positions: Nullable<Vector3[]>;
  20073. /** @hidden */
  20074. _resetPointsArrayCache(): Mesh;
  20075. /** @hidden */
  20076. _generatePointsArray(): boolean;
  20077. /**
  20078. * Returns a new Mesh object generated from the current mesh properties.
  20079. * This method must not get confused with createInstance()
  20080. * @param name is a string, the name given to the new mesh
  20081. * @param newParent can be any Node object (default `null`)
  20082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20084. * @returns a new mesh
  20085. */
  20086. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20087. /**
  20088. * Releases resources associated with this mesh.
  20089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20091. */
  20092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20093. /**
  20094. * Modifies the mesh geometry according to a displacement map.
  20095. * 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.
  20096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20097. * @param url is a string, the URL from the image file is to be downloaded.
  20098. * @param minHeight is the lower limit of the displacement.
  20099. * @param maxHeight is the upper limit of the displacement.
  20100. * @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.
  20101. * @param uvOffset is an optional vector2 used to offset UV.
  20102. * @param uvScale is an optional vector2 used to scale UV.
  20103. * @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.
  20104. * @returns the Mesh.
  20105. */
  20106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20107. /**
  20108. * Modifies the mesh geometry according to a displacementMap buffer.
  20109. * 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.
  20110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20112. * @param heightMapWidth is the width of the buffer image.
  20113. * @param heightMapHeight is the height of the buffer image.
  20114. * @param minHeight is the lower limit of the displacement.
  20115. * @param maxHeight is the upper limit of the displacement.
  20116. * @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.
  20117. * @param uvOffset is an optional vector2 used to offset UV.
  20118. * @param uvScale is an optional vector2 used to scale UV.
  20119. * @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.
  20120. * @returns the Mesh.
  20121. */
  20122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20123. /**
  20124. * Modify the mesh to get a flat shading rendering.
  20125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20127. * @returns current mesh
  20128. */
  20129. convertToFlatShadedMesh(): Mesh;
  20130. /**
  20131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20132. * In other words, more vertices, no more indices and a single bigger VBO.
  20133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20134. * @returns current mesh
  20135. */
  20136. convertToUnIndexedMesh(): Mesh;
  20137. /**
  20138. * Inverses facet orientations.
  20139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20140. * @param flipNormals will also inverts the normals
  20141. * @returns current mesh
  20142. */
  20143. flipFaces(flipNormals?: boolean): Mesh;
  20144. /** @hidden */
  20145. static _instancedMeshFactory: (name: string, mesh: Mesh) => import("babylonjs/Meshes/instancedMesh").InstancedMesh;
  20146. /**
  20147. * Creates a new InstancedMesh object from the mesh model.
  20148. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20149. * @param name defines the name of the new instance
  20150. * @returns a new InstancedMesh
  20151. */
  20152. createInstance(name: string): InstancedMesh;
  20153. /**
  20154. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20155. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20156. * @returns the current mesh
  20157. */
  20158. synchronizeInstances(): Mesh;
  20159. /**
  20160. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20161. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20162. * This should be used together with the simplification to avoid disappearing triangles.
  20163. * @param successCallback an optional success callback to be called after the optimization finished.
  20164. * @returns the current mesh
  20165. */
  20166. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20167. /**
  20168. * Serialize current mesh
  20169. * @param serializationObject defines the object which will receive the serialization data
  20170. */
  20171. serialize(serializationObject: any): void;
  20172. /** @hidden */
  20173. _syncGeometryWithMorphTargetManager(): void;
  20174. /** @hidden */
  20175. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20176. /**
  20177. * Returns a new Mesh object parsed from the source provided.
  20178. * @param parsedMesh is the source
  20179. * @param scene defines the hosting scene
  20180. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20181. * @returns a new Mesh
  20182. */
  20183. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20184. /**
  20185. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20186. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20187. * @param name defines the name of the mesh to create
  20188. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20189. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20190. * @param closePath creates a seam between the first and the last points of each path of the path array
  20191. * @param offset is taken in account only if the `pathArray` is containing a single path
  20192. * @param scene defines the hosting scene
  20193. * @param updatable defines if the mesh must be flagged as updatable
  20194. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20195. * @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)
  20196. * @returns a new Mesh
  20197. */
  20198. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20199. /**
  20200. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20201. * @param name defines the name of the mesh to create
  20202. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20203. * @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
  20204. * @param scene defines the hosting scene
  20205. * @param updatable defines if the mesh must be flagged as updatable
  20206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20207. * @returns a new Mesh
  20208. */
  20209. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20210. /**
  20211. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20212. * @param name defines the name of the mesh to create
  20213. * @param size sets the size (float) of each box side (default 1)
  20214. * @param scene defines the hosting scene
  20215. * @param updatable defines if the mesh must be flagged as updatable
  20216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20217. * @returns a new Mesh
  20218. */
  20219. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20220. /**
  20221. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20222. * @param name defines the name of the mesh to create
  20223. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20224. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20225. * @param scene defines the hosting scene
  20226. * @param updatable defines if the mesh must be flagged as updatable
  20227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20228. * @returns a new Mesh
  20229. */
  20230. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20231. /**
  20232. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20233. * @param name defines the name of the mesh to create
  20234. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20235. * @param diameterTop set the top cap diameter (floats, default 1)
  20236. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20237. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20238. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20239. * @param scene defines the hosting scene
  20240. * @param updatable defines if the mesh must be flagged as updatable
  20241. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20242. * @returns a new Mesh
  20243. */
  20244. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20245. /**
  20246. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20247. * @param name defines the name of the mesh to create
  20248. * @param diameter sets the diameter size (float) of the torus (default 1)
  20249. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20250. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20251. * @param scene defines the hosting scene
  20252. * @param updatable defines if the mesh must be flagged as updatable
  20253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20254. * @returns a new Mesh
  20255. */
  20256. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20257. /**
  20258. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20259. * @param name defines the name of the mesh to create
  20260. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20261. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20262. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20263. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20264. * @param p the number of windings on X axis (positive integers, default 2)
  20265. * @param q the number of windings on Y axis (positive integers, default 3)
  20266. * @param scene defines the hosting scene
  20267. * @param updatable defines if the mesh must be flagged as updatable
  20268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20269. * @returns a new Mesh
  20270. */
  20271. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20272. /**
  20273. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20274. * @param name defines the name of the mesh to create
  20275. * @param points is an array successive Vector3
  20276. * @param scene defines the hosting scene
  20277. * @param updatable defines if the mesh must be flagged as updatable
  20278. * @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).
  20279. * @returns a new Mesh
  20280. */
  20281. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20282. /**
  20283. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20284. * @param name defines the name of the mesh to create
  20285. * @param points is an array successive Vector3
  20286. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20287. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20288. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20289. * @param scene defines the hosting scene
  20290. * @param updatable defines if the mesh must be flagged as updatable
  20291. * @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)
  20292. * @returns a new Mesh
  20293. */
  20294. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20295. /**
  20296. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20297. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20298. * 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.
  20299. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20300. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20301. * Remember you can only change the shape positions, not their number when updating a polygon.
  20302. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20303. * @param name defines the name of the mesh to create
  20304. * @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
  20305. * @param scene defines the hosting scene
  20306. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20307. * @param updatable defines if the mesh must be flagged as updatable
  20308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20309. * @returns a new Mesh
  20310. */
  20311. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20312. /**
  20313. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20314. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20315. * @param name defines the name of the mesh to create
  20316. * @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
  20317. * @param depth defines the height of extrusion
  20318. * @param scene defines the hosting scene
  20319. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20320. * @param updatable defines if the mesh must be flagged as updatable
  20321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20322. * @returns a new Mesh
  20323. */
  20324. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20325. /**
  20326. * Creates an extruded shape mesh.
  20327. * 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
  20328. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20329. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20330. * @param name defines the name of the mesh to create
  20331. * @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
  20332. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20333. * @param scale is the value to scale the shape
  20334. * @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
  20335. * @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
  20336. * @param scene defines the hosting scene
  20337. * @param updatable defines if the mesh must be flagged as updatable
  20338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20339. * @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)
  20340. * @returns a new Mesh
  20341. */
  20342. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20343. /**
  20344. * Creates an custom extruded shape mesh.
  20345. * The custom extrusion is a parametric shape.
  20346. * It has no predefined shape. Its final shape will depend on the input parameters.
  20347. * Please consider using the same method from the MeshBuilder class instead
  20348. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20349. * @param name defines the name of the mesh to create
  20350. * @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
  20351. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20352. * @param scaleFunction is a custom Javascript function called on each path point
  20353. * @param rotationFunction is a custom Javascript function called on each path point
  20354. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20355. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20356. * @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
  20357. * @param scene defines the hosting scene
  20358. * @param updatable defines if the mesh must be flagged as updatable
  20359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20360. * @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)
  20361. * @returns a new Mesh
  20362. */
  20363. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20364. /**
  20365. * Creates lathe mesh.
  20366. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20367. * Please consider using the same method from the MeshBuilder class instead
  20368. * @param name defines the name of the mesh to create
  20369. * @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
  20370. * @param radius is the radius value of the lathe
  20371. * @param tessellation is the side number of the lathe.
  20372. * @param scene defines the hosting scene
  20373. * @param updatable defines if the mesh must be flagged as updatable
  20374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20375. * @returns a new Mesh
  20376. */
  20377. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20378. /**
  20379. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20380. * @param name defines the name of the mesh to create
  20381. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20382. * @param scene defines the hosting scene
  20383. * @param updatable defines if the mesh must be flagged as updatable
  20384. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20385. * @returns a new Mesh
  20386. */
  20387. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20388. /**
  20389. * Creates a ground mesh.
  20390. * Please consider using the same method from the MeshBuilder class instead
  20391. * @param name defines the name of the mesh to create
  20392. * @param width set the width of the ground
  20393. * @param height set the height of the ground
  20394. * @param subdivisions sets the number of subdivisions per side
  20395. * @param scene defines the hosting scene
  20396. * @param updatable defines if the mesh must be flagged as updatable
  20397. * @returns a new Mesh
  20398. */
  20399. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20400. /**
  20401. * Creates a tiled ground mesh.
  20402. * Please consider using the same method from the MeshBuilder class instead
  20403. * @param name defines the name of the mesh to create
  20404. * @param xmin set the ground minimum X coordinate
  20405. * @param zmin set the ground minimum Y coordinate
  20406. * @param xmax set the ground maximum X coordinate
  20407. * @param zmax set the ground maximum Z coordinate
  20408. * @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
  20409. * @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
  20410. * @param scene defines the hosting scene
  20411. * @param updatable defines if the mesh must be flagged as updatable
  20412. * @returns a new Mesh
  20413. */
  20414. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20415. w: number;
  20416. h: number;
  20417. }, precision: {
  20418. w: number;
  20419. h: number;
  20420. }, scene: Scene, updatable?: boolean): Mesh;
  20421. /**
  20422. * Creates a ground mesh from a height map.
  20423. * Please consider using the same method from the MeshBuilder class instead
  20424. * @see http://doc.babylonjs.com/babylon101/height_map
  20425. * @param name defines the name of the mesh to create
  20426. * @param url sets the URL of the height map image resource
  20427. * @param width set the ground width size
  20428. * @param height set the ground height size
  20429. * @param subdivisions sets the number of subdivision per side
  20430. * @param minHeight is the minimum altitude on the ground
  20431. * @param maxHeight is the maximum altitude on the ground
  20432. * @param scene defines the hosting scene
  20433. * @param updatable defines if the mesh must be flagged as updatable
  20434. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20435. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20436. * @returns a new Mesh
  20437. */
  20438. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  20439. /**
  20440. * Creates a tube mesh.
  20441. * The tube is a parametric shape.
  20442. * It has no predefined shape. Its final shape will depend on the input parameters.
  20443. * Please consider using the same method from the MeshBuilder class instead
  20444. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20445. * @param name defines the name of the mesh to create
  20446. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20447. * @param radius sets the tube radius size
  20448. * @param tessellation is the number of sides on the tubular surface
  20449. * @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
  20450. * @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
  20451. * @param scene defines the hosting scene
  20452. * @param updatable defines if the mesh must be flagged as updatable
  20453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20454. * @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)
  20455. * @returns a new Mesh
  20456. */
  20457. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20458. (i: number, distance: number): number;
  20459. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20460. /**
  20461. * Creates a polyhedron mesh.
  20462. * Please consider using the same method from the MeshBuilder class instead.
  20463. * * 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
  20464. * * The parameter `size` (positive float, default 1) sets the polygon size
  20465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20466. * * 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`
  20467. * * 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
  20468. * * 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)`)
  20469. * * 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
  20470. * * 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
  20471. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20472. * * 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
  20473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20474. * @param name defines the name of the mesh to create
  20475. * @param options defines the options used to create the mesh
  20476. * @param scene defines the hosting scene
  20477. * @returns a new Mesh
  20478. */
  20479. static CreatePolyhedron(name: string, options: {
  20480. type?: number;
  20481. size?: number;
  20482. sizeX?: number;
  20483. sizeY?: number;
  20484. sizeZ?: number;
  20485. custom?: any;
  20486. faceUV?: Vector4[];
  20487. faceColors?: Color4[];
  20488. updatable?: boolean;
  20489. sideOrientation?: number;
  20490. }, scene: Scene): Mesh;
  20491. /**
  20492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20494. * * 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`)
  20495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20496. * * 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
  20497. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20498. * * 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
  20499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20500. * @param name defines the name of the mesh
  20501. * @param options defines the options used to create the mesh
  20502. * @param scene defines the hosting scene
  20503. * @returns a new Mesh
  20504. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20505. */
  20506. static CreateIcoSphere(name: string, options: {
  20507. radius?: number;
  20508. flat?: boolean;
  20509. subdivisions?: number;
  20510. sideOrientation?: number;
  20511. updatable?: boolean;
  20512. }, scene: Scene): Mesh;
  20513. /**
  20514. * Creates a decal mesh.
  20515. * Please consider using the same method from the MeshBuilder class instead.
  20516. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20517. * @param name defines the name of the mesh
  20518. * @param sourceMesh defines the mesh receiving the decal
  20519. * @param position sets the position of the decal in world coordinates
  20520. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20521. * @param size sets the decal scaling
  20522. * @param angle sets the angle to rotate the decal
  20523. * @returns a new Mesh
  20524. */
  20525. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20526. /**
  20527. * Prepare internal position array for software CPU skinning
  20528. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20529. */
  20530. setPositionsForCPUSkinning(): Float32Array;
  20531. /**
  20532. * Prepare internal normal array for software CPU skinning
  20533. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20534. */
  20535. setNormalsForCPUSkinning(): Float32Array;
  20536. /**
  20537. * Updates the vertex buffer by applying transformation from the bones
  20538. * @param skeleton defines the skeleton to apply to current mesh
  20539. * @returns the current mesh
  20540. */
  20541. applySkeleton(skeleton: Skeleton): Mesh;
  20542. /**
  20543. * 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
  20544. * @param meshes defines the list of meshes to scan
  20545. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20546. */
  20547. static MinMax(meshes: AbstractMesh[]): {
  20548. min: Vector3;
  20549. max: Vector3;
  20550. };
  20551. /**
  20552. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20553. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20554. * @returns a vector3
  20555. */
  20556. static Center(meshesOrMinMaxVector: {
  20557. min: Vector3;
  20558. max: Vector3;
  20559. } | AbstractMesh[]): Vector3;
  20560. /**
  20561. * Merge the array of meshes into a single mesh for performance reasons.
  20562. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20563. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20564. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20565. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20566. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20567. * @returns a new mesh
  20568. */
  20569. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20570. /** @hidden */
  20571. addInstance(instance: InstancedMesh): void;
  20572. /** @hidden */
  20573. removeInstance(instance: InstancedMesh): void;
  20574. }
  20575. }
  20576. declare module "babylonjs/Actions/action" {
  20577. import { Observable } from "babylonjs/Misc/observable";
  20578. import { Condition } from "babylonjs/Actions/condition";
  20579. import { ActionManager } from "babylonjs/Actions/actionManager";
  20580. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20581. /**
  20582. * The action to be carried out following a trigger
  20583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  20584. */
  20585. export class Action {
  20586. /** the trigger, with or without parameters, for the action */
  20587. triggerOptions: any;
  20588. /**
  20589. * Trigger for the action
  20590. */
  20591. trigger: number;
  20592. /**
  20593. * Internal only - manager for action
  20594. * @hidden
  20595. */
  20596. _actionManager: ActionManager;
  20597. private _nextActiveAction;
  20598. private _child;
  20599. private _condition?;
  20600. private _triggerParameter;
  20601. /**
  20602. * An event triggered prior to action being executed.
  20603. */
  20604. onBeforeExecuteObservable: Observable<Action>;
  20605. /**
  20606. * Creates a new Action
  20607. * @param triggerOptions the trigger, with or without parameters, for the action
  20608. * @param condition an optional determinant of action
  20609. */
  20610. constructor(
  20611. /** the trigger, with or without parameters, for the action */
  20612. triggerOptions: any, condition?: Condition);
  20613. /**
  20614. * Internal only
  20615. * @hidden
  20616. */
  20617. _prepare(): void;
  20618. /**
  20619. * Gets the trigger parameters
  20620. * @returns the trigger parameters
  20621. */
  20622. getTriggerParameter(): any;
  20623. /**
  20624. * Internal only - executes current action event
  20625. * @hidden
  20626. */
  20627. _executeCurrent(evt?: ActionEvent): void;
  20628. /**
  20629. * Execute placeholder for child classes
  20630. * @param evt optional action event
  20631. */
  20632. execute(evt?: ActionEvent): void;
  20633. /**
  20634. * Skips to next active action
  20635. */
  20636. skipToNextActiveAction(): void;
  20637. /**
  20638. * Adds action to chain of actions, may be a DoNothingAction
  20639. * @param action defines the next action to execute
  20640. * @returns The action passed in
  20641. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20642. */
  20643. then(action: Action): Action;
  20644. /**
  20645. * Internal only
  20646. * @hidden
  20647. */
  20648. _getProperty(propertyPath: string): string;
  20649. /**
  20650. * Internal only
  20651. * @hidden
  20652. */
  20653. _getEffectiveTarget(target: any, propertyPath: string): any;
  20654. /**
  20655. * Serialize placeholder for child classes
  20656. * @param parent of child
  20657. * @returns the serialized object
  20658. */
  20659. serialize(parent: any): any;
  20660. /**
  20661. * Internal only called by serialize
  20662. * @hidden
  20663. */
  20664. protected _serialize(serializedAction: any, parent?: any): any;
  20665. /**
  20666. * Internal only
  20667. * @hidden
  20668. */
  20669. static _SerializeValueAsString: (value: any) => string;
  20670. /**
  20671. * Internal only
  20672. * @hidden
  20673. */
  20674. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  20675. name: string;
  20676. targetType: string;
  20677. value: string;
  20678. };
  20679. }
  20680. }
  20681. declare module "babylonjs/Actions/condition" {
  20682. import { ActionManager } from "babylonjs/Actions/actionManager";
  20683. /**
  20684. * A Condition applied to an Action
  20685. */
  20686. export class Condition {
  20687. /**
  20688. * Internal only - manager for action
  20689. * @hidden
  20690. */
  20691. _actionManager: ActionManager;
  20692. /**
  20693. * Internal only
  20694. * @hidden
  20695. */
  20696. _evaluationId: number;
  20697. /**
  20698. * Internal only
  20699. * @hidden
  20700. */
  20701. _currentResult: boolean;
  20702. /**
  20703. * Creates a new Condition
  20704. * @param actionManager the manager of the action the condition is applied to
  20705. */
  20706. constructor(actionManager: ActionManager);
  20707. /**
  20708. * Check if the current condition is valid
  20709. * @returns a boolean
  20710. */
  20711. isValid(): boolean;
  20712. /**
  20713. * Internal only
  20714. * @hidden
  20715. */
  20716. _getProperty(propertyPath: string): string;
  20717. /**
  20718. * Internal only
  20719. * @hidden
  20720. */
  20721. _getEffectiveTarget(target: any, propertyPath: string): any;
  20722. /**
  20723. * Serialize placeholder for child classes
  20724. * @returns the serialized object
  20725. */
  20726. serialize(): any;
  20727. /**
  20728. * Internal only
  20729. * @hidden
  20730. */
  20731. protected _serialize(serializedCondition: any): any;
  20732. }
  20733. /**
  20734. * Defines specific conditional operators as extensions of Condition
  20735. */
  20736. export class ValueCondition extends Condition {
  20737. /** path to specify the property of the target the conditional operator uses */
  20738. propertyPath: string;
  20739. /** the value compared by the conditional operator against the current value of the property */
  20740. value: any;
  20741. /** the conditional operator, default ValueCondition.IsEqual */
  20742. operator: number;
  20743. /**
  20744. * Internal only
  20745. * @hidden
  20746. */
  20747. private static _IsEqual;
  20748. /**
  20749. * Internal only
  20750. * @hidden
  20751. */
  20752. private static _IsDifferent;
  20753. /**
  20754. * Internal only
  20755. * @hidden
  20756. */
  20757. private static _IsGreater;
  20758. /**
  20759. * Internal only
  20760. * @hidden
  20761. */
  20762. private static _IsLesser;
  20763. /**
  20764. * returns the number for IsEqual
  20765. */
  20766. static readonly IsEqual: number;
  20767. /**
  20768. * Returns the number for IsDifferent
  20769. */
  20770. static readonly IsDifferent: number;
  20771. /**
  20772. * Returns the number for IsGreater
  20773. */
  20774. static readonly IsGreater: number;
  20775. /**
  20776. * Returns the number for IsLesser
  20777. */
  20778. static readonly IsLesser: number;
  20779. /**
  20780. * Internal only The action manager for the condition
  20781. * @hidden
  20782. */
  20783. _actionManager: ActionManager;
  20784. /**
  20785. * Internal only
  20786. * @hidden
  20787. */
  20788. private _target;
  20789. /**
  20790. * Internal only
  20791. * @hidden
  20792. */
  20793. private _effectiveTarget;
  20794. /**
  20795. * Internal only
  20796. * @hidden
  20797. */
  20798. private _property;
  20799. /**
  20800. * Creates a new ValueCondition
  20801. * @param actionManager manager for the action the condition applies to
  20802. * @param target for the action
  20803. * @param propertyPath path to specify the property of the target the conditional operator uses
  20804. * @param value the value compared by the conditional operator against the current value of the property
  20805. * @param operator the conditional operator, default ValueCondition.IsEqual
  20806. */
  20807. constructor(actionManager: ActionManager, target: any,
  20808. /** path to specify the property of the target the conditional operator uses */
  20809. propertyPath: string,
  20810. /** the value compared by the conditional operator against the current value of the property */
  20811. value: any,
  20812. /** the conditional operator, default ValueCondition.IsEqual */
  20813. operator?: number);
  20814. /**
  20815. * Compares the given value with the property value for the specified conditional operator
  20816. * @returns the result of the comparison
  20817. */
  20818. isValid(): boolean;
  20819. /**
  20820. * Serialize the ValueCondition into a JSON compatible object
  20821. * @returns serialization object
  20822. */
  20823. serialize(): any;
  20824. /**
  20825. * Gets the name of the conditional operator for the ValueCondition
  20826. * @param operator the conditional operator
  20827. * @returns the name
  20828. */
  20829. static GetOperatorName(operator: number): string;
  20830. }
  20831. /**
  20832. * Defines a predicate condition as an extension of Condition
  20833. */
  20834. export class PredicateCondition extends Condition {
  20835. /** defines the predicate function used to validate the condition */
  20836. predicate: () => boolean;
  20837. /**
  20838. * Internal only - manager for action
  20839. * @hidden
  20840. */
  20841. _actionManager: ActionManager;
  20842. /**
  20843. * Creates a new PredicateCondition
  20844. * @param actionManager manager for the action the condition applies to
  20845. * @param predicate defines the predicate function used to validate the condition
  20846. */
  20847. constructor(actionManager: ActionManager,
  20848. /** defines the predicate function used to validate the condition */
  20849. predicate: () => boolean);
  20850. /**
  20851. * @returns the validity of the predicate condition
  20852. */
  20853. isValid(): boolean;
  20854. }
  20855. /**
  20856. * Defines a state condition as an extension of Condition
  20857. */
  20858. export class StateCondition extends Condition {
  20859. /** Value to compare with target state */
  20860. value: string;
  20861. /**
  20862. * Internal only - manager for action
  20863. * @hidden
  20864. */
  20865. _actionManager: ActionManager;
  20866. /**
  20867. * Internal only
  20868. * @hidden
  20869. */
  20870. private _target;
  20871. /**
  20872. * Creates a new StateCondition
  20873. * @param actionManager manager for the action the condition applies to
  20874. * @param target of the condition
  20875. * @param value to compare with target state
  20876. */
  20877. constructor(actionManager: ActionManager, target: any,
  20878. /** Value to compare with target state */
  20879. value: string);
  20880. /**
  20881. * Gets a boolean indicating if the current condition is met
  20882. * @returns the validity of the state
  20883. */
  20884. isValid(): boolean;
  20885. /**
  20886. * Serialize the StateCondition into a JSON compatible object
  20887. * @returns serialization object
  20888. */
  20889. serialize(): any;
  20890. }
  20891. }
  20892. declare module "babylonjs/Actions/directActions" {
  20893. import { Action } from "babylonjs/Actions/action";
  20894. import { Condition } from "babylonjs/Actions/condition";
  20895. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20896. /**
  20897. * This defines an action responsible to toggle a boolean once triggered.
  20898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20899. */
  20900. export class SwitchBooleanAction extends Action {
  20901. /**
  20902. * The path to the boolean property in the target object
  20903. */
  20904. propertyPath: string;
  20905. private _target;
  20906. private _effectiveTarget;
  20907. private _property;
  20908. /**
  20909. * Instantiate the action
  20910. * @param triggerOptions defines the trigger options
  20911. * @param target defines the object containing the boolean
  20912. * @param propertyPath defines the path to the boolean property in the target object
  20913. * @param condition defines the trigger related conditions
  20914. */
  20915. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20916. /** @hidden */
  20917. _prepare(): void;
  20918. /**
  20919. * Execute the action toggle the boolean value.
  20920. */
  20921. execute(): void;
  20922. /**
  20923. * Serializes the actions and its related information.
  20924. * @param parent defines the object to serialize in
  20925. * @returns the serialized object
  20926. */
  20927. serialize(parent: any): any;
  20928. }
  20929. /**
  20930. * This defines an action responsible to set a the state field of the target
  20931. * to a desired value once triggered.
  20932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20933. */
  20934. export class SetStateAction extends Action {
  20935. /**
  20936. * The value to store in the state field.
  20937. */
  20938. value: string;
  20939. private _target;
  20940. /**
  20941. * Instantiate the action
  20942. * @param triggerOptions defines the trigger options
  20943. * @param target defines the object containing the state property
  20944. * @param value defines the value to store in the state field
  20945. * @param condition defines the trigger related conditions
  20946. */
  20947. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  20948. /**
  20949. * Execute the action and store the value on the target state property.
  20950. */
  20951. execute(): void;
  20952. /**
  20953. * Serializes the actions and its related information.
  20954. * @param parent defines the object to serialize in
  20955. * @returns the serialized object
  20956. */
  20957. serialize(parent: any): any;
  20958. }
  20959. /**
  20960. * This defines an action responsible to set a property of the target
  20961. * to a desired value once triggered.
  20962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20963. */
  20964. export class SetValueAction extends Action {
  20965. /**
  20966. * The path of the property to set in the target.
  20967. */
  20968. propertyPath: string;
  20969. /**
  20970. * The value to set in the property
  20971. */
  20972. value: any;
  20973. private _target;
  20974. private _effectiveTarget;
  20975. private _property;
  20976. /**
  20977. * Instantiate the action
  20978. * @param triggerOptions defines the trigger options
  20979. * @param target defines the object containing the property
  20980. * @param propertyPath defines the path of the property to set in the target
  20981. * @param value defines the value to set in the property
  20982. * @param condition defines the trigger related conditions
  20983. */
  20984. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20985. /** @hidden */
  20986. _prepare(): void;
  20987. /**
  20988. * Execute the action and set the targetted property to the desired value.
  20989. */
  20990. execute(): void;
  20991. /**
  20992. * Serializes the actions and its related information.
  20993. * @param parent defines the object to serialize in
  20994. * @returns the serialized object
  20995. */
  20996. serialize(parent: any): any;
  20997. }
  20998. /**
  20999. * This defines an action responsible to increment the target value
  21000. * to a desired value once triggered.
  21001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21002. */
  21003. export class IncrementValueAction extends Action {
  21004. /**
  21005. * The path of the property to increment in the target.
  21006. */
  21007. propertyPath: string;
  21008. /**
  21009. * The value we should increment the property by.
  21010. */
  21011. value: any;
  21012. private _target;
  21013. private _effectiveTarget;
  21014. private _property;
  21015. /**
  21016. * Instantiate the action
  21017. * @param triggerOptions defines the trigger options
  21018. * @param target defines the object containing the property
  21019. * @param propertyPath defines the path of the property to increment in the target
  21020. * @param value defines the value value we should increment the property by
  21021. * @param condition defines the trigger related conditions
  21022. */
  21023. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  21024. /** @hidden */
  21025. _prepare(): void;
  21026. /**
  21027. * Execute the action and increment the target of the value amount.
  21028. */
  21029. execute(): void;
  21030. /**
  21031. * Serializes the actions and its related information.
  21032. * @param parent defines the object to serialize in
  21033. * @returns the serialized object
  21034. */
  21035. serialize(parent: any): any;
  21036. }
  21037. /**
  21038. * This defines an action responsible to start an animation once triggered.
  21039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21040. */
  21041. export class PlayAnimationAction extends Action {
  21042. /**
  21043. * Where the animation should start (animation frame)
  21044. */
  21045. from: number;
  21046. /**
  21047. * Where the animation should stop (animation frame)
  21048. */
  21049. to: number;
  21050. /**
  21051. * Define if the animation should loop or stop after the first play.
  21052. */
  21053. loop?: boolean;
  21054. private _target;
  21055. /**
  21056. * Instantiate the action
  21057. * @param triggerOptions defines the trigger options
  21058. * @param target defines the target animation or animation name
  21059. * @param from defines from where the animation should start (animation frame)
  21060. * @param end defines where the animation should stop (animation frame)
  21061. * @param loop defines if the animation should loop or stop after the first play
  21062. * @param condition defines the trigger related conditions
  21063. */
  21064. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  21065. /** @hidden */
  21066. _prepare(): void;
  21067. /**
  21068. * Execute the action and play the animation.
  21069. */
  21070. execute(): void;
  21071. /**
  21072. * Serializes the actions and its related information.
  21073. * @param parent defines the object to serialize in
  21074. * @returns the serialized object
  21075. */
  21076. serialize(parent: any): any;
  21077. }
  21078. /**
  21079. * This defines an action responsible to stop an animation once triggered.
  21080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21081. */
  21082. export class StopAnimationAction extends Action {
  21083. private _target;
  21084. /**
  21085. * Instantiate the action
  21086. * @param triggerOptions defines the trigger options
  21087. * @param target defines the target animation or animation name
  21088. * @param condition defines the trigger related conditions
  21089. */
  21090. constructor(triggerOptions: any, target: any, condition?: Condition);
  21091. /** @hidden */
  21092. _prepare(): void;
  21093. /**
  21094. * Execute the action and stop the animation.
  21095. */
  21096. execute(): void;
  21097. /**
  21098. * Serializes the actions and its related information.
  21099. * @param parent defines the object to serialize in
  21100. * @returns the serialized object
  21101. */
  21102. serialize(parent: any): any;
  21103. }
  21104. /**
  21105. * This defines an action responsible that does nothing once triggered.
  21106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21107. */
  21108. export class DoNothingAction extends Action {
  21109. /**
  21110. * Instantiate the action
  21111. * @param triggerOptions defines the trigger options
  21112. * @param condition defines the trigger related conditions
  21113. */
  21114. constructor(triggerOptions?: any, condition?: Condition);
  21115. /**
  21116. * Execute the action and do nothing.
  21117. */
  21118. execute(): void;
  21119. /**
  21120. * Serializes the actions and its related information.
  21121. * @param parent defines the object to serialize in
  21122. * @returns the serialized object
  21123. */
  21124. serialize(parent: any): any;
  21125. }
  21126. /**
  21127. * This defines an action responsible to trigger several actions once triggered.
  21128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21129. */
  21130. export class CombineAction extends Action {
  21131. /**
  21132. * The list of aggregated animations to run.
  21133. */
  21134. children: Action[];
  21135. /**
  21136. * Instantiate the action
  21137. * @param triggerOptions defines the trigger options
  21138. * @param children defines the list of aggregated animations to run
  21139. * @param condition defines the trigger related conditions
  21140. */
  21141. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  21142. /** @hidden */
  21143. _prepare(): void;
  21144. /**
  21145. * Execute the action and executes all the aggregated actions.
  21146. */
  21147. execute(evt: ActionEvent): void;
  21148. /**
  21149. * Serializes the actions and its related information.
  21150. * @param parent defines the object to serialize in
  21151. * @returns the serialized object
  21152. */
  21153. serialize(parent: any): any;
  21154. }
  21155. /**
  21156. * This defines an action responsible to run code (external event) once triggered.
  21157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21158. */
  21159. export class ExecuteCodeAction extends Action {
  21160. /**
  21161. * The callback function to run.
  21162. */
  21163. func: (evt: ActionEvent) => void;
  21164. /**
  21165. * Instantiate the action
  21166. * @param triggerOptions defines the trigger options
  21167. * @param func defines the callback function to run
  21168. * @param condition defines the trigger related conditions
  21169. */
  21170. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  21171. /**
  21172. * Execute the action and run the attached code.
  21173. */
  21174. execute(evt: ActionEvent): void;
  21175. }
  21176. /**
  21177. * This defines an action responsible to set the parent property of the target once triggered.
  21178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21179. */
  21180. export class SetParentAction extends Action {
  21181. private _parent;
  21182. private _target;
  21183. /**
  21184. * Instantiate the action
  21185. * @param triggerOptions defines the trigger options
  21186. * @param target defines the target containing the parent property
  21187. * @param parent defines from where the animation should start (animation frame)
  21188. * @param condition defines the trigger related conditions
  21189. */
  21190. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  21191. /** @hidden */
  21192. _prepare(): void;
  21193. /**
  21194. * Execute the action and set the parent property.
  21195. */
  21196. execute(): void;
  21197. /**
  21198. * Serializes the actions and its related information.
  21199. * @param parent defines the object to serialize in
  21200. * @returns the serialized object
  21201. */
  21202. serialize(parent: any): any;
  21203. }
  21204. }
  21205. declare module "babylonjs/Actions/actionManager" {
  21206. import { Nullable } from "babylonjs/types";
  21207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21208. import { Scene } from "babylonjs/scene";
  21209. import { Action } from "babylonjs/Actions/action";
  21210. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  21211. /**
  21212. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  21213. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  21214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21215. */
  21216. export class ActionManager {
  21217. /**
  21218. * Nothing
  21219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21220. */
  21221. static readonly NothingTrigger: number;
  21222. /**
  21223. * On pick
  21224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21225. */
  21226. static readonly OnPickTrigger: number;
  21227. /**
  21228. * On left pick
  21229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21230. */
  21231. static readonly OnLeftPickTrigger: number;
  21232. /**
  21233. * On right pick
  21234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21235. */
  21236. static readonly OnRightPickTrigger: number;
  21237. /**
  21238. * On center pick
  21239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21240. */
  21241. static readonly OnCenterPickTrigger: number;
  21242. /**
  21243. * On pick down
  21244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21245. */
  21246. static readonly OnPickDownTrigger: number;
  21247. /**
  21248. * On double pick
  21249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21250. */
  21251. static readonly OnDoublePickTrigger: number;
  21252. /**
  21253. * On pick up
  21254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21255. */
  21256. static readonly OnPickUpTrigger: number;
  21257. /**
  21258. * On pick out.
  21259. * This trigger will only be raised if you also declared a OnPickDown
  21260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21261. */
  21262. static readonly OnPickOutTrigger: number;
  21263. /**
  21264. * On long press
  21265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21266. */
  21267. static readonly OnLongPressTrigger: number;
  21268. /**
  21269. * On pointer over
  21270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21271. */
  21272. static readonly OnPointerOverTrigger: number;
  21273. /**
  21274. * On pointer out
  21275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21276. */
  21277. static readonly OnPointerOutTrigger: number;
  21278. /**
  21279. * On every frame
  21280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21281. */
  21282. static readonly OnEveryFrameTrigger: number;
  21283. /**
  21284. * On intersection enter
  21285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21286. */
  21287. static readonly OnIntersectionEnterTrigger: number;
  21288. /**
  21289. * On intersection exit
  21290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21291. */
  21292. static readonly OnIntersectionExitTrigger: number;
  21293. /**
  21294. * On key down
  21295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21296. */
  21297. static readonly OnKeyDownTrigger: number;
  21298. /**
  21299. * On key up
  21300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21301. */
  21302. static readonly OnKeyUpTrigger: number;
  21303. /** Gets the list of active triggers */
  21304. static Triggers: {
  21305. [key: string]: number;
  21306. };
  21307. /** Gets the list of actions */
  21308. actions: Action[];
  21309. /** Gets the cursor to use when hovering items */
  21310. hoverCursor: string;
  21311. private _scene;
  21312. /**
  21313. * Creates a new action manager
  21314. * @param scene defines the hosting scene
  21315. */
  21316. constructor(scene: Scene);
  21317. /**
  21318. * Releases all associated resources
  21319. */
  21320. dispose(): void;
  21321. /**
  21322. * Gets hosting scene
  21323. * @returns the hosting scene
  21324. */
  21325. getScene(): Scene;
  21326. /**
  21327. * Does this action manager handles actions of any of the given triggers
  21328. * @param triggers defines the triggers to be tested
  21329. * @return a boolean indicating whether one (or more) of the triggers is handled
  21330. */
  21331. hasSpecificTriggers(triggers: number[]): boolean;
  21332. /**
  21333. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  21334. * speed.
  21335. * @param triggerA defines the trigger to be tested
  21336. * @param triggerB defines the trigger to be tested
  21337. * @return a boolean indicating whether one (or more) of the triggers is handled
  21338. */
  21339. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  21340. /**
  21341. * Does this action manager handles actions of a given trigger
  21342. * @param trigger defines the trigger to be tested
  21343. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  21344. * @return whether the trigger is handled
  21345. */
  21346. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  21347. /**
  21348. * Does this action manager has pointer triggers
  21349. */
  21350. readonly hasPointerTriggers: boolean;
  21351. /**
  21352. * Does this action manager has pick triggers
  21353. */
  21354. readonly hasPickTriggers: boolean;
  21355. /**
  21356. * Does exist one action manager with at least one trigger
  21357. **/
  21358. static readonly HasTriggers: boolean;
  21359. /**
  21360. * Does exist one action manager with at least one pick trigger
  21361. **/
  21362. static readonly HasPickTriggers: boolean;
  21363. /**
  21364. * Does exist one action manager that handles actions of a given trigger
  21365. * @param trigger defines the trigger to be tested
  21366. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  21367. **/
  21368. static HasSpecificTrigger(trigger: number): boolean;
  21369. /**
  21370. * Registers an action to this action manager
  21371. * @param action defines the action to be registered
  21372. * @return the action amended (prepared) after registration
  21373. */
  21374. registerAction(action: Action): Nullable<Action>;
  21375. /**
  21376. * Unregisters an action to this action manager
  21377. * @param action defines the action to be unregistered
  21378. * @return a boolean indicating whether the action has been unregistered
  21379. */
  21380. unregisterAction(action: Action): Boolean;
  21381. /**
  21382. * Process a specific trigger
  21383. * @param trigger defines the trigger to process
  21384. * @param evt defines the event details to be processed
  21385. */
  21386. processTrigger(trigger: number, evt?: ActionEvent): void;
  21387. /** @hidden */
  21388. _getEffectiveTarget(target: any, propertyPath: string): any;
  21389. /** @hidden */
  21390. _getProperty(propertyPath: string): string;
  21391. /**
  21392. * Serialize this manager to a JSON object
  21393. * @param name defines the property name to store this manager
  21394. * @returns a JSON representation of this manager
  21395. */
  21396. serialize(name: string): any;
  21397. /**
  21398. * Creates a new ActionManager from a JSON data
  21399. * @param parsedActions defines the JSON data to read from
  21400. * @param object defines the hosting mesh
  21401. * @param scene defines the hosting scene
  21402. */
  21403. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  21404. /**
  21405. * Get a trigger name by index
  21406. * @param trigger defines the trigger index
  21407. * @returns a trigger name
  21408. */
  21409. static GetTriggerName(trigger: number): string;
  21410. }
  21411. }
  21412. declare module "babylonjs/Sprites/sprite" {
  21413. import { Vector3, Color4 } from "babylonjs/Maths/math";
  21414. import { Nullable } from "babylonjs/types";
  21415. import { ActionManager } from "babylonjs/Actions/actionManager";
  21416. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21417. /**
  21418. * Class used to represent a sprite
  21419. * @see http://doc.babylonjs.com/babylon101/sprites
  21420. */
  21421. export class Sprite {
  21422. /** defines the name */
  21423. name: string;
  21424. /** Gets or sets the current world position */
  21425. position: Vector3;
  21426. /** Gets or sets the main color */
  21427. color: Color4;
  21428. /** Gets or sets the width */
  21429. width: number;
  21430. /** Gets or sets the height */
  21431. height: number;
  21432. /** Gets or sets rotation angle */
  21433. angle: number;
  21434. /** Gets or sets the cell index in the sprite sheet */
  21435. cellIndex: number;
  21436. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  21437. invertU: number;
  21438. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  21439. invertV: number;
  21440. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  21441. disposeWhenFinishedAnimating: boolean;
  21442. /** Gets the list of attached animations */
  21443. animations: Animation[];
  21444. /** Gets or sets a boolean indicating if the sprite can be picked */
  21445. isPickable: boolean;
  21446. /**
  21447. * Gets or sets the associated action manager
  21448. */
  21449. actionManager: Nullable<ActionManager>;
  21450. private _animationStarted;
  21451. private _loopAnimation;
  21452. private _fromIndex;
  21453. private _toIndex;
  21454. private _delay;
  21455. private _direction;
  21456. private _manager;
  21457. private _time;
  21458. private _onAnimationEnd;
  21459. /**
  21460. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  21461. */
  21462. isVisible: boolean;
  21463. /**
  21464. * Gets or sets the sprite size
  21465. */
  21466. size: number;
  21467. /**
  21468. * Creates a new Sprite
  21469. * @param name defines the name
  21470. * @param manager defines the manager
  21471. */
  21472. constructor(
  21473. /** defines the name */
  21474. name: string, manager: ISpriteManager);
  21475. /**
  21476. * Starts an animation
  21477. * @param from defines the initial key
  21478. * @param to defines the end key
  21479. * @param loop defines if the animation must loop
  21480. * @param delay defines the start delay (in ms)
  21481. * @param onAnimationEnd defines a callback to call when animation ends
  21482. */
  21483. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  21484. /** Stops current animation (if any) */
  21485. stopAnimation(): void;
  21486. /** @hidden */
  21487. _animate(deltaTime: number): void;
  21488. /** Release associated resources */
  21489. dispose(): void;
  21490. }
  21491. }
  21492. declare module "babylonjs/Collisions/pickingInfo" {
  21493. import { Nullable } from "babylonjs/types";
  21494. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21496. import { Ray } from "babylonjs/Culling/ray";
  21497. import { Sprite } from "babylonjs/Sprites/sprite";
  21498. /**
  21499. * Information about the result of picking within a scene
  21500. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  21501. */
  21502. export class PickingInfo {
  21503. /**
  21504. * If the pick collided with an object
  21505. */
  21506. hit: boolean;
  21507. /**
  21508. * Distance away where the pick collided
  21509. */
  21510. distance: number;
  21511. /**
  21512. * The location of pick collision
  21513. */
  21514. pickedPoint: Nullable<Vector3>;
  21515. /**
  21516. * The mesh corresponding the the pick collision
  21517. */
  21518. pickedMesh: Nullable<AbstractMesh>;
  21519. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  21520. bu: number;
  21521. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  21522. bv: number;
  21523. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  21524. faceId: number;
  21525. /** Id of the the submesh that was picked */
  21526. subMeshId: number;
  21527. /** If a sprite was picked, this will be the sprite the pick collided with */
  21528. pickedSprite: Nullable<Sprite>;
  21529. /**
  21530. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  21531. */
  21532. originMesh: Nullable<AbstractMesh>;
  21533. /**
  21534. * The ray that was used to perform the picking.
  21535. */
  21536. ray: Nullable<Ray>;
  21537. /**
  21538. * Gets the normal correspodning to the face the pick collided with
  21539. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  21540. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  21541. * @returns The normal correspodning to the face the pick collided with
  21542. */
  21543. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  21544. /**
  21545. * Gets the texture coordinates of where the pick occured
  21546. * @returns the vector containing the coordnates of the texture
  21547. */
  21548. getTextureCoordinates(): Nullable<Vector2>;
  21549. }
  21550. }
  21551. declare module "babylonjs/Culling/ray" {
  21552. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  21553. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21555. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  21556. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21557. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  21558. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21559. /**
  21560. * Class representing a ray with position and direction
  21561. */
  21562. export class Ray {
  21563. /** origin point */
  21564. origin: Vector3;
  21565. /** direction */
  21566. direction: Vector3;
  21567. /** length of the ray */
  21568. length: number;
  21569. private static readonly TmpVector3;
  21570. private _tmpRay;
  21571. /**
  21572. * Creates a new ray
  21573. * @param origin origin point
  21574. * @param direction direction
  21575. * @param length length of the ray
  21576. */
  21577. constructor(
  21578. /** origin point */
  21579. origin: Vector3,
  21580. /** direction */
  21581. direction: Vector3,
  21582. /** length of the ray */
  21583. length?: number);
  21584. /**
  21585. * Checks if the ray intersects a box
  21586. * @param minimum bound of the box
  21587. * @param maximum bound of the box
  21588. * @param intersectionTreshold extra extend to be added to the box in all direction
  21589. * @returns if the box was hit
  21590. */
  21591. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21592. /**
  21593. * Checks if the ray intersects a box
  21594. * @param box the bounding box to check
  21595. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21596. * @returns if the box was hit
  21597. */
  21598. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21599. /**
  21600. * If the ray hits a sphere
  21601. * @param sphere the bounding sphere to check
  21602. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21603. * @returns true if it hits the sphere
  21604. */
  21605. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21606. /**
  21607. * If the ray hits a triange
  21608. * @param vertex0 triangle vertex
  21609. * @param vertex1 triangle vertex
  21610. * @param vertex2 triangle vertex
  21611. * @returns intersection information if hit
  21612. */
  21613. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21614. /**
  21615. * Checks if ray intersects a plane
  21616. * @param plane the plane to check
  21617. * @returns the distance away it was hit
  21618. */
  21619. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21620. /**
  21621. * Checks if ray intersects a mesh
  21622. * @param mesh the mesh to check
  21623. * @param fastCheck if only the bounding box should checked
  21624. * @returns picking info of the intersecton
  21625. */
  21626. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21627. /**
  21628. * Checks if ray intersects a mesh
  21629. * @param meshes the meshes to check
  21630. * @param fastCheck if only the bounding box should checked
  21631. * @param results array to store result in
  21632. * @returns Array of picking infos
  21633. */
  21634. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21635. private _comparePickingInfo;
  21636. private static smallnum;
  21637. private static rayl;
  21638. /**
  21639. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21640. * @param sega the first point of the segment to test the intersection against
  21641. * @param segb the second point of the segment to test the intersection against
  21642. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21643. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21644. */
  21645. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21646. /**
  21647. * Update the ray from viewport position
  21648. * @param x position
  21649. * @param y y position
  21650. * @param viewportWidth viewport width
  21651. * @param viewportHeight viewport height
  21652. * @param world world matrix
  21653. * @param view view matrix
  21654. * @param projection projection matrix
  21655. * @returns this ray updated
  21656. */
  21657. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21658. /**
  21659. * Creates a ray with origin and direction of 0,0,0
  21660. * @returns the new ray
  21661. */
  21662. static Zero(): Ray;
  21663. /**
  21664. * Creates a new ray from screen space and viewport
  21665. * @param x position
  21666. * @param y y position
  21667. * @param viewportWidth viewport width
  21668. * @param viewportHeight viewport height
  21669. * @param world world matrix
  21670. * @param view view matrix
  21671. * @param projection projection matrix
  21672. * @returns new ray
  21673. */
  21674. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21675. /**
  21676. * 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
  21677. * transformed to the given world matrix.
  21678. * @param origin The origin point
  21679. * @param end The end point
  21680. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21681. * @returns the new ray
  21682. */
  21683. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21684. /**
  21685. * Transforms a ray by a matrix
  21686. * @param ray ray to transform
  21687. * @param matrix matrix to apply
  21688. * @returns the resulting new ray
  21689. */
  21690. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21691. /**
  21692. * Transforms a ray by a matrix
  21693. * @param ray ray to transform
  21694. * @param matrix matrix to apply
  21695. * @param result ray to store result in
  21696. */
  21697. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21698. /**
  21699. * Unproject a ray from screen space to object space
  21700. * @param sourceX defines the screen space x coordinate to use
  21701. * @param sourceY defines the screen space y coordinate to use
  21702. * @param viewportWidth defines the current width of the viewport
  21703. * @param viewportHeight defines the current height of the viewport
  21704. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21705. * @param view defines the view matrix to use
  21706. * @param projection defines the projection matrix to use
  21707. */
  21708. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21709. }
  21710. }
  21711. declare module "babylonjs/Materials/multiMaterial" {
  21712. import { Nullable } from "babylonjs/types";
  21713. import { Scene } from "babylonjs/scene";
  21714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21715. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21717. import { Material } from "babylonjs/Materials/material";
  21718. /**
  21719. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21720. * separate meshes. This can be use to improve performances.
  21721. * @see http://doc.babylonjs.com/how_to/multi_materials
  21722. */
  21723. export class MultiMaterial extends Material {
  21724. private _subMaterials;
  21725. /**
  21726. * Gets or Sets the list of Materials used within the multi material.
  21727. * They need to be ordered according to the submeshes order in the associated mesh
  21728. */
  21729. subMaterials: Nullable<Material>[];
  21730. /**
  21731. * Function used to align with Node.getChildren()
  21732. * @returns the list of Materials used within the multi material
  21733. */
  21734. getChildren(): Nullable<Material>[];
  21735. /**
  21736. * Instantiates a new Multi Material
  21737. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21738. * separate meshes. This can be use to improve performances.
  21739. * @see http://doc.babylonjs.com/how_to/multi_materials
  21740. * @param name Define the name in the scene
  21741. * @param scene Define the scene the material belongs to
  21742. */
  21743. constructor(name: string, scene: Scene);
  21744. private _hookArray;
  21745. /**
  21746. * Get one of the submaterial by its index in the submaterials array
  21747. * @param index The index to look the sub material at
  21748. * @returns The Material if the index has been defined
  21749. */
  21750. getSubMaterial(index: number): Nullable<Material>;
  21751. /**
  21752. * Get the list of active textures for the whole sub materials list.
  21753. * @returns All the textures that will be used during the rendering
  21754. */
  21755. getActiveTextures(): BaseTexture[];
  21756. /**
  21757. * Gets the current class name of the material e.g. "MultiMaterial"
  21758. * Mainly use in serialization.
  21759. * @returns the class name
  21760. */
  21761. getClassName(): string;
  21762. /**
  21763. * Checks if the material is ready to render the requested sub mesh
  21764. * @param mesh Define the mesh the submesh belongs to
  21765. * @param subMesh Define the sub mesh to look readyness for
  21766. * @param useInstances Define whether or not the material is used with instances
  21767. * @returns true if ready, otherwise false
  21768. */
  21769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21770. /**
  21771. * Clones the current material and its related sub materials
  21772. * @param name Define the name of the newly cloned material
  21773. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21774. * @returns the cloned material
  21775. */
  21776. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21777. /**
  21778. * Serializes the materials into a JSON representation.
  21779. * @returns the JSON representation
  21780. */
  21781. serialize(): any;
  21782. /**
  21783. * Dispose the material and release its associated resources
  21784. * @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)
  21785. * @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)
  21786. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21787. */
  21788. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21789. /**
  21790. * Creates a MultiMaterial from parsed MultiMaterial data.
  21791. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21792. * @param scene defines the hosting scene
  21793. * @returns a new MultiMaterial
  21794. */
  21795. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21796. }
  21797. }
  21798. declare module "babylonjs/Meshes/subMesh" {
  21799. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21800. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21801. import { Engine } from "babylonjs/Engines/engine";
  21802. import { Collider } from "babylonjs/Collisions/collider";
  21803. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21804. import { Ray } from "babylonjs/Culling/ray";
  21805. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21806. import { Effect } from "babylonjs/Materials/effect";
  21807. import { Material } from "babylonjs/Materials/material";
  21808. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21810. import { Mesh } from "babylonjs/Meshes/mesh";
  21811. /**
  21812. * Base class for submeshes
  21813. */
  21814. export class BaseSubMesh {
  21815. /** @hidden */
  21816. _materialDefines: Nullable<MaterialDefines>;
  21817. /** @hidden */
  21818. _materialEffect: Nullable<Effect>;
  21819. /**
  21820. * Gets associated effect
  21821. */
  21822. readonly effect: Nullable<Effect>;
  21823. /**
  21824. * Sets associated effect (effect used to render this submesh)
  21825. * @param effect defines the effect to associate with
  21826. * @param defines defines the set of defines used to compile this effect
  21827. */
  21828. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21829. }
  21830. /**
  21831. * Defines a subdivision inside a mesh
  21832. */
  21833. export class SubMesh extends BaseSubMesh implements ICullable {
  21834. /** the material index to use */
  21835. materialIndex: number;
  21836. /** vertex index start */
  21837. verticesStart: number;
  21838. /** vertices count */
  21839. verticesCount: number;
  21840. /** index start */
  21841. indexStart: number;
  21842. /** indices count */
  21843. indexCount: number;
  21844. /** @hidden */
  21845. _linesIndexCount: number;
  21846. private _mesh;
  21847. private _renderingMesh;
  21848. private _boundingInfo;
  21849. private _linesIndexBuffer;
  21850. /** @hidden */
  21851. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21852. /** @hidden */
  21853. _trianglePlanes: Plane[];
  21854. /** @hidden */
  21855. _lastColliderTransformMatrix: Matrix;
  21856. /** @hidden */
  21857. _renderId: number;
  21858. /** @hidden */
  21859. _alphaIndex: number;
  21860. /** @hidden */
  21861. _distanceToCamera: number;
  21862. /** @hidden */
  21863. _id: number;
  21864. private _currentMaterial;
  21865. /**
  21866. * Add a new submesh to a mesh
  21867. * @param materialIndex defines the material index to use
  21868. * @param verticesStart defines vertex index start
  21869. * @param verticesCount defines vertices count
  21870. * @param indexStart defines index start
  21871. * @param indexCount defines indices count
  21872. * @param mesh defines the parent mesh
  21873. * @param renderingMesh defines an optional rendering mesh
  21874. * @param createBoundingBox defines if bounding box should be created for this submesh
  21875. * @returns the new submesh
  21876. */
  21877. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21878. /**
  21879. * Creates a new submesh
  21880. * @param materialIndex defines the material index to use
  21881. * @param verticesStart defines vertex index start
  21882. * @param verticesCount defines vertices count
  21883. * @param indexStart defines index start
  21884. * @param indexCount defines indices count
  21885. * @param mesh defines the parent mesh
  21886. * @param renderingMesh defines an optional rendering mesh
  21887. * @param createBoundingBox defines if bounding box should be created for this submesh
  21888. */
  21889. constructor(
  21890. /** the material index to use */
  21891. materialIndex: number,
  21892. /** vertex index start */
  21893. verticesStart: number,
  21894. /** vertices count */
  21895. verticesCount: number,
  21896. /** index start */
  21897. indexStart: number,
  21898. /** indices count */
  21899. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21900. /**
  21901. * Returns true if this submesh covers the entire parent mesh
  21902. * @ignorenaming
  21903. */
  21904. readonly IsGlobal: boolean;
  21905. /**
  21906. * Returns the submesh BoudingInfo object
  21907. * @returns current bounding info (or mesh's one if the submesh is global)
  21908. */
  21909. getBoundingInfo(): BoundingInfo;
  21910. /**
  21911. * Sets the submesh BoundingInfo
  21912. * @param boundingInfo defines the new bounding info to use
  21913. * @returns the SubMesh
  21914. */
  21915. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21916. /**
  21917. * Returns the mesh of the current submesh
  21918. * @return the parent mesh
  21919. */
  21920. getMesh(): AbstractMesh;
  21921. /**
  21922. * Returns the rendering mesh of the submesh
  21923. * @returns the rendering mesh (could be different from parent mesh)
  21924. */
  21925. getRenderingMesh(): Mesh;
  21926. /**
  21927. * Returns the submesh material
  21928. * @returns null or the current material
  21929. */
  21930. getMaterial(): Nullable<Material>;
  21931. /**
  21932. * Sets a new updated BoundingInfo object to the submesh
  21933. * @returns the SubMesh
  21934. */
  21935. refreshBoundingInfo(): SubMesh;
  21936. /** @hidden */
  21937. _checkCollision(collider: Collider): boolean;
  21938. /**
  21939. * Updates the submesh BoundingInfo
  21940. * @param world defines the world matrix to use to update the bounding info
  21941. * @returns the submesh
  21942. */
  21943. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21944. /**
  21945. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21946. * @param frustumPlanes defines the frustum planes
  21947. * @returns true if the submesh is intersecting with the frustum
  21948. */
  21949. isInFrustum(frustumPlanes: Plane[]): boolean;
  21950. /**
  21951. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21952. * @param frustumPlanes defines the frustum planes
  21953. * @returns true if the submesh is inside the frustum
  21954. */
  21955. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21956. /**
  21957. * Renders the submesh
  21958. * @param enableAlphaMode defines if alpha needs to be used
  21959. * @returns the submesh
  21960. */
  21961. render(enableAlphaMode: boolean): SubMesh;
  21962. /**
  21963. * @hidden
  21964. */
  21965. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21966. /**
  21967. * Checks if the submesh intersects with a ray
  21968. * @param ray defines the ray to test
  21969. * @returns true is the passed ray intersects the submesh bounding box
  21970. */
  21971. canIntersects(ray: Ray): boolean;
  21972. /**
  21973. * Intersects current submesh with a ray
  21974. * @param ray defines the ray to test
  21975. * @param positions defines mesh's positions array
  21976. * @param indices defines mesh's indices array
  21977. * @param fastCheck defines if only bounding info should be used
  21978. * @returns intersection info or null if no intersection
  21979. */
  21980. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21981. /** @hidden */
  21982. private _intersectLines;
  21983. /** @hidden */
  21984. private _intersectTriangles;
  21985. /** @hidden */
  21986. _rebuild(): void;
  21987. /**
  21988. * Creates a new submesh from the passed mesh
  21989. * @param newMesh defines the new hosting mesh
  21990. * @param newRenderingMesh defines an optional rendering mesh
  21991. * @returns the new submesh
  21992. */
  21993. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21994. /**
  21995. * Release associated resources
  21996. */
  21997. dispose(): void;
  21998. /**
  21999. * Gets the class name
  22000. * @returns the string "SubMesh".
  22001. */
  22002. getClassName(): string;
  22003. /**
  22004. * Creates a new submesh from indices data
  22005. * @param materialIndex the index of the main mesh material
  22006. * @param startIndex the index where to start the copy in the mesh indices array
  22007. * @param indexCount the number of indices to copy then from the startIndex
  22008. * @param mesh the main mesh to create the submesh from
  22009. * @param renderingMesh the optional rendering mesh
  22010. * @returns a new submesh
  22011. */
  22012. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22013. }
  22014. }
  22015. declare module "babylonjs/Meshes/geometry" {
  22016. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22017. import { Scene } from "babylonjs/scene";
  22018. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22019. import { Engine } from "babylonjs/Engines/engine";
  22020. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22021. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22022. import { Effect } from "babylonjs/Materials/effect";
  22023. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22024. import { Mesh } from "babylonjs/Meshes/mesh";
  22025. /**
  22026. * Class used to store geometry data (vertex buffers + index buffer)
  22027. */
  22028. export class Geometry implements IGetSetVerticesData {
  22029. /**
  22030. * Gets or sets the ID of the geometry
  22031. */
  22032. id: string;
  22033. /**
  22034. * Gets or sets the unique ID of the geometry
  22035. */
  22036. uniqueId: number;
  22037. /**
  22038. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22039. */
  22040. delayLoadState: number;
  22041. /**
  22042. * Gets the file containing the data to load when running in delay load state
  22043. */
  22044. delayLoadingFile: Nullable<string>;
  22045. /**
  22046. * Callback called when the geometry is updated
  22047. */
  22048. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22049. private _scene;
  22050. private _engine;
  22051. private _meshes;
  22052. private _totalVertices;
  22053. /** @hidden */
  22054. _indices: IndicesArray;
  22055. /** @hidden */
  22056. _vertexBuffers: {
  22057. [key: string]: VertexBuffer;
  22058. };
  22059. private _isDisposed;
  22060. private _extend;
  22061. private _boundingBias;
  22062. /** @hidden */
  22063. _delayInfo: Array<string>;
  22064. private _indexBuffer;
  22065. private _indexBufferIsUpdatable;
  22066. /** @hidden */
  22067. _boundingInfo: Nullable<BoundingInfo>;
  22068. /** @hidden */
  22069. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22070. /** @hidden */
  22071. _softwareSkinningFrameId: number;
  22072. private _vertexArrayObjects;
  22073. private _updatable;
  22074. /** @hidden */
  22075. _positions: Nullable<Vector3[]>;
  22076. /**
  22077. * 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
  22078. */
  22079. /**
  22080. * 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
  22081. */
  22082. boundingBias: Vector2;
  22083. /**
  22084. * Static function used to attach a new empty geometry to a mesh
  22085. * @param mesh defines the mesh to attach the geometry to
  22086. * @returns the new Geometry
  22087. */
  22088. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22089. /**
  22090. * Creates a new geometry
  22091. * @param id defines the unique ID
  22092. * @param scene defines the hosting scene
  22093. * @param vertexData defines the VertexData used to get geometry data
  22094. * @param updatable defines if geometry must be updatable (false by default)
  22095. * @param mesh defines the mesh that will be associated with the geometry
  22096. */
  22097. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22098. /**
  22099. * Gets the current extend of the geometry
  22100. */
  22101. readonly extend: {
  22102. minimum: Vector3;
  22103. maximum: Vector3;
  22104. };
  22105. /**
  22106. * Gets the hosting scene
  22107. * @returns the hosting Scene
  22108. */
  22109. getScene(): Scene;
  22110. /**
  22111. * Gets the hosting engine
  22112. * @returns the hosting Engine
  22113. */
  22114. getEngine(): Engine;
  22115. /**
  22116. * Defines if the geometry is ready to use
  22117. * @returns true if the geometry is ready to be used
  22118. */
  22119. isReady(): boolean;
  22120. /**
  22121. * Gets a value indicating that the geometry should not be serialized
  22122. */
  22123. readonly doNotSerialize: boolean;
  22124. /** @hidden */
  22125. _rebuild(): void;
  22126. /**
  22127. * Affects all geometry data in one call
  22128. * @param vertexData defines the geometry data
  22129. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22130. */
  22131. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22132. /**
  22133. * Set specific vertex data
  22134. * @param kind defines the data kind (Position, normal, etc...)
  22135. * @param data defines the vertex data to use
  22136. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22137. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22138. */
  22139. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22140. /**
  22141. * Removes a specific vertex data
  22142. * @param kind defines the data kind (Position, normal, etc...)
  22143. */
  22144. removeVerticesData(kind: string): void;
  22145. /**
  22146. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22147. * @param buffer defines the vertex buffer to use
  22148. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22149. */
  22150. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22151. /**
  22152. * Update a specific vertex buffer
  22153. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22154. * It will do nothing if the buffer is not updatable
  22155. * @param kind defines the data kind (Position, normal, etc...)
  22156. * @param data defines the data to use
  22157. * @param offset defines the offset in the target buffer where to store the data
  22158. * @param useBytes set to true if the offset is in bytes
  22159. */
  22160. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22161. /**
  22162. * Update a specific vertex buffer
  22163. * This function will create a new buffer if the current one is not updatable
  22164. * @param kind defines the data kind (Position, normal, etc...)
  22165. * @param data defines the data to use
  22166. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22167. */
  22168. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22169. private _updateBoundingInfo;
  22170. /** @hidden */
  22171. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22172. /**
  22173. * Gets total number of vertices
  22174. * @returns the total number of vertices
  22175. */
  22176. getTotalVertices(): number;
  22177. /**
  22178. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22179. * @param kind defines the data kind (Position, normal, etc...)
  22180. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22181. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22182. * @returns a float array containing vertex data
  22183. */
  22184. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22185. /**
  22186. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22187. * @param kind defines the data kind (Position, normal, etc...)
  22188. * @returns true if the vertex buffer with the specified kind is updatable
  22189. */
  22190. isVertexBufferUpdatable(kind: string): boolean;
  22191. /**
  22192. * Gets a specific vertex buffer
  22193. * @param kind defines the data kind (Position, normal, etc...)
  22194. * @returns a VertexBuffer
  22195. */
  22196. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22197. /**
  22198. * Returns all vertex buffers
  22199. * @return an object holding all vertex buffers indexed by kind
  22200. */
  22201. getVertexBuffers(): Nullable<{
  22202. [key: string]: VertexBuffer;
  22203. }>;
  22204. /**
  22205. * Gets a boolean indicating if specific vertex buffer is present
  22206. * @param kind defines the data kind (Position, normal, etc...)
  22207. * @returns true if data is present
  22208. */
  22209. isVerticesDataPresent(kind: string): boolean;
  22210. /**
  22211. * Gets a list of all attached data kinds (Position, normal, etc...)
  22212. * @returns a list of string containing all kinds
  22213. */
  22214. getVerticesDataKinds(): string[];
  22215. /**
  22216. * Update index buffer
  22217. * @param indices defines the indices to store in the index buffer
  22218. * @param offset defines the offset in the target buffer where to store the data
  22219. */
  22220. updateIndices(indices: IndicesArray, offset?: number): void;
  22221. /**
  22222. * Creates a new index buffer
  22223. * @param indices defines the indices to store in the index buffer
  22224. * @param totalVertices defines the total number of vertices (could be null)
  22225. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22226. */
  22227. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22228. /**
  22229. * Return the total number of indices
  22230. * @returns the total number of indices
  22231. */
  22232. getTotalIndices(): number;
  22233. /**
  22234. * Gets the index buffer array
  22235. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22236. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22237. * @returns the index buffer array
  22238. */
  22239. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22240. /**
  22241. * Gets the index buffer
  22242. * @return the index buffer
  22243. */
  22244. getIndexBuffer(): Nullable<WebGLBuffer>;
  22245. /** @hidden */
  22246. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22247. /**
  22248. * Release the associated resources for a specific mesh
  22249. * @param mesh defines the source mesh
  22250. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22251. */
  22252. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22253. /**
  22254. * Apply current geometry to a given mesh
  22255. * @param mesh defines the mesh to apply geometry to
  22256. */
  22257. applyToMesh(mesh: Mesh): void;
  22258. private _updateExtend;
  22259. private _applyToMesh;
  22260. private notifyUpdate;
  22261. /**
  22262. * Load the geometry if it was flagged as delay loaded
  22263. * @param scene defines the hosting scene
  22264. * @param onLoaded defines a callback called when the geometry is loaded
  22265. */
  22266. load(scene: Scene, onLoaded?: () => void): void;
  22267. private _queueLoad;
  22268. /**
  22269. * Invert the geometry to move from a right handed system to a left handed one.
  22270. */
  22271. toLeftHanded(): void;
  22272. /** @hidden */
  22273. _resetPointsArrayCache(): void;
  22274. /** @hidden */
  22275. _generatePointsArray(): boolean;
  22276. /**
  22277. * Gets a value indicating if the geometry is disposed
  22278. * @returns true if the geometry was disposed
  22279. */
  22280. isDisposed(): boolean;
  22281. private _disposeVertexArrayObjects;
  22282. /**
  22283. * Free all associated resources
  22284. */
  22285. dispose(): void;
  22286. /**
  22287. * Clone the current geometry into a new geometry
  22288. * @param id defines the unique ID of the new geometry
  22289. * @returns a new geometry object
  22290. */
  22291. copy(id: string): Geometry;
  22292. /**
  22293. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22294. * @return a JSON representation of the current geometry data (without the vertices data)
  22295. */
  22296. serialize(): any;
  22297. private toNumberArray;
  22298. /**
  22299. * Serialize all vertices data into a JSON oject
  22300. * @returns a JSON representation of the current geometry data
  22301. */
  22302. serializeVerticeData(): any;
  22303. /**
  22304. * Extracts a clone of a mesh geometry
  22305. * @param mesh defines the source mesh
  22306. * @param id defines the unique ID of the new geometry object
  22307. * @returns the new geometry object
  22308. */
  22309. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22310. /**
  22311. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22312. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22313. * Be aware Math.random() could cause collisions, but:
  22314. * "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"
  22315. * @returns a string containing a new GUID
  22316. */
  22317. static RandomId(): string;
  22318. /** @hidden */
  22319. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22320. private static _CleanMatricesWeights;
  22321. /**
  22322. * Create a new geometry from persisted data (Using .babylon file format)
  22323. * @param parsedVertexData defines the persisted data
  22324. * @param scene defines the hosting scene
  22325. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22326. * @returns the new geometry object
  22327. */
  22328. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22329. }
  22330. /**
  22331. * Abstract class used to provide common services for all typed geometries
  22332. * @hidden
  22333. */
  22334. export class _PrimitiveGeometry extends Geometry {
  22335. private _canBeRegenerated;
  22336. private _beingRegenerated;
  22337. /**
  22338. * Creates a new typed geometry
  22339. * @param id defines the unique ID of the geometry
  22340. * @param scene defines the hosting scene
  22341. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22342. * @param mesh defines the hosting mesh (can be null)
  22343. */
  22344. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22345. /**
  22346. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  22347. * @returns true if the geometry can be regenerated
  22348. */
  22349. canBeRegenerated(): boolean;
  22350. /**
  22351. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  22352. */
  22353. regenerate(): void;
  22354. /**
  22355. * Clone the geometry
  22356. * @param id defines the unique ID of the new geometry
  22357. * @returns the new geometry
  22358. */
  22359. asNewGeometry(id: string): Geometry;
  22360. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22361. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  22362. /** @hidden */
  22363. _regenerateVertexData(): VertexData;
  22364. copy(id: string): Geometry;
  22365. serialize(): any;
  22366. }
  22367. /**
  22368. * Creates a ribbon geometry
  22369. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  22370. */
  22371. export class RibbonGeometry extends _PrimitiveGeometry {
  22372. /**
  22373. * Defines the array of paths to use
  22374. */
  22375. pathArray: Vector3[][];
  22376. /**
  22377. * Defines if the last and first points of each path in your pathArray must be joined
  22378. */
  22379. closeArray: boolean;
  22380. /**
  22381. * Defines if the last and first points of each path in your pathArray must be joined
  22382. */
  22383. closePath: boolean;
  22384. /**
  22385. * Defines the offset between points
  22386. */
  22387. offset: number;
  22388. /**
  22389. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22390. */
  22391. side: number;
  22392. /**
  22393. * Creates a ribbon geometry
  22394. * @param id defines the unique ID of the geometry
  22395. * @param scene defines the hosting scene
  22396. * @param pathArray defines the array of paths to use
  22397. * @param closeArray defines if the last path and the first path must be joined
  22398. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  22399. * @param offset defines the offset between points
  22400. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22401. * @param mesh defines the hosting mesh (can be null)
  22402. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22403. */
  22404. constructor(id: string, scene: Scene,
  22405. /**
  22406. * Defines the array of paths to use
  22407. */
  22408. pathArray: Vector3[][],
  22409. /**
  22410. * Defines if the last and first points of each path in your pathArray must be joined
  22411. */
  22412. closeArray: boolean,
  22413. /**
  22414. * Defines if the last and first points of each path in your pathArray must be joined
  22415. */
  22416. closePath: boolean,
  22417. /**
  22418. * Defines the offset between points
  22419. */
  22420. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  22421. /**
  22422. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22423. */
  22424. side?: number);
  22425. /** @hidden */
  22426. _regenerateVertexData(): VertexData;
  22427. copy(id: string): Geometry;
  22428. }
  22429. /**
  22430. * Creates a box geometry
  22431. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  22432. */
  22433. export class BoxGeometry extends _PrimitiveGeometry {
  22434. /**
  22435. * Defines the zise of the box (width, height and depth are the same)
  22436. */
  22437. size: number;
  22438. /**
  22439. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22440. */
  22441. side: number;
  22442. /**
  22443. * Creates a box geometry
  22444. * @param id defines the unique ID of the geometry
  22445. * @param scene defines the hosting scene
  22446. * @param size defines the zise of the box (width, height and depth are the same)
  22447. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22448. * @param mesh defines the hosting mesh (can be null)
  22449. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22450. */
  22451. constructor(id: string, scene: Scene,
  22452. /**
  22453. * Defines the zise of the box (width, height and depth are the same)
  22454. */
  22455. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22456. /**
  22457. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22458. */
  22459. side?: number);
  22460. /** @hidden */
  22461. _regenerateVertexData(): VertexData;
  22462. copy(id: string): Geometry;
  22463. serialize(): any;
  22464. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  22465. }
  22466. /**
  22467. * Creates a sphere geometry
  22468. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  22469. */
  22470. export class SphereGeometry extends _PrimitiveGeometry {
  22471. /**
  22472. * Defines the number of segments to use to create the sphere
  22473. */
  22474. segments: number;
  22475. /**
  22476. * Defines the diameter of the sphere
  22477. */
  22478. diameter: number;
  22479. /**
  22480. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22481. */
  22482. side: number;
  22483. /**
  22484. * Create a new sphere geometry
  22485. * @param id defines the unique ID of the geometry
  22486. * @param scene defines the hosting scene
  22487. * @param segments defines the number of segments to use to create the sphere
  22488. * @param diameter defines the diameter of the sphere
  22489. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22490. * @param mesh defines the hosting mesh (can be null)
  22491. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22492. */
  22493. constructor(id: string, scene: Scene,
  22494. /**
  22495. * Defines the number of segments to use to create the sphere
  22496. */
  22497. segments: number,
  22498. /**
  22499. * Defines the diameter of the sphere
  22500. */
  22501. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22502. /**
  22503. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22504. */
  22505. side?: number);
  22506. /** @hidden */
  22507. _regenerateVertexData(): VertexData;
  22508. copy(id: string): Geometry;
  22509. serialize(): any;
  22510. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  22511. }
  22512. /**
  22513. * Creates a disc geometry
  22514. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22515. */
  22516. export class DiscGeometry extends _PrimitiveGeometry {
  22517. /**
  22518. * Defines the radius of the disc
  22519. */
  22520. radius: number;
  22521. /**
  22522. * Defines the tesselation factor to apply to the disc
  22523. */
  22524. tessellation: number;
  22525. /**
  22526. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22527. */
  22528. side: number;
  22529. /**
  22530. * Creates a new disc geometry
  22531. * @param id defines the unique ID of the geometry
  22532. * @param scene defines the hosting scene
  22533. * @param radius defines the radius of the disc
  22534. * @param tessellation defines the tesselation factor to apply to the disc
  22535. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22536. * @param mesh defines the hosting mesh (can be null)
  22537. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22538. */
  22539. constructor(id: string, scene: Scene,
  22540. /**
  22541. * Defines the radius of the disc
  22542. */
  22543. radius: number,
  22544. /**
  22545. * Defines the tesselation factor to apply to the disc
  22546. */
  22547. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22548. /**
  22549. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22550. */
  22551. side?: number);
  22552. /** @hidden */
  22553. _regenerateVertexData(): VertexData;
  22554. copy(id: string): Geometry;
  22555. }
  22556. /**
  22557. * Creates a new cylinder geometry
  22558. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22559. */
  22560. export class CylinderGeometry extends _PrimitiveGeometry {
  22561. /**
  22562. * Defines the height of the cylinder
  22563. */
  22564. height: number;
  22565. /**
  22566. * Defines the diameter of the cylinder's top cap
  22567. */
  22568. diameterTop: number;
  22569. /**
  22570. * Defines the diameter of the cylinder's bottom cap
  22571. */
  22572. diameterBottom: number;
  22573. /**
  22574. * Defines the tessellation factor to apply to the cylinder
  22575. */
  22576. tessellation: number;
  22577. /**
  22578. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22579. */
  22580. subdivisions: number;
  22581. /**
  22582. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22583. */
  22584. side: number;
  22585. /**
  22586. * Creates a new cylinder geometry
  22587. * @param id defines the unique ID of the geometry
  22588. * @param scene defines the hosting scene
  22589. * @param height defines the height of the cylinder
  22590. * @param diameterTop defines the diameter of the cylinder's top cap
  22591. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22592. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22593. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22594. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22595. * @param mesh defines the hosting mesh (can be null)
  22596. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22597. */
  22598. constructor(id: string, scene: Scene,
  22599. /**
  22600. * Defines the height of the cylinder
  22601. */
  22602. height: number,
  22603. /**
  22604. * Defines the diameter of the cylinder's top cap
  22605. */
  22606. diameterTop: number,
  22607. /**
  22608. * Defines the diameter of the cylinder's bottom cap
  22609. */
  22610. diameterBottom: number,
  22611. /**
  22612. * Defines the tessellation factor to apply to the cylinder
  22613. */
  22614. tessellation: number,
  22615. /**
  22616. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22617. */
  22618. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22619. /**
  22620. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22621. */
  22622. side?: number);
  22623. /** @hidden */
  22624. _regenerateVertexData(): VertexData;
  22625. copy(id: string): Geometry;
  22626. serialize(): any;
  22627. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22628. }
  22629. /**
  22630. * Creates a new torus geometry
  22631. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22632. */
  22633. export class TorusGeometry extends _PrimitiveGeometry {
  22634. /**
  22635. * Defines the diameter of the torus
  22636. */
  22637. diameter: number;
  22638. /**
  22639. * Defines the thickness of the torus (ie. internal diameter)
  22640. */
  22641. thickness: number;
  22642. /**
  22643. * Defines the tesselation factor to apply to the torus
  22644. */
  22645. tessellation: number;
  22646. /**
  22647. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22648. */
  22649. side: number;
  22650. /**
  22651. * Creates a new torus geometry
  22652. * @param id defines the unique ID of the geometry
  22653. * @param scene defines the hosting scene
  22654. * @param diameter defines the diameter of the torus
  22655. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22656. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22657. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22658. * @param mesh defines the hosting mesh (can be null)
  22659. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22660. */
  22661. constructor(id: string, scene: Scene,
  22662. /**
  22663. * Defines the diameter of the torus
  22664. */
  22665. diameter: number,
  22666. /**
  22667. * Defines the thickness of the torus (ie. internal diameter)
  22668. */
  22669. thickness: number,
  22670. /**
  22671. * Defines the tesselation factor to apply to the torus
  22672. */
  22673. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22674. /**
  22675. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22676. */
  22677. side?: number);
  22678. /** @hidden */
  22679. _regenerateVertexData(): VertexData;
  22680. copy(id: string): Geometry;
  22681. serialize(): any;
  22682. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22683. }
  22684. /**
  22685. * Creates a new ground geometry
  22686. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22687. */
  22688. export class GroundGeometry extends _PrimitiveGeometry {
  22689. /**
  22690. * Defines the width of the ground
  22691. */
  22692. width: number;
  22693. /**
  22694. * Defines the height of the ground
  22695. */
  22696. height: number;
  22697. /**
  22698. * Defines the subdivisions to apply to the ground
  22699. */
  22700. subdivisions: number;
  22701. /**
  22702. * Creates a new ground geometry
  22703. * @param id defines the unique ID of the geometry
  22704. * @param scene defines the hosting scene
  22705. * @param width defines the width of the ground
  22706. * @param height defines the height of the ground
  22707. * @param subdivisions defines the subdivisions to apply to the ground
  22708. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22709. * @param mesh defines the hosting mesh (can be null)
  22710. */
  22711. constructor(id: string, scene: Scene,
  22712. /**
  22713. * Defines the width of the ground
  22714. */
  22715. width: number,
  22716. /**
  22717. * Defines the height of the ground
  22718. */
  22719. height: number,
  22720. /**
  22721. * Defines the subdivisions to apply to the ground
  22722. */
  22723. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22724. /** @hidden */
  22725. _regenerateVertexData(): VertexData;
  22726. copy(id: string): Geometry;
  22727. serialize(): any;
  22728. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22729. }
  22730. /**
  22731. * Creates a tiled ground geometry
  22732. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22733. */
  22734. export class TiledGroundGeometry extends _PrimitiveGeometry {
  22735. /**
  22736. * Defines the minimum value on X axis
  22737. */
  22738. xmin: number;
  22739. /**
  22740. * Defines the minimum value on Z axis
  22741. */
  22742. zmin: number;
  22743. /**
  22744. * Defines the maximum value on X axis
  22745. */
  22746. xmax: number;
  22747. /**
  22748. * Defines the maximum value on Z axis
  22749. */
  22750. zmax: number;
  22751. /**
  22752. * Defines the subdivisions to apply to the ground
  22753. */
  22754. subdivisions: {
  22755. w: number;
  22756. h: number;
  22757. };
  22758. /**
  22759. * Defines the precision to use when computing the tiles
  22760. */
  22761. precision: {
  22762. w: number;
  22763. h: number;
  22764. };
  22765. /**
  22766. * Creates a tiled ground geometry
  22767. * @param id defines the unique ID of the geometry
  22768. * @param scene defines the hosting scene
  22769. * @param xmin defines the minimum value on X axis
  22770. * @param zmin defines the minimum value on Z axis
  22771. * @param xmax defines the maximum value on X axis
  22772. * @param zmax defines the maximum value on Z axis
  22773. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22774. * @param precision defines the precision to use when computing the tiles
  22775. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22776. * @param mesh defines the hosting mesh (can be null)
  22777. */
  22778. constructor(id: string, scene: Scene,
  22779. /**
  22780. * Defines the minimum value on X axis
  22781. */
  22782. xmin: number,
  22783. /**
  22784. * Defines the minimum value on Z axis
  22785. */
  22786. zmin: number,
  22787. /**
  22788. * Defines the maximum value on X axis
  22789. */
  22790. xmax: number,
  22791. /**
  22792. * Defines the maximum value on Z axis
  22793. */
  22794. zmax: number,
  22795. /**
  22796. * Defines the subdivisions to apply to the ground
  22797. */
  22798. subdivisions: {
  22799. w: number;
  22800. h: number;
  22801. },
  22802. /**
  22803. * Defines the precision to use when computing the tiles
  22804. */
  22805. precision: {
  22806. w: number;
  22807. h: number;
  22808. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22809. /** @hidden */
  22810. _regenerateVertexData(): VertexData;
  22811. copy(id: string): Geometry;
  22812. }
  22813. /**
  22814. * Creates a plane geometry
  22815. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22816. */
  22817. export class PlaneGeometry extends _PrimitiveGeometry {
  22818. /**
  22819. * Defines the size of the plane (width === height)
  22820. */
  22821. size: number;
  22822. /**
  22823. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22824. */
  22825. side: number;
  22826. /**
  22827. * Creates a plane geometry
  22828. * @param id defines the unique ID of the geometry
  22829. * @param scene defines the hosting scene
  22830. * @param size defines the size of the plane (width === height)
  22831. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22832. * @param mesh defines the hosting mesh (can be null)
  22833. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22834. */
  22835. constructor(id: string, scene: Scene,
  22836. /**
  22837. * Defines the size of the plane (width === height)
  22838. */
  22839. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22840. /**
  22841. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22842. */
  22843. side?: number);
  22844. /** @hidden */
  22845. _regenerateVertexData(): VertexData;
  22846. copy(id: string): Geometry;
  22847. serialize(): any;
  22848. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  22849. }
  22850. /**
  22851. * Creates a torus knot geometry
  22852. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  22853. */
  22854. export class TorusKnotGeometry extends _PrimitiveGeometry {
  22855. /**
  22856. * Defines the radius of the torus knot
  22857. */
  22858. radius: number;
  22859. /**
  22860. * Defines the thickness of the torus knot tube
  22861. */
  22862. tube: number;
  22863. /**
  22864. * Defines the number of radial segments
  22865. */
  22866. radialSegments: number;
  22867. /**
  22868. * Defines the number of tubular segments
  22869. */
  22870. tubularSegments: number;
  22871. /**
  22872. * Defines the first number of windings
  22873. */
  22874. p: number;
  22875. /**
  22876. * Defines the second number of windings
  22877. */
  22878. q: number;
  22879. /**
  22880. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22881. */
  22882. side: number;
  22883. /**
  22884. * Creates a torus knot geometry
  22885. * @param id defines the unique ID of the geometry
  22886. * @param scene defines the hosting scene
  22887. * @param radius defines the radius of the torus knot
  22888. * @param tube defines the thickness of the torus knot tube
  22889. * @param radialSegments defines the number of radial segments
  22890. * @param tubularSegments defines the number of tubular segments
  22891. * @param p defines the first number of windings
  22892. * @param q defines the second number of windings
  22893. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22894. * @param mesh defines the hosting mesh (can be null)
  22895. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22896. */
  22897. constructor(id: string, scene: Scene,
  22898. /**
  22899. * Defines the radius of the torus knot
  22900. */
  22901. radius: number,
  22902. /**
  22903. * Defines the thickness of the torus knot tube
  22904. */
  22905. tube: number,
  22906. /**
  22907. * Defines the number of radial segments
  22908. */
  22909. radialSegments: number,
  22910. /**
  22911. * Defines the number of tubular segments
  22912. */
  22913. tubularSegments: number,
  22914. /**
  22915. * Defines the first number of windings
  22916. */
  22917. p: number,
  22918. /**
  22919. * Defines the second number of windings
  22920. */
  22921. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22922. /**
  22923. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22924. */
  22925. side?: number);
  22926. /** @hidden */
  22927. _regenerateVertexData(): VertexData;
  22928. copy(id: string): Geometry;
  22929. serialize(): any;
  22930. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  22931. }
  22932. }
  22933. declare module "babylonjs/Meshes/mesh.vertexData" {
  22934. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22935. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22936. import { Geometry } from "babylonjs/Meshes/geometry";
  22937. import { Mesh } from "babylonjs/Meshes/mesh";
  22938. /**
  22939. * Define an interface for all classes that will get and set the data on vertices
  22940. */
  22941. export interface IGetSetVerticesData {
  22942. /**
  22943. * Gets a boolean indicating if specific vertex data is present
  22944. * @param kind defines the vertex data kind to use
  22945. * @returns true is data kind is present
  22946. */
  22947. isVerticesDataPresent(kind: string): boolean;
  22948. /**
  22949. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22950. * @param kind defines the data kind (Position, normal, etc...)
  22951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22953. * @returns a float array containing vertex data
  22954. */
  22955. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22956. /**
  22957. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22958. * @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.
  22959. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22960. * @returns the indices array or an empty array if the mesh has no geometry
  22961. */
  22962. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22963. /**
  22964. * Set specific vertex data
  22965. * @param kind defines the data kind (Position, normal, etc...)
  22966. * @param data defines the vertex data to use
  22967. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22968. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22969. */
  22970. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22971. /**
  22972. * Update a specific associated vertex buffer
  22973. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22974. * - VertexBuffer.PositionKind
  22975. * - VertexBuffer.UVKind
  22976. * - VertexBuffer.UV2Kind
  22977. * - VertexBuffer.UV3Kind
  22978. * - VertexBuffer.UV4Kind
  22979. * - VertexBuffer.UV5Kind
  22980. * - VertexBuffer.UV6Kind
  22981. * - VertexBuffer.ColorKind
  22982. * - VertexBuffer.MatricesIndicesKind
  22983. * - VertexBuffer.MatricesIndicesExtraKind
  22984. * - VertexBuffer.MatricesWeightsKind
  22985. * - VertexBuffer.MatricesWeightsExtraKind
  22986. * @param data defines the data source
  22987. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22988. * @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)
  22989. */
  22990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22991. /**
  22992. * Creates a new index buffer
  22993. * @param indices defines the indices to store in the index buffer
  22994. * @param totalVertices defines the total number of vertices (could be null)
  22995. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22996. */
  22997. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22998. }
  22999. /**
  23000. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23001. */
  23002. export class VertexData {
  23003. /**
  23004. * Mesh side orientation : usually the external or front surface
  23005. */
  23006. static readonly FRONTSIDE: number;
  23007. /**
  23008. * Mesh side orientation : usually the internal or back surface
  23009. */
  23010. static readonly BACKSIDE: number;
  23011. /**
  23012. * Mesh side orientation : both internal and external or front and back surfaces
  23013. */
  23014. static readonly DOUBLESIDE: number;
  23015. /**
  23016. * Mesh side orientation : by default, `FRONTSIDE`
  23017. */
  23018. static readonly DEFAULTSIDE: number;
  23019. /**
  23020. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23021. */
  23022. positions: Nullable<FloatArray>;
  23023. /**
  23024. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23025. */
  23026. normals: Nullable<FloatArray>;
  23027. /**
  23028. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23029. */
  23030. tangents: Nullable<FloatArray>;
  23031. /**
  23032. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23033. */
  23034. uvs: Nullable<FloatArray>;
  23035. /**
  23036. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23037. */
  23038. uvs2: Nullable<FloatArray>;
  23039. /**
  23040. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23041. */
  23042. uvs3: Nullable<FloatArray>;
  23043. /**
  23044. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23045. */
  23046. uvs4: Nullable<FloatArray>;
  23047. /**
  23048. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23049. */
  23050. uvs5: Nullable<FloatArray>;
  23051. /**
  23052. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23053. */
  23054. uvs6: Nullable<FloatArray>;
  23055. /**
  23056. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23057. */
  23058. colors: Nullable<FloatArray>;
  23059. /**
  23060. * 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).
  23061. */
  23062. matricesIndices: Nullable<FloatArray>;
  23063. /**
  23064. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23065. */
  23066. matricesWeights: Nullable<FloatArray>;
  23067. /**
  23068. * An array extending the number of possible indices
  23069. */
  23070. matricesIndicesExtra: Nullable<FloatArray>;
  23071. /**
  23072. * An array extending the number of possible weights when the number of indices is extended
  23073. */
  23074. matricesWeightsExtra: Nullable<FloatArray>;
  23075. /**
  23076. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23077. */
  23078. indices: Nullable<IndicesArray>;
  23079. /**
  23080. * Uses the passed data array to set the set the values for the specified kind of data
  23081. * @param data a linear array of floating numbers
  23082. * @param kind the type of data that is being set, eg positions, colors etc
  23083. */
  23084. set(data: FloatArray, kind: string): void;
  23085. /**
  23086. * Associates the vertexData to the passed Mesh.
  23087. * Sets it as updatable or not (default `false`)
  23088. * @param mesh the mesh the vertexData is applied to
  23089. * @param updatable when used and having the value true allows new data to update the vertexData
  23090. * @returns the VertexData
  23091. */
  23092. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23093. /**
  23094. * Associates the vertexData to the passed Geometry.
  23095. * Sets it as updatable or not (default `false`)
  23096. * @param geometry the geometry the vertexData is applied to
  23097. * @param updatable when used and having the value true allows new data to update the vertexData
  23098. * @returns VertexData
  23099. */
  23100. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23101. /**
  23102. * Updates the associated mesh
  23103. * @param mesh the mesh to be updated
  23104. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23105. * @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
  23106. * @returns VertexData
  23107. */
  23108. updateMesh(mesh: Mesh): VertexData;
  23109. /**
  23110. * Updates the associated geometry
  23111. * @param geometry the geometry to be updated
  23112. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23113. * @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
  23114. * @returns VertexData.
  23115. */
  23116. updateGeometry(geometry: Geometry): VertexData;
  23117. private _applyTo;
  23118. private _update;
  23119. /**
  23120. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23121. * @param matrix the transforming matrix
  23122. * @returns the VertexData
  23123. */
  23124. transform(matrix: Matrix): VertexData;
  23125. /**
  23126. * Merges the passed VertexData into the current one
  23127. * @param other the VertexData to be merged into the current one
  23128. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23129. * @returns the modified VertexData
  23130. */
  23131. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23132. private _mergeElement;
  23133. private _validate;
  23134. /**
  23135. * Serializes the VertexData
  23136. * @returns a serialized object
  23137. */
  23138. serialize(): any;
  23139. /**
  23140. * Extracts the vertexData from a mesh
  23141. * @param mesh the mesh from which to extract the VertexData
  23142. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23143. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23144. * @returns the object VertexData associated to the passed mesh
  23145. */
  23146. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23147. /**
  23148. * Extracts the vertexData from the geometry
  23149. * @param geometry the geometry from which to extract the VertexData
  23150. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23151. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23152. * @returns the object VertexData associated to the passed mesh
  23153. */
  23154. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23155. private static _ExtractFrom;
  23156. /**
  23157. * Creates the VertexData for a Ribbon
  23158. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23159. * * pathArray array of paths, each of which an array of successive Vector3
  23160. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23161. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23162. * * 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
  23163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23164. * * 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)
  23165. * * 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)
  23166. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23167. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23168. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23169. * @returns the VertexData of the ribbon
  23170. */
  23171. static CreateRibbon(options: {
  23172. pathArray: Vector3[][];
  23173. closeArray?: boolean;
  23174. closePath?: boolean;
  23175. offset?: number;
  23176. sideOrientation?: number;
  23177. frontUVs?: Vector4;
  23178. backUVs?: Vector4;
  23179. invertUV?: boolean;
  23180. uvs?: Vector2[];
  23181. colors?: Color4[];
  23182. }): VertexData;
  23183. /**
  23184. * Creates the VertexData for a box
  23185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23186. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23187. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23188. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23189. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23190. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23191. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23193. * * 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)
  23194. * * 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)
  23195. * @returns the VertexData of the box
  23196. */
  23197. static CreateBox(options: {
  23198. size?: number;
  23199. width?: number;
  23200. height?: number;
  23201. depth?: number;
  23202. faceUV?: Vector4[];
  23203. faceColors?: Color4[];
  23204. sideOrientation?: number;
  23205. frontUVs?: Vector4;
  23206. backUVs?: Vector4;
  23207. }): VertexData;
  23208. /**
  23209. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23210. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23211. * * segments sets the number of horizontal strips optional, default 32
  23212. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23213. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23214. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23215. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23216. * * 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
  23217. * * 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
  23218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23219. * * 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)
  23220. * * 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)
  23221. * @returns the VertexData of the ellipsoid
  23222. */
  23223. static CreateSphere(options: {
  23224. segments?: number;
  23225. diameter?: number;
  23226. diameterX?: number;
  23227. diameterY?: number;
  23228. diameterZ?: number;
  23229. arc?: number;
  23230. slice?: number;
  23231. sideOrientation?: number;
  23232. frontUVs?: Vector4;
  23233. backUVs?: Vector4;
  23234. }): VertexData;
  23235. /**
  23236. * Creates the VertexData for a cylinder, cone or prism
  23237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23238. * * height sets the height (y direction) of the cylinder, optional, default 2
  23239. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23240. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23241. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23242. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23243. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23244. * * 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
  23245. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23246. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23247. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23248. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23250. * * 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)
  23251. * * 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)
  23252. * @returns the VertexData of the cylinder, cone or prism
  23253. */
  23254. static CreateCylinder(options: {
  23255. height?: number;
  23256. diameterTop?: number;
  23257. diameterBottom?: number;
  23258. diameter?: number;
  23259. tessellation?: number;
  23260. subdivisions?: number;
  23261. arc?: number;
  23262. faceColors?: Color4[];
  23263. faceUV?: Vector4[];
  23264. hasRings?: boolean;
  23265. enclose?: boolean;
  23266. sideOrientation?: number;
  23267. frontUVs?: Vector4;
  23268. backUVs?: Vector4;
  23269. }): VertexData;
  23270. /**
  23271. * Creates the VertexData for a torus
  23272. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23273. * * diameter the diameter of the torus, optional default 1
  23274. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23275. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23277. * * 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)
  23278. * * 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)
  23279. * @returns the VertexData of the torus
  23280. */
  23281. static CreateTorus(options: {
  23282. diameter?: number;
  23283. thickness?: number;
  23284. tessellation?: number;
  23285. sideOrientation?: number;
  23286. frontUVs?: Vector4;
  23287. backUVs?: Vector4;
  23288. }): VertexData;
  23289. /**
  23290. * Creates the VertexData of the LineSystem
  23291. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23292. * - lines an array of lines, each line being an array of successive Vector3
  23293. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23294. * @returns the VertexData of the LineSystem
  23295. */
  23296. static CreateLineSystem(options: {
  23297. lines: Vector3[][];
  23298. colors?: Nullable<Color4[][]>;
  23299. }): VertexData;
  23300. /**
  23301. * Create the VertexData for a DashedLines
  23302. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23303. * - points an array successive Vector3
  23304. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23305. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23306. * - dashNb the intended total number of dashes, optional, default 200
  23307. * @returns the VertexData for the DashedLines
  23308. */
  23309. static CreateDashedLines(options: {
  23310. points: Vector3[];
  23311. dashSize?: number;
  23312. gapSize?: number;
  23313. dashNb?: number;
  23314. }): VertexData;
  23315. /**
  23316. * Creates the VertexData for a Ground
  23317. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23318. * - width the width (x direction) of the ground, optional, default 1
  23319. * - height the height (z direction) of the ground, optional, default 1
  23320. * - subdivisions the number of subdivisions per side, optional, default 1
  23321. * @returns the VertexData of the Ground
  23322. */
  23323. static CreateGround(options: {
  23324. width?: number;
  23325. height?: number;
  23326. subdivisions?: number;
  23327. subdivisionsX?: number;
  23328. subdivisionsY?: number;
  23329. }): VertexData;
  23330. /**
  23331. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23332. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23333. * * xmin the ground minimum X coordinate, optional, default -1
  23334. * * zmin the ground minimum Z coordinate, optional, default -1
  23335. * * xmax the ground maximum X coordinate, optional, default 1
  23336. * * zmax the ground maximum Z coordinate, optional, default 1
  23337. * * 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}
  23338. * * 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}
  23339. * @returns the VertexData of the TiledGround
  23340. */
  23341. static CreateTiledGround(options: {
  23342. xmin: number;
  23343. zmin: number;
  23344. xmax: number;
  23345. zmax: number;
  23346. subdivisions?: {
  23347. w: number;
  23348. h: number;
  23349. };
  23350. precision?: {
  23351. w: number;
  23352. h: number;
  23353. };
  23354. }): VertexData;
  23355. /**
  23356. * Creates the VertexData of the Ground designed from a heightmap
  23357. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23358. * * width the width (x direction) of the ground
  23359. * * height the height (z direction) of the ground
  23360. * * subdivisions the number of subdivisions per side
  23361. * * minHeight the minimum altitude on the ground, optional, default 0
  23362. * * maxHeight the maximum altitude on the ground, optional default 1
  23363. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23364. * * buffer the array holding the image color data
  23365. * * bufferWidth the width of image
  23366. * * bufferHeight the height of image
  23367. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23368. * @returns the VertexData of the Ground designed from a heightmap
  23369. */
  23370. static CreateGroundFromHeightMap(options: {
  23371. width: number;
  23372. height: number;
  23373. subdivisions: number;
  23374. minHeight: number;
  23375. maxHeight: number;
  23376. colorFilter: Color3;
  23377. buffer: Uint8Array;
  23378. bufferWidth: number;
  23379. bufferHeight: number;
  23380. alphaFilter: number;
  23381. }): VertexData;
  23382. /**
  23383. * Creates the VertexData for a Plane
  23384. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23385. * * size sets the width and height of the plane to the value of size, optional default 1
  23386. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23387. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23389. * * 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)
  23390. * * 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)
  23391. * @returns the VertexData of the box
  23392. */
  23393. static CreatePlane(options: {
  23394. size?: number;
  23395. width?: number;
  23396. height?: number;
  23397. sideOrientation?: number;
  23398. frontUVs?: Vector4;
  23399. backUVs?: Vector4;
  23400. }): VertexData;
  23401. /**
  23402. * Creates the VertexData of the Disc or regular Polygon
  23403. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23404. * * radius the radius of the disc, optional default 0.5
  23405. * * tessellation the number of polygon sides, optional, default 64
  23406. * * 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
  23407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23408. * * 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)
  23409. * * 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)
  23410. * @returns the VertexData of the box
  23411. */
  23412. static CreateDisc(options: {
  23413. radius?: number;
  23414. tessellation?: number;
  23415. arc?: number;
  23416. sideOrientation?: number;
  23417. frontUVs?: Vector4;
  23418. backUVs?: Vector4;
  23419. }): VertexData;
  23420. /**
  23421. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23422. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23423. * @param polygon a mesh built from polygonTriangulation.build()
  23424. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23425. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23426. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23427. * @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)
  23428. * @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)
  23429. * @returns the VertexData of the Polygon
  23430. */
  23431. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23432. /**
  23433. * Creates the VertexData of the IcoSphere
  23434. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23435. * * radius the radius of the IcoSphere, optional default 1
  23436. * * radiusX allows stretching in the x direction, optional, default radius
  23437. * * radiusY allows stretching in the y direction, optional, default radius
  23438. * * radiusZ allows stretching in the z direction, optional, default radius
  23439. * * flat when true creates a flat shaded mesh, optional, default true
  23440. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23442. * * 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)
  23443. * * 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)
  23444. * @returns the VertexData of the IcoSphere
  23445. */
  23446. static CreateIcoSphere(options: {
  23447. radius?: number;
  23448. radiusX?: number;
  23449. radiusY?: number;
  23450. radiusZ?: number;
  23451. flat?: boolean;
  23452. subdivisions?: number;
  23453. sideOrientation?: number;
  23454. frontUVs?: Vector4;
  23455. backUVs?: Vector4;
  23456. }): VertexData;
  23457. /**
  23458. * Creates the VertexData for a Polyhedron
  23459. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23460. * * type provided types are:
  23461. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23462. * * 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)
  23463. * * size the size of the IcoSphere, optional default 1
  23464. * * sizeX allows stretching in the x direction, optional, default size
  23465. * * sizeY allows stretching in the y direction, optional, default size
  23466. * * sizeZ allows stretching in the z direction, optional, default size
  23467. * * 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
  23468. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23469. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23470. * * flat when true creates a flat shaded mesh, optional, default true
  23471. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23473. * * 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)
  23474. * * 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)
  23475. * @returns the VertexData of the Polyhedron
  23476. */
  23477. static CreatePolyhedron(options: {
  23478. type?: number;
  23479. size?: number;
  23480. sizeX?: number;
  23481. sizeY?: number;
  23482. sizeZ?: number;
  23483. custom?: any;
  23484. faceUV?: Vector4[];
  23485. faceColors?: Color4[];
  23486. flat?: boolean;
  23487. sideOrientation?: number;
  23488. frontUVs?: Vector4;
  23489. backUVs?: Vector4;
  23490. }): VertexData;
  23491. /**
  23492. * Creates the VertexData for a TorusKnot
  23493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23494. * * radius the radius of the torus knot, optional, default 2
  23495. * * tube the thickness of the tube, optional, default 0.5
  23496. * * radialSegments the number of sides on each tube segments, optional, default 32
  23497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23498. * * p the number of windings around the z axis, optional, default 2
  23499. * * q the number of windings around the x axis, optional, default 3
  23500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23501. * * 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)
  23502. * * 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)
  23503. * @returns the VertexData of the Torus Knot
  23504. */
  23505. static CreateTorusKnot(options: {
  23506. radius?: number;
  23507. tube?: number;
  23508. radialSegments?: number;
  23509. tubularSegments?: number;
  23510. p?: number;
  23511. q?: number;
  23512. sideOrientation?: number;
  23513. frontUVs?: Vector4;
  23514. backUVs?: Vector4;
  23515. }): VertexData;
  23516. /**
  23517. * Compute normals for given positions and indices
  23518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23522. * * facetNormals : optional array of facet normals (vector3)
  23523. * * facetPositions : optional array of facet positions (vector3)
  23524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23526. * * bInfo : optional bounding info, required for facetPartitioning computation
  23527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23529. * * useRightHandedSystem: optional boolean to for right handed system computation
  23530. * * depthSort : optional boolean to enable the facet depth sort computation
  23531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23533. */
  23534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23535. facetNormals?: any;
  23536. facetPositions?: any;
  23537. facetPartitioning?: any;
  23538. ratio?: number;
  23539. bInfo?: any;
  23540. bbSize?: Vector3;
  23541. subDiv?: any;
  23542. useRightHandedSystem?: boolean;
  23543. depthSort?: boolean;
  23544. distanceTo?: Vector3;
  23545. depthSortedFacets?: any;
  23546. }): void;
  23547. private static _ComputeSides;
  23548. /**
  23549. * Applies VertexData created from the imported parameters to the geometry
  23550. * @param parsedVertexData the parsed data from an imported file
  23551. * @param geometry the geometry to apply the VertexData to
  23552. */
  23553. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23554. }
  23555. }
  23556. declare module "babylonjs/Meshes/polygonMesh" {
  23557. import { Scene } from "babylonjs/scene";
  23558. import { Vector2, Path2 } from "babylonjs/Maths/math";
  23559. import { Mesh } from "babylonjs/Meshes/mesh";
  23560. /**
  23561. * Polygon
  23562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23563. */
  23564. export class Polygon {
  23565. /**
  23566. * Creates a rectangle
  23567. * @param xmin bottom X coord
  23568. * @param ymin bottom Y coord
  23569. * @param xmax top X coord
  23570. * @param ymax top Y coord
  23571. * @returns points that make the resulting rectation
  23572. */
  23573. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23574. /**
  23575. * Creates a circle
  23576. * @param radius radius of circle
  23577. * @param cx scale in x
  23578. * @param cy scale in y
  23579. * @param numberOfSides number of sides that make up the circle
  23580. * @returns points that make the resulting circle
  23581. */
  23582. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23583. /**
  23584. * Creates a polygon from input string
  23585. * @param input Input polygon data
  23586. * @returns the parsed points
  23587. */
  23588. static Parse(input: string): Vector2[];
  23589. /**
  23590. * Starts building a polygon from x and y coordinates
  23591. * @param x x coordinate
  23592. * @param y y coordinate
  23593. * @returns the started path2
  23594. */
  23595. static StartingAt(x: number, y: number): Path2;
  23596. }
  23597. /**
  23598. * Builds a polygon
  23599. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  23600. */
  23601. export class PolygonMeshBuilder {
  23602. private _points;
  23603. private _outlinepoints;
  23604. private _holes;
  23605. private _name;
  23606. private _scene;
  23607. private _epoints;
  23608. private _eholes;
  23609. private _addToepoint;
  23610. /**
  23611. * Babylon reference to the earcut plugin.
  23612. */
  23613. bjsEarcut: any;
  23614. /**
  23615. * Creates a PolygonMeshBuilder
  23616. * @param name name of the builder
  23617. * @param contours Path of the polygon
  23618. * @param scene scene to add to
  23619. */
  23620. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  23621. /**
  23622. * Adds a whole within the polygon
  23623. * @param hole Array of points defining the hole
  23624. * @returns this
  23625. */
  23626. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23627. /**
  23628. * Creates the polygon
  23629. * @param updatable If the mesh should be updatable
  23630. * @param depth The depth of the mesh created
  23631. * @returns the created mesh
  23632. */
  23633. build(updatable?: boolean, depth?: number): Mesh;
  23634. /**
  23635. * Adds a side to the polygon
  23636. * @param positions points that make the polygon
  23637. * @param normals normals of the polygon
  23638. * @param uvs uvs of the polygon
  23639. * @param indices indices of the polygon
  23640. * @param bounds bounds of the polygon
  23641. * @param points points of the polygon
  23642. * @param depth depth of the polygon
  23643. * @param flip flip of the polygon
  23644. */
  23645. private addSide;
  23646. }
  23647. }
  23648. declare module "babylonjs/Meshes/meshBuilder" {
  23649. import { Nullable } from "babylonjs/types";
  23650. import { Scene } from "babylonjs/scene";
  23651. import { Vector3, Vector2, Color3, Color4, Plane, Vector4 } from "babylonjs/Maths/math";
  23652. import { Mesh } from "babylonjs/Meshes/mesh";
  23653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23654. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23655. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23656. /**
  23657. * Class containing static functions to help procedurally build meshes
  23658. */
  23659. export class MeshBuilder {
  23660. private static _UpdateSideOrientation;
  23661. /**
  23662. * Creates a box mesh
  23663. * * The parameter `size` sets the size (float) of each box side (default 1)
  23664. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  23665. * * 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)
  23666. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23668. * * 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
  23669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23670. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  23671. * @param name defines the name of the mesh
  23672. * @param options defines the options used to create the mesh
  23673. * @param scene defines the hosting scene
  23674. * @returns the box mesh
  23675. */
  23676. static CreateBox(name: string, options: {
  23677. size?: number;
  23678. width?: number;
  23679. height?: number;
  23680. depth?: number;
  23681. faceUV?: Vector4[];
  23682. faceColors?: Color4[];
  23683. sideOrientation?: number;
  23684. frontUVs?: Vector4;
  23685. backUVs?: Vector4;
  23686. updatable?: boolean;
  23687. }, scene?: Nullable<Scene>): Mesh;
  23688. /**
  23689. * Creates a sphere mesh
  23690. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23691. * * 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`)
  23692. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23693. * * 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
  23694. * * 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)
  23695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23696. * * 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
  23697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23698. * @param name defines the name of the mesh
  23699. * @param options defines the options used to create the mesh
  23700. * @param scene defines the hosting scene
  23701. * @returns the sphere mesh
  23702. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  23703. */
  23704. static CreateSphere(name: string, options: {
  23705. segments?: number;
  23706. diameter?: number;
  23707. diameterX?: number;
  23708. diameterY?: number;
  23709. diameterZ?: number;
  23710. arc?: number;
  23711. slice?: number;
  23712. sideOrientation?: number;
  23713. frontUVs?: Vector4;
  23714. backUVs?: Vector4;
  23715. updatable?: boolean;
  23716. }, scene: any): Mesh;
  23717. /**
  23718. * Creates a plane polygonal mesh. By default, this is a disc
  23719. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23720. * * 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
  23721. * * 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
  23722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23723. * * 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
  23724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23725. * @param name defines the name of the mesh
  23726. * @param options defines the options used to create the mesh
  23727. * @param scene defines the hosting scene
  23728. * @returns the plane polygonal mesh
  23729. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23730. */
  23731. static CreateDisc(name: string, options: {
  23732. radius?: number;
  23733. tessellation?: number;
  23734. arc?: number;
  23735. updatable?: boolean;
  23736. sideOrientation?: number;
  23737. frontUVs?: Vector4;
  23738. backUVs?: Vector4;
  23739. }, scene?: Nullable<Scene>): Mesh;
  23740. /**
  23741. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23742. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23743. * * 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`)
  23744. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23745. * * 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
  23746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23747. * * 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
  23748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23749. * @param name defines the name of the mesh
  23750. * @param options defines the options used to create the mesh
  23751. * @param scene defines the hosting scene
  23752. * @returns the icosahedron mesh
  23753. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23754. */
  23755. static CreateIcoSphere(name: string, options: {
  23756. radius?: number;
  23757. radiusX?: number;
  23758. radiusY?: number;
  23759. radiusZ?: number;
  23760. flat?: boolean;
  23761. subdivisions?: number;
  23762. sideOrientation?: number;
  23763. frontUVs?: Vector4;
  23764. backUVs?: Vector4;
  23765. updatable?: boolean;
  23766. }, scene: Scene): Mesh;
  23767. /**
  23768. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23769. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23770. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23771. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23772. * * 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
  23773. * * 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
  23774. * * 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
  23775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23776. * * 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
  23777. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23778. * * 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
  23779. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23780. * * 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
  23781. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23783. * @param name defines the name of the mesh
  23784. * @param options defines the options used to create the mesh
  23785. * @param scene defines the hosting scene
  23786. * @returns the ribbon mesh
  23787. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  23788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23789. */
  23790. static CreateRibbon(name: string, options: {
  23791. pathArray: Vector3[][];
  23792. closeArray?: boolean;
  23793. closePath?: boolean;
  23794. offset?: number;
  23795. updatable?: boolean;
  23796. sideOrientation?: number;
  23797. frontUVs?: Vector4;
  23798. backUVs?: Vector4;
  23799. instance?: Mesh;
  23800. invertUV?: boolean;
  23801. uvs?: Vector2[];
  23802. colors?: Color4[];
  23803. }, scene?: Nullable<Scene>): Mesh;
  23804. /**
  23805. * Creates a cylinder or a cone mesh
  23806. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23807. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23808. * * 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.
  23809. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23810. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23811. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23812. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23813. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23814. * * 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).
  23815. * * 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
  23816. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23817. * * 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
  23818. * * 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.
  23819. * * If `enclose` is false, a ring surface is one element.
  23820. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23821. * * 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
  23822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23823. * * 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
  23824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23825. * @param name defines the name of the mesh
  23826. * @param options defines the options used to create the mesh
  23827. * @param scene defines the hosting scene
  23828. * @returns the cylinder mesh
  23829. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23830. */
  23831. static CreateCylinder(name: string, options: {
  23832. height?: number;
  23833. diameterTop?: number;
  23834. diameterBottom?: number;
  23835. diameter?: number;
  23836. tessellation?: number;
  23837. subdivisions?: number;
  23838. arc?: number;
  23839. faceColors?: Color4[];
  23840. faceUV?: Vector4[];
  23841. updatable?: boolean;
  23842. hasRings?: boolean;
  23843. enclose?: boolean;
  23844. sideOrientation?: number;
  23845. frontUVs?: Vector4;
  23846. backUVs?: Vector4;
  23847. }, scene: any): Mesh;
  23848. /**
  23849. * Creates a torus mesh
  23850. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23851. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23852. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23854. * * 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
  23855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23856. * @param name defines the name of the mesh
  23857. * @param options defines the options used to create the mesh
  23858. * @param scene defines the hosting scene
  23859. * @returns the torus mesh
  23860. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  23861. */
  23862. static CreateTorus(name: string, options: {
  23863. diameter?: number;
  23864. thickness?: number;
  23865. tessellation?: number;
  23866. updatable?: boolean;
  23867. sideOrientation?: number;
  23868. frontUVs?: Vector4;
  23869. backUVs?: Vector4;
  23870. }, scene: any): Mesh;
  23871. /**
  23872. * Creates a torus knot mesh
  23873. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23874. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23875. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23876. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23878. * * 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
  23879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23880. * @param name defines the name of the mesh
  23881. * @param options defines the options used to create the mesh
  23882. * @param scene defines the hosting scene
  23883. * @returns the torus knot mesh
  23884. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23885. */
  23886. static CreateTorusKnot(name: string, options: {
  23887. radius?: number;
  23888. tube?: number;
  23889. radialSegments?: number;
  23890. tubularSegments?: number;
  23891. p?: number;
  23892. q?: number;
  23893. updatable?: boolean;
  23894. sideOrientation?: number;
  23895. frontUVs?: Vector4;
  23896. backUVs?: Vector4;
  23897. }, scene: any): Mesh;
  23898. /**
  23899. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23900. * * 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
  23901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23902. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23903. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23904. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23905. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23906. * * 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
  23907. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23910. * @param name defines the name of the new line system
  23911. * @param options defines the options used to create the line system
  23912. * @param scene defines the hosting scene
  23913. * @returns a new line system mesh
  23914. */
  23915. static CreateLineSystem(name: string, options: {
  23916. lines: Vector3[][];
  23917. updatable?: boolean;
  23918. instance?: Nullable<LinesMesh>;
  23919. colors?: Nullable<Color4[][]>;
  23920. useVertexAlpha?: boolean;
  23921. }, scene: Nullable<Scene>): LinesMesh;
  23922. /**
  23923. * Creates a line mesh
  23924. * 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
  23925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23926. * * The parameter `points` is an array successive Vector3
  23927. * * 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
  23928. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23929. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23930. * * When updating an instance, remember that only point positions can change, not the number of points
  23931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  23933. * @param name defines the name of the new line system
  23934. * @param options defines the options used to create the line system
  23935. * @param scene defines the hosting scene
  23936. * @returns a new line mesh
  23937. */
  23938. static CreateLines(name: string, options: {
  23939. points: Vector3[];
  23940. updatable?: boolean;
  23941. instance?: Nullable<LinesMesh>;
  23942. colors?: Color4[];
  23943. useVertexAlpha?: boolean;
  23944. }, scene?: Nullable<Scene>): LinesMesh;
  23945. /**
  23946. * Creates a dashed line mesh
  23947. * * 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
  23948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23949. * * The parameter `points` is an array successive Vector3
  23950. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23951. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23952. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23953. * * 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
  23954. * * When updating an instance, remember that only point positions can change, not the number of points
  23955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23956. * @param name defines the name of the mesh
  23957. * @param options defines the options used to create the mesh
  23958. * @param scene defines the hosting scene
  23959. * @returns the dashed line mesh
  23960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23961. */
  23962. static CreateDashedLines(name: string, options: {
  23963. points: Vector3[];
  23964. dashSize?: number;
  23965. gapSize?: number;
  23966. dashNb?: number;
  23967. updatable?: boolean;
  23968. instance?: LinesMesh;
  23969. }, scene?: Nullable<Scene>): LinesMesh;
  23970. /**
  23971. * 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.
  23972. * * 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.
  23973. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23974. * * 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.
  23975. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23976. * * 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
  23977. * * 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
  23978. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23980. * * 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
  23981. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23983. * @param name defines the name of the mesh
  23984. * @param options defines the options used to create the mesh
  23985. * @param scene defines the hosting scene
  23986. * @returns the extruded shape mesh
  23987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23989. */
  23990. static ExtrudeShape(name: string, options: {
  23991. shape: Vector3[];
  23992. path: Vector3[];
  23993. scale?: number;
  23994. rotation?: number;
  23995. cap?: number;
  23996. updatable?: boolean;
  23997. sideOrientation?: number;
  23998. frontUVs?: Vector4;
  23999. backUVs?: Vector4;
  24000. instance?: Mesh;
  24001. invertUV?: boolean;
  24002. }, scene?: Nullable<Scene>): Mesh;
  24003. /**
  24004. * Creates an custom extruded shape mesh.
  24005. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24006. * * 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.
  24007. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24008. * * 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
  24009. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  24010. * * 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
  24011. * * It must returns a float value that will be the scale value applied to the shape on each path point
  24012. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24013. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  24014. * * 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
  24015. * * 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
  24016. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  24017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24018. * * 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
  24019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24021. * @param name defines the name of the mesh
  24022. * @param options defines the options used to create the mesh
  24023. * @param scene defines the hosting scene
  24024. * @returns the custom extruded shape mesh
  24025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  24026. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24028. */
  24029. static ExtrudeShapeCustom(name: string, options: {
  24030. shape: Vector3[];
  24031. path: Vector3[];
  24032. scaleFunction?: any;
  24033. rotationFunction?: any;
  24034. ribbonCloseArray?: boolean;
  24035. ribbonClosePath?: boolean;
  24036. cap?: number;
  24037. updatable?: boolean;
  24038. sideOrientation?: number;
  24039. frontUVs?: Vector4;
  24040. backUVs?: Vector4;
  24041. instance?: Mesh;
  24042. invertUV?: boolean;
  24043. }, scene: Scene): Mesh;
  24044. /**
  24045. * Creates lathe mesh.
  24046. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  24047. * * 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
  24048. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  24049. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  24050. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  24051. * * 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
  24052. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  24053. * * 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
  24054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24055. * * 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
  24056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24058. * @param name defines the name of the mesh
  24059. * @param options defines the options used to create the mesh
  24060. * @param scene defines the hosting scene
  24061. * @returns the lathe mesh
  24062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  24063. */
  24064. static CreateLathe(name: string, options: {
  24065. shape: Vector3[];
  24066. radius?: number;
  24067. tessellation?: number;
  24068. clip?: number;
  24069. arc?: number;
  24070. closed?: boolean;
  24071. updatable?: boolean;
  24072. sideOrientation?: number;
  24073. frontUVs?: Vector4;
  24074. backUVs?: Vector4;
  24075. cap?: number;
  24076. invertUV?: boolean;
  24077. }, scene: Scene): Mesh;
  24078. /**
  24079. * Creates a plane mesh
  24080. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  24081. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  24082. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  24083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24084. * * 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
  24085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24086. * @param name defines the name of the mesh
  24087. * @param options defines the options used to create the mesh
  24088. * @param scene defines the hosting scene
  24089. * @returns the plane mesh
  24090. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  24091. */
  24092. static CreatePlane(name: string, options: {
  24093. size?: number;
  24094. width?: number;
  24095. height?: number;
  24096. sideOrientation?: number;
  24097. frontUVs?: Vector4;
  24098. backUVs?: Vector4;
  24099. updatable?: boolean;
  24100. sourcePlane?: Plane;
  24101. }, scene: Scene): Mesh;
  24102. /**
  24103. * Creates a ground mesh
  24104. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  24105. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  24106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24107. * @param name defines the name of the mesh
  24108. * @param options defines the options used to create the mesh
  24109. * @param scene defines the hosting scene
  24110. * @returns the ground mesh
  24111. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  24112. */
  24113. static CreateGround(name: string, options: {
  24114. width?: number;
  24115. height?: number;
  24116. subdivisions?: number;
  24117. subdivisionsX?: number;
  24118. subdivisionsY?: number;
  24119. updatable?: boolean;
  24120. }, scene: any): Mesh;
  24121. /**
  24122. * Creates a tiled ground mesh
  24123. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  24124. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  24125. * * 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
  24126. * * 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
  24127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24128. * @param name defines the name of the mesh
  24129. * @param options defines the options used to create the mesh
  24130. * @param scene defines the hosting scene
  24131. * @returns the tiled ground mesh
  24132. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  24133. */
  24134. static CreateTiledGround(name: string, options: {
  24135. xmin: number;
  24136. zmin: number;
  24137. xmax: number;
  24138. zmax: number;
  24139. subdivisions?: {
  24140. w: number;
  24141. h: number;
  24142. };
  24143. precision?: {
  24144. w: number;
  24145. h: number;
  24146. };
  24147. updatable?: boolean;
  24148. }, scene: Scene): Mesh;
  24149. /**
  24150. * Creates a ground mesh from a height map
  24151. * * The parameter `url` sets the URL of the height map image resource.
  24152. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  24153. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  24154. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  24155. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  24156. * * 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.
  24157. * * 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).
  24158. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24160. * @param name defines the name of the mesh
  24161. * @param url defines the url to the height map
  24162. * @param options defines the options used to create the mesh
  24163. * @param scene defines the hosting scene
  24164. * @returns the ground mesh
  24165. * @see https://doc.babylonjs.com/babylon101/height_map
  24166. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  24167. */
  24168. static CreateGroundFromHeightMap(name: string, url: string, options: {
  24169. width?: number;
  24170. height?: number;
  24171. subdivisions?: number;
  24172. minHeight?: number;
  24173. maxHeight?: number;
  24174. colorFilter?: Color3;
  24175. alphaFilter?: number;
  24176. updatable?: boolean;
  24177. onReady?: (mesh: GroundMesh) => void;
  24178. }, scene: Scene): GroundMesh;
  24179. /**
  24180. * Creates a polygon mesh
  24181. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24182. * * 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
  24183. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24185. * * 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)
  24186. * * Remember you can only change the shape positions, not their number when updating a polygon
  24187. * @param name defines the name of the mesh
  24188. * @param options defines the options used to create the mesh
  24189. * @param scene defines the hosting scene
  24190. * @returns the polygon mesh
  24191. */
  24192. static CreatePolygon(name: string, options: {
  24193. shape: Vector3[];
  24194. holes?: Vector3[][];
  24195. depth?: number;
  24196. faceUV?: Vector4[];
  24197. faceColors?: Color4[];
  24198. updatable?: boolean;
  24199. sideOrientation?: number;
  24200. frontUVs?: Vector4;
  24201. backUVs?: Vector4;
  24202. }, scene: Scene): Mesh;
  24203. /**
  24204. * Creates an extruded polygon mesh, with depth in the Y direction.
  24205. * * 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)
  24206. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24207. * @param name defines the name of the mesh
  24208. * @param options defines the options used to create the mesh
  24209. * @param scene defines the hosting scene
  24210. * @returns the polygon mesh
  24211. */
  24212. static ExtrudePolygon(name: string, options: {
  24213. shape: Vector3[];
  24214. holes?: Vector3[][];
  24215. depth?: number;
  24216. faceUV?: Vector4[];
  24217. faceColors?: Color4[];
  24218. updatable?: boolean;
  24219. sideOrientation?: number;
  24220. frontUVs?: Vector4;
  24221. backUVs?: Vector4;
  24222. }, scene: Scene): Mesh;
  24223. /**
  24224. * Creates a tube mesh.
  24225. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24226. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  24227. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  24228. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  24229. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  24230. * * 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)
  24231. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  24232. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  24233. * * 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
  24234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24235. * * 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
  24236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24238. * @param name defines the name of the mesh
  24239. * @param options defines the options used to create the mesh
  24240. * @param scene defines the hosting scene
  24241. * @returns the tube mesh
  24242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24243. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  24244. */
  24245. static CreateTube(name: string, options: {
  24246. path: Vector3[];
  24247. radius?: number;
  24248. tessellation?: number;
  24249. radiusFunction?: {
  24250. (i: number, distance: number): number;
  24251. };
  24252. cap?: number;
  24253. arc?: number;
  24254. updatable?: boolean;
  24255. sideOrientation?: number;
  24256. frontUVs?: Vector4;
  24257. backUVs?: Vector4;
  24258. instance?: Mesh;
  24259. invertUV?: boolean;
  24260. }, scene: Scene): Mesh;
  24261. /**
  24262. * Creates a polyhedron mesh
  24263. * * 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
  24264. * * The parameter `size` (positive float, default 1) sets the polygon size
  24265. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24266. * * 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`
  24267. * * 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
  24268. * * 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)`)
  24269. * * 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
  24270. * * 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
  24271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24272. * * 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
  24273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24274. * @param name defines the name of the mesh
  24275. * @param options defines the options used to create the mesh
  24276. * @param scene defines the hosting scene
  24277. * @returns the polyhedron mesh
  24278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  24279. */
  24280. static CreatePolyhedron(name: string, options: {
  24281. type?: number;
  24282. size?: number;
  24283. sizeX?: number;
  24284. sizeY?: number;
  24285. sizeZ?: number;
  24286. custom?: any;
  24287. faceUV?: Vector4[];
  24288. faceColors?: Color4[];
  24289. flat?: boolean;
  24290. updatable?: boolean;
  24291. sideOrientation?: number;
  24292. frontUVs?: Vector4;
  24293. backUVs?: Vector4;
  24294. }, scene: Scene): Mesh;
  24295. /**
  24296. * Creates a decal mesh.
  24297. * 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
  24298. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  24299. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  24300. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  24301. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  24302. * @param name defines the name of the mesh
  24303. * @param sourceMesh defines the mesh where the decal must be applied
  24304. * @param options defines the options used to create the mesh
  24305. * @param scene defines the hosting scene
  24306. * @returns the decal mesh
  24307. * @see https://doc.babylonjs.com/how_to/decals
  24308. */
  24309. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  24310. position?: Vector3;
  24311. normal?: Vector3;
  24312. size?: Vector3;
  24313. angle?: number;
  24314. }): Mesh;
  24315. private static _ExtrudeShapeGeneric;
  24316. }
  24317. }
  24318. declare module "babylonjs/Particles/solidParticleSystem" {
  24319. import { Vector3 } from "babylonjs/Maths/math";
  24320. import { Mesh } from "babylonjs/Meshes/mesh";
  24321. import { Scene, IDisposable } from "babylonjs/scene";
  24322. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24323. /**
  24324. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24325. *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.
  24326. * The SPS is also a particle system. It provides some methods to manage the particles.
  24327. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24328. *
  24329. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24330. */
  24331. export class SolidParticleSystem implements IDisposable {
  24332. /**
  24333. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24334. * Example : var p = SPS.particles[i];
  24335. */
  24336. particles: SolidParticle[];
  24337. /**
  24338. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24339. */
  24340. nbParticles: number;
  24341. /**
  24342. * If the particles must ever face the camera (default false). Useful for planar particles.
  24343. */
  24344. billboard: boolean;
  24345. /**
  24346. * Recompute normals when adding a shape
  24347. */
  24348. recomputeNormals: boolean;
  24349. /**
  24350. * This a counter ofr your own usage. It's not set by any SPS functions.
  24351. */
  24352. counter: number;
  24353. /**
  24354. * The SPS name. This name is also given to the underlying mesh.
  24355. */
  24356. name: string;
  24357. /**
  24358. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24359. */
  24360. mesh: Mesh;
  24361. /**
  24362. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24363. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24364. */
  24365. vars: any;
  24366. /**
  24367. * This array is populated when the SPS is set as 'pickable'.
  24368. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24369. * Each element of this array is an object `{idx: int, faceId: int}`.
  24370. * `idx` is the picked particle index in the `SPS.particles` array
  24371. * `faceId` is the picked face index counted within this particle.
  24372. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24373. */
  24374. pickedParticles: {
  24375. idx: number;
  24376. faceId: number;
  24377. }[];
  24378. /**
  24379. * This array is populated when `enableDepthSort` is set to true.
  24380. * Each element of this array is an instance of the class DepthSortedParticle.
  24381. */
  24382. depthSortedParticles: DepthSortedParticle[];
  24383. /**
  24384. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24385. * @hidden
  24386. */
  24387. _bSphereOnly: boolean;
  24388. /**
  24389. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24390. * @hidden
  24391. */
  24392. _bSphereRadiusFactor: number;
  24393. private _scene;
  24394. private _positions;
  24395. private _indices;
  24396. private _normals;
  24397. private _colors;
  24398. private _uvs;
  24399. private _indices32;
  24400. private _positions32;
  24401. private _normals32;
  24402. private _fixedNormal32;
  24403. private _colors32;
  24404. private _uvs32;
  24405. private _index;
  24406. private _updatable;
  24407. private _pickable;
  24408. private _isVisibilityBoxLocked;
  24409. private _alwaysVisible;
  24410. private _depthSort;
  24411. private _shapeCounter;
  24412. private _copy;
  24413. private _color;
  24414. private _computeParticleColor;
  24415. private _computeParticleTexture;
  24416. private _computeParticleRotation;
  24417. private _computeParticleVertex;
  24418. private _computeBoundingBox;
  24419. private _depthSortParticles;
  24420. private _camera;
  24421. private _mustUnrotateFixedNormals;
  24422. private _particlesIntersect;
  24423. private _needs32Bits;
  24424. /**
  24425. * Creates a SPS (Solid Particle System) object.
  24426. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24427. * @param scene (Scene) is the scene in which the SPS is added.
  24428. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24429. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24430. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24431. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24432. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24433. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24434. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24435. */
  24436. constructor(name: string, scene: Scene, options?: {
  24437. updatable?: boolean;
  24438. isPickable?: boolean;
  24439. enableDepthSort?: boolean;
  24440. particleIntersection?: boolean;
  24441. boundingSphereOnly?: boolean;
  24442. bSphereRadiusFactor?: number;
  24443. });
  24444. /**
  24445. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24446. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24447. * @returns the created mesh
  24448. */
  24449. buildMesh(): Mesh;
  24450. /**
  24451. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24452. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24453. * Thus the particles generated from `digest()` have their property `position` set yet.
  24454. * @param mesh ( Mesh ) is the mesh to be digested
  24455. * @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
  24456. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24457. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24458. * @returns the current SPS
  24459. */
  24460. digest(mesh: Mesh, options?: {
  24461. facetNb?: number;
  24462. number?: number;
  24463. delta?: number;
  24464. }): SolidParticleSystem;
  24465. private _unrotateFixedNormals;
  24466. private _resetCopy;
  24467. private _meshBuilder;
  24468. private _posToShape;
  24469. private _uvsToShapeUV;
  24470. private _addParticle;
  24471. /**
  24472. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24473. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24474. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24475. * @param nb (positive integer) the number of particles to be created from this model
  24476. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24477. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24478. * @returns the number of shapes in the system
  24479. */
  24480. addShape(mesh: Mesh, nb: number, options?: {
  24481. positionFunction?: any;
  24482. vertexFunction?: any;
  24483. }): number;
  24484. private _rebuildParticle;
  24485. /**
  24486. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24487. * @returns the SPS.
  24488. */
  24489. rebuildMesh(): SolidParticleSystem;
  24490. /**
  24491. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24492. * This method calls `updateParticle()` for each particle of the SPS.
  24493. * For an animated SPS, it is usually called within the render loop.
  24494. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24495. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24496. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24497. * @returns the SPS.
  24498. */
  24499. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24500. /**
  24501. * Disposes the SPS.
  24502. */
  24503. dispose(): void;
  24504. /**
  24505. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24506. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24507. * @returns the SPS.
  24508. */
  24509. refreshVisibleSize(): SolidParticleSystem;
  24510. /**
  24511. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24512. * @param size the size (float) of the visibility box
  24513. * note : this doesn't lock the SPS mesh bounding box.
  24514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24515. */
  24516. setVisibilityBox(size: number): void;
  24517. /**
  24518. * Gets whether the SPS as always visible or not
  24519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24520. */
  24521. /**
  24522. * Sets the SPS as always visible or not
  24523. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24524. */
  24525. isAlwaysVisible: boolean;
  24526. /**
  24527. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24529. */
  24530. /**
  24531. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24532. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24533. */
  24534. isVisibilityBoxLocked: boolean;
  24535. /**
  24536. * Tells to `setParticles()` to compute the particle rotations or not.
  24537. * Default value : true. The SPS is faster when it's set to false.
  24538. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24539. */
  24540. /**
  24541. * Gets if `setParticles()` computes the particle rotations or not.
  24542. * Default value : true. The SPS is faster when it's set to false.
  24543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24544. */
  24545. computeParticleRotation: boolean;
  24546. /**
  24547. * Tells to `setParticles()` to compute the particle colors or not.
  24548. * Default value : true. The SPS is faster when it's set to false.
  24549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24550. */
  24551. /**
  24552. * Gets if `setParticles()` computes the particle colors or not.
  24553. * Default value : true. The SPS is faster when it's set to false.
  24554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24555. */
  24556. computeParticleColor: boolean;
  24557. /**
  24558. * Gets if `setParticles()` computes the particle textures or not.
  24559. * Default value : true. The SPS is faster when it's set to false.
  24560. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24561. */
  24562. computeParticleTexture: boolean;
  24563. /**
  24564. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24565. * Default value : false. The SPS is faster when it's set to false.
  24566. * Note : the particle custom vertex positions aren't stored values.
  24567. */
  24568. /**
  24569. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24570. * Default value : false. The SPS is faster when it's set to false.
  24571. * Note : the particle custom vertex positions aren't stored values.
  24572. */
  24573. computeParticleVertex: boolean;
  24574. /**
  24575. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24576. */
  24577. /**
  24578. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24579. */
  24580. computeBoundingBox: boolean;
  24581. /**
  24582. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24583. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24584. * Default : `true`
  24585. */
  24586. /**
  24587. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24588. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24589. * Default : `true`
  24590. */
  24591. depthSortParticles: boolean;
  24592. /**
  24593. * This function does nothing. It may be overwritten to set all the particle first values.
  24594. * The SPS doesn't call this function, you may have to call it by your own.
  24595. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24596. */
  24597. initParticles(): void;
  24598. /**
  24599. * This function does nothing. It may be overwritten to recycle a particle.
  24600. * The SPS doesn't call this function, you may have to call it by your own.
  24601. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24602. * @param particle The particle to recycle
  24603. * @returns the recycled particle
  24604. */
  24605. recycleParticle(particle: SolidParticle): SolidParticle;
  24606. /**
  24607. * Updates a particle : this function should be overwritten by the user.
  24608. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24609. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24610. * @example : just set a particle position or velocity and recycle conditions
  24611. * @param particle The particle to update
  24612. * @returns the updated particle
  24613. */
  24614. updateParticle(particle: SolidParticle): SolidParticle;
  24615. /**
  24616. * Updates a vertex of a particle : it can be overwritten by the user.
  24617. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24618. * @param particle the current particle
  24619. * @param vertex the current index of the current particle
  24620. * @param pt the index of the current vertex in the particle shape
  24621. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24622. * @example : just set a vertex particle position
  24623. * @returns the updated vertex
  24624. */
  24625. updateParticleVertex(vertex: Vector3): Vector3;
  24626. /**
  24627. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24628. * This does nothing and may be overwritten by the user.
  24629. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24630. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24631. * @param update the boolean update value actually passed to setParticles()
  24632. */
  24633. beforeUpdateParticles(): void;
  24634. /**
  24635. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24636. * This will be passed three parameters.
  24637. * This does nothing and may be overwritten by the user.
  24638. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24639. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24640. * @param update the boolean update value actually passed to setParticles()
  24641. */
  24642. afterUpdateParticles(): void;
  24643. }
  24644. }
  24645. declare module "babylonjs/Particles/solidParticle" {
  24646. import { Nullable } from "babylonjs/types";
  24647. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24648. import { Mesh } from "babylonjs/Meshes/mesh";
  24649. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24650. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24651. /**
  24652. * Represents one particle of a solid particle system.
  24653. */
  24654. export class SolidParticle {
  24655. /**
  24656. * particle global index
  24657. */
  24658. idx: number;
  24659. /**
  24660. * The color of the particle
  24661. */
  24662. color: Nullable<Color4>;
  24663. /**
  24664. * The world space position of the particle.
  24665. */
  24666. position: Vector3;
  24667. /**
  24668. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24669. */
  24670. rotation: Vector3;
  24671. /**
  24672. * The world space rotation quaternion of the particle.
  24673. */
  24674. rotationQuaternion: Nullable<Quaternion>;
  24675. /**
  24676. * The scaling of the particle.
  24677. */
  24678. scaling: Vector3;
  24679. /**
  24680. * The uvs of the particle.
  24681. */
  24682. uvs: Vector4;
  24683. /**
  24684. * The current speed of the particle.
  24685. */
  24686. velocity: Vector3;
  24687. /**
  24688. * The pivot point in the particle local space.
  24689. */
  24690. pivot: Vector3;
  24691. /**
  24692. * Must the particle be translated from its pivot point in its local space ?
  24693. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24694. * Default : false
  24695. */
  24696. translateFromPivot: boolean;
  24697. /**
  24698. * Is the particle active or not ?
  24699. */
  24700. alive: boolean;
  24701. /**
  24702. * Is the particle visible or not ?
  24703. */
  24704. isVisible: boolean;
  24705. /**
  24706. * Index of this particle in the global "positions" array (Internal use)
  24707. * @hidden
  24708. */
  24709. _pos: number;
  24710. /**
  24711. * @hidden Index of this particle in the global "indices" array (Internal use)
  24712. */
  24713. _ind: number;
  24714. /**
  24715. * @hidden ModelShape of this particle (Internal use)
  24716. */
  24717. _model: ModelShape;
  24718. /**
  24719. * ModelShape id of this particle
  24720. */
  24721. shapeId: number;
  24722. /**
  24723. * Index of the particle in its shape id (Internal use)
  24724. */
  24725. idxInShape: number;
  24726. /**
  24727. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24728. */
  24729. _modelBoundingInfo: BoundingInfo;
  24730. /**
  24731. * @hidden Particle BoundingInfo object (Internal use)
  24732. */
  24733. _boundingInfo: BoundingInfo;
  24734. /**
  24735. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24736. */
  24737. _sps: SolidParticleSystem;
  24738. /**
  24739. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24740. */
  24741. _stillInvisible: boolean;
  24742. /**
  24743. * @hidden Last computed particle rotation matrix
  24744. */
  24745. _rotationMatrix: number[];
  24746. /**
  24747. * Parent particle Id, if any.
  24748. * Default null.
  24749. */
  24750. parentId: Nullable<number>;
  24751. /**
  24752. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24753. * The possible values are :
  24754. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24755. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24756. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24758. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24759. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24760. * */
  24761. cullingStrategy: number;
  24762. /**
  24763. * @hidden Internal global position in the SPS.
  24764. */
  24765. _globalPosition: Vector3;
  24766. /**
  24767. * Creates a Solid Particle object.
  24768. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24769. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24770. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24771. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24772. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24773. * @param shapeId (integer) is the model shape identifier in the SPS.
  24774. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24775. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24776. */
  24777. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24778. /**
  24779. * Legacy support, changed scale to scaling
  24780. */
  24781. /**
  24782. * Legacy support, changed scale to scaling
  24783. */
  24784. scale: Vector3;
  24785. /**
  24786. * Legacy support, changed quaternion to rotationQuaternion
  24787. */
  24788. /**
  24789. * Legacy support, changed quaternion to rotationQuaternion
  24790. */
  24791. quaternion: Nullable<Quaternion>;
  24792. /**
  24793. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24794. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24795. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24796. * @returns true if it intersects
  24797. */
  24798. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24799. /**
  24800. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24801. * A particle is in the frustum if its bounding box intersects the frustum
  24802. * @param frustumPlanes defines the frustum to test
  24803. * @returns true if the particle is in the frustum planes
  24804. */
  24805. isInFrustum(frustumPlanes: Plane[]): boolean;
  24806. /**
  24807. * get the rotation matrix of the particle
  24808. * @hidden
  24809. */
  24810. getRotationMatrix(m: Matrix): void;
  24811. }
  24812. /**
  24813. * Represents the shape of the model used by one particle of a solid particle system.
  24814. * SPS internal tool, don't use it manually.
  24815. */
  24816. export class ModelShape {
  24817. /**
  24818. * The shape id
  24819. * @hidden
  24820. */
  24821. shapeID: number;
  24822. /**
  24823. * flat array of model positions (internal use)
  24824. * @hidden
  24825. */
  24826. _shape: Vector3[];
  24827. /**
  24828. * flat array of model UVs (internal use)
  24829. * @hidden
  24830. */
  24831. _shapeUV: number[];
  24832. /**
  24833. * length of the shape in the model indices array (internal use)
  24834. * @hidden
  24835. */
  24836. _indicesLength: number;
  24837. /**
  24838. * Custom position function (internal use)
  24839. * @hidden
  24840. */
  24841. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24842. /**
  24843. * Custom vertex function (internal use)
  24844. * @hidden
  24845. */
  24846. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24847. /**
  24848. * 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.
  24849. * SPS internal tool, don't use it manually.
  24850. * @hidden
  24851. */
  24852. 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>);
  24853. }
  24854. /**
  24855. * Represents a Depth Sorted Particle in the solid particle system.
  24856. */
  24857. export class DepthSortedParticle {
  24858. /**
  24859. * Index of the particle in the "indices" array
  24860. */
  24861. ind: number;
  24862. /**
  24863. * Length of the particle shape in the "indices" array
  24864. */
  24865. indicesLength: number;
  24866. /**
  24867. * Squared distance from the particle to the camera
  24868. */
  24869. sqDistance: number;
  24870. }
  24871. }
  24872. declare module "babylonjs/Meshes/abstractMesh" {
  24873. import { Observable } from "babylonjs/Misc/observable";
  24874. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24875. import { Camera } from "babylonjs/Cameras/camera";
  24876. import { Scene, IDisposable } from "babylonjs/scene";
  24877. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24878. import { Node } from "babylonjs/node";
  24879. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24882. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24883. import { Collider } from "babylonjs/Collisions/collider";
  24884. import { Ray } from "babylonjs/Culling/ray";
  24885. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24886. import { Material } from "babylonjs/Materials/material";
  24887. import { Light } from "babylonjs/Lights/light";
  24888. import { ActionManager } from "babylonjs/Actions/actionManager";
  24889. import { Skeleton } from "babylonjs/Bones/skeleton";
  24890. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24891. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24892. /**
  24893. * Class used to store all common mesh properties
  24894. */
  24895. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24896. /** No occlusion */
  24897. static OCCLUSION_TYPE_NONE: number;
  24898. /** Occlusion set to optimisitic */
  24899. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24900. /** Occlusion set to strict */
  24901. static OCCLUSION_TYPE_STRICT: number;
  24902. /** Use an accurante occlusion algorithm */
  24903. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24904. /** Use a conservative occlusion algorithm */
  24905. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24906. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24907. * Test order :
  24908. * Is the bounding sphere outside the frustum ?
  24909. * If not, are the bounding box vertices outside the frustum ?
  24910. * It not, then the cullable object is in the frustum.
  24911. */
  24912. static readonly CULLINGSTRATEGY_STANDARD: number;
  24913. /** Culling strategy : Bounding Sphere Only.
  24914. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24915. * It's also less accurate than the standard because some not visible objects can still be selected.
  24916. * Test : is the bounding sphere outside the frustum ?
  24917. * If not, then the cullable object is in the frustum.
  24918. */
  24919. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24920. /** Culling strategy : Optimistic Inclusion.
  24921. * This in an inclusion test first, then the standard exclusion test.
  24922. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24923. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  24924. * Anyway, it's as accurate as the standard strategy.
  24925. * Test :
  24926. * Is the cullable object bounding sphere center in the frustum ?
  24927. * If not, apply the default culling strategy.
  24928. */
  24929. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24930. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24931. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24932. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24933. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  24934. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24935. * Test :
  24936. * Is the cullable object bounding sphere center in the frustum ?
  24937. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24938. */
  24939. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24940. /**
  24941. * No billboard
  24942. */
  24943. static readonly BILLBOARDMODE_NONE: number;
  24944. /** Billboard on X axis */
  24945. static readonly BILLBOARDMODE_X: number;
  24946. /** Billboard on Y axis */
  24947. static readonly BILLBOARDMODE_Y: number;
  24948. /** Billboard on Z axis */
  24949. static readonly BILLBOARDMODE_Z: number;
  24950. /** Billboard on all axes */
  24951. static readonly BILLBOARDMODE_ALL: number;
  24952. private _facetData;
  24953. /**
  24954. * The culling strategy to use to check whether the mesh must be rendered or not.
  24955. * This value can be changed at any time and will be used on the next render mesh selection.
  24956. * The possible values are :
  24957. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24958. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24959. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24960. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24961. * Please read each static variable documentation to get details about the culling process.
  24962. * */
  24963. cullingStrategy: number;
  24964. /**
  24965. * Gets the number of facets in the mesh
  24966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24967. */
  24968. readonly facetNb: number;
  24969. /**
  24970. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24972. */
  24973. partitioningSubdivisions: number;
  24974. /**
  24975. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24976. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24978. */
  24979. partitioningBBoxRatio: number;
  24980. /**
  24981. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24982. * Works only for updatable meshes.
  24983. * Doesn't work with multi-materials
  24984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24985. */
  24986. mustDepthSortFacets: boolean;
  24987. /**
  24988. * The location (Vector3) where the facet depth sort must be computed from.
  24989. * By default, the active camera position.
  24990. * Used only when facet depth sort is enabled
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24992. */
  24993. facetDepthSortFrom: Vector3;
  24994. /**
  24995. * gets a boolean indicating if facetData is enabled
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24997. */
  24998. readonly isFacetDataEnabled: boolean;
  24999. /** @hidden */
  25000. _updateNonUniformScalingState(value: boolean): boolean;
  25001. /**
  25002. * An event triggered when this mesh collides with another one
  25003. */
  25004. onCollideObservable: Observable<AbstractMesh>;
  25005. private _onCollideObserver;
  25006. /** Set a function to call when this mesh collides with another one */
  25007. onCollide: () => void;
  25008. /**
  25009. * An event triggered when the collision's position changes
  25010. */
  25011. onCollisionPositionChangeObservable: Observable<Vector3>;
  25012. private _onCollisionPositionChangeObserver;
  25013. /** Set a function to call when the collision's position changes */
  25014. onCollisionPositionChange: () => void;
  25015. /**
  25016. * An event triggered when material is changed
  25017. */
  25018. onMaterialChangedObservable: Observable<AbstractMesh>;
  25019. /**
  25020. * Gets or sets the orientation for POV movement & rotation
  25021. */
  25022. definedFacingForward: boolean;
  25023. /** @hidden */
  25024. _occlusionQuery: Nullable<WebGLQuery>;
  25025. private _visibility;
  25026. /**
  25027. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25028. */
  25029. /**
  25030. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25031. */
  25032. visibility: number;
  25033. /** Gets or sets the alpha index used to sort transparent meshes
  25034. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25035. */
  25036. alphaIndex: number;
  25037. /**
  25038. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25039. */
  25040. isVisible: boolean;
  25041. /**
  25042. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25043. */
  25044. isPickable: boolean;
  25045. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25046. showSubMeshesBoundingBox: boolean;
  25047. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25048. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25049. */
  25050. isBlocker: boolean;
  25051. /**
  25052. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25053. */
  25054. enablePointerMoveEvents: boolean;
  25055. /**
  25056. * Specifies the rendering group id for this mesh (0 by default)
  25057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25058. */
  25059. renderingGroupId: number;
  25060. private _material;
  25061. /** Gets or sets current material */
  25062. material: Nullable<Material>;
  25063. private _receiveShadows;
  25064. /**
  25065. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25066. * @see http://doc.babylonjs.com/babylon101/shadows
  25067. */
  25068. receiveShadows: boolean;
  25069. /** Defines color to use when rendering outline */
  25070. outlineColor: Color3;
  25071. /** Define width to use when rendering outline */
  25072. outlineWidth: number;
  25073. /** Defines color to use when rendering overlay */
  25074. overlayColor: Color3;
  25075. /** Defines alpha to use when rendering overlay */
  25076. overlayAlpha: number;
  25077. private _hasVertexAlpha;
  25078. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25079. hasVertexAlpha: boolean;
  25080. private _useVertexColors;
  25081. /** 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) */
  25082. useVertexColors: boolean;
  25083. private _computeBonesUsingShaders;
  25084. /**
  25085. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25086. */
  25087. computeBonesUsingShaders: boolean;
  25088. private _numBoneInfluencers;
  25089. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25090. numBoneInfluencers: number;
  25091. private _applyFog;
  25092. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25093. applyFog: boolean;
  25094. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25095. useOctreeForRenderingSelection: boolean;
  25096. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25097. useOctreeForPicking: boolean;
  25098. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25099. useOctreeForCollisions: boolean;
  25100. private _layerMask;
  25101. /**
  25102. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25103. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25104. */
  25105. layerMask: number;
  25106. /**
  25107. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25108. */
  25109. alwaysSelectAsActiveMesh: boolean;
  25110. /**
  25111. * Gets or sets the current action manager
  25112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25113. */
  25114. actionManager: Nullable<ActionManager>;
  25115. private _checkCollisions;
  25116. private _collisionMask;
  25117. private _collisionGroup;
  25118. /**
  25119. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25121. */
  25122. ellipsoid: Vector3;
  25123. /**
  25124. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25126. */
  25127. ellipsoidOffset: Vector3;
  25128. private _collider;
  25129. private _oldPositionForCollisions;
  25130. private _diffPositionForCollisions;
  25131. /**
  25132. * Gets or sets a collision mask used to mask collisions (default is -1).
  25133. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25134. */
  25135. collisionMask: number;
  25136. /**
  25137. * Gets or sets the current collision group mask (-1 by default).
  25138. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25139. */
  25140. collisionGroup: number;
  25141. /**
  25142. * Defines edge width used when edgesRenderer is enabled
  25143. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25144. */
  25145. edgesWidth: number;
  25146. /**
  25147. * Defines edge color used when edgesRenderer is enabled
  25148. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25149. */
  25150. edgesColor: Color4;
  25151. /** @hidden */
  25152. _edgesRenderer: Nullable<IEdgesRenderer>;
  25153. /** @hidden */
  25154. _masterMesh: Nullable<AbstractMesh>;
  25155. /** @hidden */
  25156. _boundingInfo: Nullable<BoundingInfo>;
  25157. /** @hidden */
  25158. _renderId: number;
  25159. /**
  25160. * Gets or sets the list of subMeshes
  25161. * @see http://doc.babylonjs.com/how_to/multi_materials
  25162. */
  25163. subMeshes: SubMesh[];
  25164. /** @hidden */
  25165. _intersectionsInProgress: AbstractMesh[];
  25166. /** @hidden */
  25167. _unIndexed: boolean;
  25168. /** @hidden */
  25169. _lightSources: Light[];
  25170. /** @hidden */
  25171. readonly _positions: Nullable<Vector3[]>;
  25172. /** @hidden */
  25173. _waitingActions: any;
  25174. /** @hidden */
  25175. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25176. private _skeleton;
  25177. /** @hidden */
  25178. _bonesTransformMatrices: Nullable<Float32Array>;
  25179. /**
  25180. * Gets or sets a skeleton to apply skining transformations
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25182. */
  25183. skeleton: Nullable<Skeleton>;
  25184. /**
  25185. * An event triggered when the mesh is rebuilt.
  25186. */
  25187. onRebuildObservable: Observable<AbstractMesh>;
  25188. /**
  25189. * Creates a new AbstractMesh
  25190. * @param name defines the name of the mesh
  25191. * @param scene defines the hosting scene
  25192. */
  25193. constructor(name: string, scene?: Nullable<Scene>);
  25194. /**
  25195. * Returns the string "AbstractMesh"
  25196. * @returns "AbstractMesh"
  25197. */
  25198. getClassName(): string;
  25199. /**
  25200. * Gets a string representation of the current mesh
  25201. * @param fullDetails defines a boolean indicating if full details must be included
  25202. * @returns a string representation of the current mesh
  25203. */
  25204. toString(fullDetails?: boolean): string;
  25205. /** @hidden */
  25206. _rebuild(): void;
  25207. /** @hidden */
  25208. _resyncLightSources(): void;
  25209. /** @hidden */
  25210. _resyncLighSource(light: Light): void;
  25211. /** @hidden */
  25212. _unBindEffect(): void;
  25213. /** @hidden */
  25214. _removeLightSource(light: Light): void;
  25215. private _markSubMeshesAsDirty;
  25216. /** @hidden */
  25217. _markSubMeshesAsLightDirty(): void;
  25218. /** @hidden */
  25219. _markSubMeshesAsAttributesDirty(): void;
  25220. /** @hidden */
  25221. _markSubMeshesAsMiscDirty(): void;
  25222. /**
  25223. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25224. */
  25225. scaling: Vector3;
  25226. /**
  25227. * Returns true if the mesh is blocked. Implemented by child classes
  25228. */
  25229. readonly isBlocked: boolean;
  25230. /**
  25231. * Returns the mesh itself by default. Implemented by child classes
  25232. * @param camera defines the camera to use to pick the right LOD level
  25233. * @returns the currentAbstractMesh
  25234. */
  25235. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25236. /**
  25237. * Returns 0 by default. Implemented by child classes
  25238. * @returns an integer
  25239. */
  25240. getTotalVertices(): number;
  25241. /**
  25242. * Returns a positive integer : the total number of indices in this mesh geometry.
  25243. * @returns the numner of indices or zero if the mesh has no geometry.
  25244. */
  25245. getTotalIndices(): number;
  25246. /**
  25247. * Returns null by default. Implemented by child classes
  25248. * @returns null
  25249. */
  25250. getIndices(): Nullable<IndicesArray>;
  25251. /**
  25252. * Returns the array of the requested vertex data kind. Implemented by child classes
  25253. * @param kind defines the vertex data kind to use
  25254. * @returns null
  25255. */
  25256. getVerticesData(kind: string): Nullable<FloatArray>;
  25257. /**
  25258. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25259. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25260. * Note that a new underlying VertexBuffer object is created each call.
  25261. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25262. * @param kind defines vertex data kind:
  25263. * * VertexBuffer.PositionKind
  25264. * * VertexBuffer.UVKind
  25265. * * VertexBuffer.UV2Kind
  25266. * * VertexBuffer.UV3Kind
  25267. * * VertexBuffer.UV4Kind
  25268. * * VertexBuffer.UV5Kind
  25269. * * VertexBuffer.UV6Kind
  25270. * * VertexBuffer.ColorKind
  25271. * * VertexBuffer.MatricesIndicesKind
  25272. * * VertexBuffer.MatricesIndicesExtraKind
  25273. * * VertexBuffer.MatricesWeightsKind
  25274. * * VertexBuffer.MatricesWeightsExtraKind
  25275. * @param data defines the data source
  25276. * @param updatable defines if the data must be flagged as updatable (or static)
  25277. * @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
  25278. * @returns the current mesh
  25279. */
  25280. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25281. /**
  25282. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25283. * If the mesh has no geometry, it is simply returned as it is.
  25284. * @param kind defines vertex data kind:
  25285. * * VertexBuffer.PositionKind
  25286. * * VertexBuffer.UVKind
  25287. * * VertexBuffer.UV2Kind
  25288. * * VertexBuffer.UV3Kind
  25289. * * VertexBuffer.UV4Kind
  25290. * * VertexBuffer.UV5Kind
  25291. * * VertexBuffer.UV6Kind
  25292. * * VertexBuffer.ColorKind
  25293. * * VertexBuffer.MatricesIndicesKind
  25294. * * VertexBuffer.MatricesIndicesExtraKind
  25295. * * VertexBuffer.MatricesWeightsKind
  25296. * * VertexBuffer.MatricesWeightsExtraKind
  25297. * @param data defines the data source
  25298. * @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
  25299. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25300. * @returns the current mesh
  25301. */
  25302. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25303. /**
  25304. * Sets the mesh indices,
  25305. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25306. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25307. * @param totalVertices Defines the total number of vertices
  25308. * @returns the current mesh
  25309. */
  25310. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25311. /**
  25312. * Gets a boolean indicating if specific vertex data is present
  25313. * @param kind defines the vertex data kind to use
  25314. * @returns true is data kind is present
  25315. */
  25316. isVerticesDataPresent(kind: string): boolean;
  25317. /**
  25318. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25319. * @returns a BoundingInfo
  25320. */
  25321. getBoundingInfo(): BoundingInfo;
  25322. /**
  25323. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25324. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25325. * @returns the current mesh
  25326. */
  25327. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25328. /**
  25329. * Overwrite the current bounding info
  25330. * @param boundingInfo defines the new bounding info
  25331. * @returns the current mesh
  25332. */
  25333. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25334. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25335. readonly useBones: boolean;
  25336. /** @hidden */
  25337. _preActivate(): void;
  25338. /** @hidden */
  25339. _preActivateForIntermediateRendering(renderId: number): void;
  25340. /** @hidden */
  25341. _activate(renderId: number): void;
  25342. /**
  25343. * Gets the current world matrix
  25344. * @returns a Matrix
  25345. */
  25346. getWorldMatrix(): Matrix;
  25347. /** @hidden */
  25348. _getWorldMatrixDeterminant(): number;
  25349. /**
  25350. * Perform relative position change from the point of view of behind the front of the mesh.
  25351. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25352. * Supports definition of mesh facing forward or backward
  25353. * @param amountRight defines the distance on the right axis
  25354. * @param amountUp defines the distance on the up axis
  25355. * @param amountForward defines the distance on the forward axis
  25356. * @returns the current mesh
  25357. */
  25358. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25359. /**
  25360. * Calculate relative position change from the point of view of behind the front of the mesh.
  25361. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25362. * Supports definition of mesh facing forward or backward
  25363. * @param amountRight defines the distance on the right axis
  25364. * @param amountUp defines the distance on the up axis
  25365. * @param amountForward defines the distance on the forward axis
  25366. * @returns the new displacement vector
  25367. */
  25368. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25369. /**
  25370. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25371. * Supports definition of mesh facing forward or backward
  25372. * @param flipBack defines the flip
  25373. * @param twirlClockwise defines the twirl
  25374. * @param tiltRight defines the tilt
  25375. * @returns the current mesh
  25376. */
  25377. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25378. /**
  25379. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25380. * Supports definition of mesh facing forward or backward.
  25381. * @param flipBack defines the flip
  25382. * @param twirlClockwise defines the twirl
  25383. * @param tiltRight defines the tilt
  25384. * @returns the new rotation vector
  25385. */
  25386. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25387. /**
  25388. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25389. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25390. * @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
  25391. * @returns the new bounding vectors
  25392. */
  25393. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25394. min: Vector3;
  25395. max: Vector3;
  25396. };
  25397. /**
  25398. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25399. * This means the mesh underlying bounding box and sphere are recomputed.
  25400. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25401. * @returns the current mesh
  25402. */
  25403. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25404. /** @hidden */
  25405. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25406. /** @hidden */
  25407. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25408. /** @hidden */
  25409. _updateBoundingInfo(): AbstractMesh;
  25410. /** @hidden */
  25411. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25412. /** @hidden */
  25413. protected _afterComputeWorldMatrix(): void;
  25414. /**
  25415. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25416. * A mesh is in the frustum if its bounding box intersects the frustum
  25417. * @param frustumPlanes defines the frustum to test
  25418. * @returns true if the mesh is in the frustum planes
  25419. */
  25420. isInFrustum(frustumPlanes: Plane[]): boolean;
  25421. /**
  25422. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25423. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25424. * @param frustumPlanes defines the frustum to test
  25425. * @returns true if the mesh is completely in the frustum planes
  25426. */
  25427. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25428. /**
  25429. * True if the mesh intersects another mesh or a SolidParticle object
  25430. * @param mesh defines a target mesh or SolidParticle to test
  25431. * @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)
  25432. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25433. * @returns true if there is an intersection
  25434. */
  25435. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25436. /**
  25437. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25438. * @param point defines the point to test
  25439. * @returns true if there is an intersection
  25440. */
  25441. intersectsPoint(point: Vector3): boolean;
  25442. /**
  25443. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25444. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25445. */
  25446. checkCollisions: boolean;
  25447. /**
  25448. * Gets Collider object used to compute collisions (not physics)
  25449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25450. */
  25451. readonly collider: Collider;
  25452. /**
  25453. * Move the mesh using collision engine
  25454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25455. * @param displacement defines the requested displacement vector
  25456. * @returns the current mesh
  25457. */
  25458. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25459. private _onCollisionPositionChange;
  25460. /** @hidden */
  25461. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25462. /** @hidden */
  25463. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25464. /** @hidden */
  25465. _checkCollision(collider: Collider): AbstractMesh;
  25466. /** @hidden */
  25467. _generatePointsArray(): boolean;
  25468. /**
  25469. * Checks if the passed Ray intersects with the mesh
  25470. * @param ray defines the ray to use
  25471. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25472. * @returns the picking info
  25473. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25474. */
  25475. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25476. /**
  25477. * Clones the current mesh
  25478. * @param name defines the mesh name
  25479. * @param newParent defines the new mesh parent
  25480. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25481. * @returns the new mesh
  25482. */
  25483. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25484. /**
  25485. * Disposes all the submeshes of the current meshnp
  25486. * @returns the current mesh
  25487. */
  25488. releaseSubMeshes(): AbstractMesh;
  25489. /**
  25490. * Releases resources associated with this abstract mesh.
  25491. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25492. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25493. */
  25494. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25495. /**
  25496. * Adds the passed mesh as a child to the current mesh
  25497. * @param mesh defines the child mesh
  25498. * @returns the current mesh
  25499. */
  25500. addChild(mesh: AbstractMesh): AbstractMesh;
  25501. /**
  25502. * Removes the passed mesh from the current mesh children list
  25503. * @param mesh defines the child mesh
  25504. * @returns the current mesh
  25505. */
  25506. removeChild(mesh: AbstractMesh): AbstractMesh;
  25507. /** @hidden */
  25508. private _initFacetData;
  25509. /**
  25510. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25511. * This method can be called within the render loop.
  25512. * 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
  25513. * @returns the current mesh
  25514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25515. */
  25516. updateFacetData(): AbstractMesh;
  25517. /**
  25518. * Returns the facetLocalNormals array.
  25519. * The normals are expressed in the mesh local spac
  25520. * @returns an array of Vector3
  25521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25522. */
  25523. getFacetLocalNormals(): Vector3[];
  25524. /**
  25525. * Returns the facetLocalPositions array.
  25526. * The facet positions are expressed in the mesh local space
  25527. * @returns an array of Vector3
  25528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25529. */
  25530. getFacetLocalPositions(): Vector3[];
  25531. /**
  25532. * Returns the facetLocalPartioning array
  25533. * @returns an array of array of numbers
  25534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25535. */
  25536. getFacetLocalPartitioning(): number[][];
  25537. /**
  25538. * Returns the i-th facet position in the world system.
  25539. * This method allocates a new Vector3 per call
  25540. * @param i defines the facet index
  25541. * @returns a new Vector3
  25542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25543. */
  25544. getFacetPosition(i: number): Vector3;
  25545. /**
  25546. * Sets the reference Vector3 with the i-th facet position in the world system
  25547. * @param i defines the facet index
  25548. * @param ref defines the target vector
  25549. * @returns the current mesh
  25550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25551. */
  25552. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25553. /**
  25554. * Returns the i-th facet normal in the world system.
  25555. * This method allocates a new Vector3 per call
  25556. * @param i defines the facet index
  25557. * @returns a new Vector3
  25558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25559. */
  25560. getFacetNormal(i: number): Vector3;
  25561. /**
  25562. * Sets the reference Vector3 with the i-th facet normal in the world system
  25563. * @param i defines the facet index
  25564. * @param ref defines the target vector
  25565. * @returns the current mesh
  25566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25567. */
  25568. getFacetNormalToRef(i: number, ref: Vector3): this;
  25569. /**
  25570. * 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)
  25571. * @param x defines x coordinate
  25572. * @param y defines y coordinate
  25573. * @param z defines z coordinate
  25574. * @returns the array of facet indexes
  25575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25576. */
  25577. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25578. /**
  25579. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25580. * @param projected sets as the (x,y,z) world projection on the facet
  25581. * @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
  25582. * @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
  25583. * @param x defines x coordinate
  25584. * @param y defines y coordinate
  25585. * @param z defines z coordinate
  25586. * @returns the face index if found (or null instead)
  25587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25588. */
  25589. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25590. /**
  25591. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25592. * @param projected sets as the (x,y,z) local projection on the facet
  25593. * @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
  25594. * @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
  25595. * @param x defines x coordinate
  25596. * @param y defines y coordinate
  25597. * @param z defines z coordinate
  25598. * @returns the face index if found (or null instead)
  25599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25600. */
  25601. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25602. /**
  25603. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25604. * @returns the parameters
  25605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25606. */
  25607. getFacetDataParameters(): any;
  25608. /**
  25609. * Disables the feature FacetData and frees the related memory
  25610. * @returns the current mesh
  25611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25612. */
  25613. disableFacetData(): AbstractMesh;
  25614. /**
  25615. * Updates the AbstractMesh indices array
  25616. * @param indices defines the data source
  25617. * @returns the current mesh
  25618. */
  25619. updateIndices(indices: IndicesArray): AbstractMesh;
  25620. /**
  25621. * Creates new normals data for the mesh
  25622. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25623. * @returns the current mesh
  25624. */
  25625. createNormals(updatable: boolean): AbstractMesh;
  25626. /**
  25627. * Align the mesh with a normal
  25628. * @param normal defines the normal to use
  25629. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25630. * @returns the current mesh
  25631. */
  25632. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25633. /** @hidden */
  25634. _checkOcclusionQuery(): boolean;
  25635. }
  25636. }
  25637. declare module "babylonjs/node" {
  25638. import { Scene } from "babylonjs/scene";
  25639. import { Nullable } from "babylonjs/types";
  25640. import { Matrix } from "babylonjs/Maths/math";
  25641. import { Engine } from "babylonjs/Engines/engine";
  25642. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25643. import { Observable } from "babylonjs/Misc/observable";
  25644. import { Animatable } from "babylonjs/Animations/animatable";
  25645. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25646. import { Animation } from "babylonjs/Animations/animation";
  25647. import { AnimationRange } from "babylonjs/Animations/animation";
  25648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25649. /**
  25650. * Defines how a node can be built from a string name.
  25651. */
  25652. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25653. /**
  25654. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25655. */
  25656. export class Node implements IBehaviorAware<Node> {
  25657. /** @hidden */
  25658. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animation").AnimationRange;
  25659. private static _NodeConstructors;
  25660. /**
  25661. * Add a new node constructor
  25662. * @param type defines the type name of the node to construct
  25663. * @param constructorFunc defines the constructor function
  25664. */
  25665. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25666. /**
  25667. * Returns a node constructor based on type name
  25668. * @param type defines the type name
  25669. * @param name defines the new node name
  25670. * @param scene defines the hosting scene
  25671. * @param options defines optional options to transmit to constructors
  25672. * @returns the new constructor or null
  25673. */
  25674. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25675. /**
  25676. * Gets or sets the name of the node
  25677. */
  25678. name: string;
  25679. /**
  25680. * Gets or sets the id of the node
  25681. */
  25682. id: string;
  25683. /**
  25684. * Gets or sets the unique id of the node
  25685. */
  25686. uniqueId: number;
  25687. /**
  25688. * Gets or sets a string used to store user defined state for the node
  25689. */
  25690. state: string;
  25691. /**
  25692. * Gets or sets an object used to store user defined information for the node
  25693. */
  25694. metadata: any;
  25695. /**
  25696. * For internal use only. Please do not use.
  25697. */
  25698. reservedDataStore: any;
  25699. /**
  25700. * Gets or sets a boolean used to define if the node must be serialized
  25701. */
  25702. doNotSerialize: boolean;
  25703. /** @hidden */
  25704. _isDisposed: boolean;
  25705. /**
  25706. * Gets a list of Animations associated with the node
  25707. */
  25708. animations: import("babylonjs/Animations/animation").Animation[];
  25709. protected _ranges: {
  25710. [name: string]: Nullable<AnimationRange>;
  25711. };
  25712. /**
  25713. * Callback raised when the node is ready to be used
  25714. */
  25715. onReady: (node: Node) => void;
  25716. private _isEnabled;
  25717. private _isParentEnabled;
  25718. private _isReady;
  25719. /** @hidden */
  25720. _currentRenderId: number;
  25721. private _parentRenderId;
  25722. protected _childRenderId: number;
  25723. /** @hidden */
  25724. _waitingParentId: Nullable<string>;
  25725. /** @hidden */
  25726. _scene: Scene;
  25727. /** @hidden */
  25728. _cache: any;
  25729. private _parentNode;
  25730. private _children;
  25731. /** @hidden */
  25732. _worldMatrix: Matrix;
  25733. /** @hidden */
  25734. _worldMatrixDeterminant: number;
  25735. /** @hidden */
  25736. private _sceneRootNodesIndex;
  25737. /**
  25738. * Gets a boolean indicating if the node has been disposed
  25739. * @returns true if the node was disposed
  25740. */
  25741. isDisposed(): boolean;
  25742. /**
  25743. * Gets or sets the parent of the node
  25744. */
  25745. parent: Nullable<Node>;
  25746. private addToSceneRootNodes;
  25747. private removeFromSceneRootNodes;
  25748. private _animationPropertiesOverride;
  25749. /**
  25750. * Gets or sets the animation properties override
  25751. */
  25752. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25753. /**
  25754. * Gets a string idenfifying the name of the class
  25755. * @returns "Node" string
  25756. */
  25757. getClassName(): string;
  25758. /** @hidden */
  25759. readonly _isNode: boolean;
  25760. /**
  25761. * An event triggered when the mesh is disposed
  25762. */
  25763. onDisposeObservable: Observable<Node>;
  25764. private _onDisposeObserver;
  25765. /**
  25766. * Sets a callback that will be raised when the node will be disposed
  25767. */
  25768. onDispose: () => void;
  25769. /**
  25770. * Creates a new Node
  25771. * @param name the name and id to be given to this node
  25772. * @param scene the scene this node will be added to
  25773. * @param addToRootNodes the node will be added to scene.rootNodes
  25774. */
  25775. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25776. /**
  25777. * Gets the scene of the node
  25778. * @returns a scene
  25779. */
  25780. getScene(): Scene;
  25781. /**
  25782. * Gets the engine of the node
  25783. * @returns a Engine
  25784. */
  25785. getEngine(): Engine;
  25786. private _behaviors;
  25787. /**
  25788. * Attach a behavior to the node
  25789. * @see http://doc.babylonjs.com/features/behaviour
  25790. * @param behavior defines the behavior to attach
  25791. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25792. * @returns the current Node
  25793. */
  25794. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25795. /**
  25796. * Remove an attached behavior
  25797. * @see http://doc.babylonjs.com/features/behaviour
  25798. * @param behavior defines the behavior to attach
  25799. * @returns the current Node
  25800. */
  25801. removeBehavior(behavior: Behavior<Node>): Node;
  25802. /**
  25803. * Gets the list of attached behaviors
  25804. * @see http://doc.babylonjs.com/features/behaviour
  25805. */
  25806. readonly behaviors: Behavior<Node>[];
  25807. /**
  25808. * Gets an attached behavior by name
  25809. * @param name defines the name of the behavior to look for
  25810. * @see http://doc.babylonjs.com/features/behaviour
  25811. * @returns null if behavior was not found else the requested behavior
  25812. */
  25813. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25814. /**
  25815. * Returns the latest update of the World matrix
  25816. * @returns a Matrix
  25817. */
  25818. getWorldMatrix(): Matrix;
  25819. /** @hidden */
  25820. _getWorldMatrixDeterminant(): number;
  25821. /**
  25822. * Returns directly the latest state of the mesh World matrix.
  25823. * A Matrix is returned.
  25824. */
  25825. readonly worldMatrixFromCache: Matrix;
  25826. /** @hidden */
  25827. _initCache(): void;
  25828. /** @hidden */
  25829. updateCache(force?: boolean): void;
  25830. /** @hidden */
  25831. _updateCache(ignoreParentClass?: boolean): void;
  25832. /** @hidden */
  25833. _isSynchronized(): boolean;
  25834. /** @hidden */
  25835. _markSyncedWithParent(): void;
  25836. /** @hidden */
  25837. isSynchronizedWithParent(): boolean;
  25838. /** @hidden */
  25839. isSynchronized(): boolean;
  25840. /**
  25841. * Is this node ready to be used/rendered
  25842. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25843. * @return true if the node is ready
  25844. */
  25845. isReady(completeCheck?: boolean): boolean;
  25846. /**
  25847. * Is this node enabled?
  25848. * 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
  25849. * @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
  25850. * @return whether this node (and its parent) is enabled
  25851. */
  25852. isEnabled(checkAncestors?: boolean): boolean;
  25853. /** @hidden */
  25854. protected _syncParentEnabledState(): void;
  25855. /**
  25856. * Set the enabled state of this node
  25857. * @param value defines the new enabled state
  25858. */
  25859. setEnabled(value: boolean): void;
  25860. /**
  25861. * Is this node a descendant of the given node?
  25862. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25863. * @param ancestor defines the parent node to inspect
  25864. * @returns a boolean indicating if this node is a descendant of the given node
  25865. */
  25866. isDescendantOf(ancestor: Node): boolean;
  25867. /** @hidden */
  25868. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25869. /**
  25870. * Will return all nodes that have this node as ascendant
  25871. * @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
  25872. * @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
  25873. * @return all children nodes of all types
  25874. */
  25875. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25876. /**
  25877. * Get all child-meshes of this node
  25878. * @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
  25879. * @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
  25880. * @returns an array of AbstractMesh
  25881. */
  25882. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25883. /**
  25884. * Get all direct children of this node
  25885. * @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
  25886. * @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)
  25887. * @returns an array of Node
  25888. */
  25889. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25890. /** @hidden */
  25891. _setReady(state: boolean): void;
  25892. /**
  25893. * Get an animation by name
  25894. * @param name defines the name of the animation to look for
  25895. * @returns null if not found else the requested animation
  25896. */
  25897. getAnimationByName(name: string): Nullable<Animation>;
  25898. /**
  25899. * Creates an animation range for this node
  25900. * @param name defines the name of the range
  25901. * @param from defines the starting key
  25902. * @param to defines the end key
  25903. */
  25904. createAnimationRange(name: string, from: number, to: number): void;
  25905. /**
  25906. * Delete a specific animation range
  25907. * @param name defines the name of the range to delete
  25908. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25909. */
  25910. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25911. /**
  25912. * Get an animation range by name
  25913. * @param name defines the name of the animation range to look for
  25914. * @returns null if not found else the requested animation range
  25915. */
  25916. getAnimationRange(name: string): Nullable<AnimationRange>;
  25917. /**
  25918. * Will start the animation sequence
  25919. * @param name defines the range frames for animation sequence
  25920. * @param loop defines if the animation should loop (false by default)
  25921. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25922. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25923. * @returns the object created for this animation. If range does not exist, it will return null
  25924. */
  25925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25926. /**
  25927. * Serialize animation ranges into a JSON compatible object
  25928. * @returns serialization object
  25929. */
  25930. serializeAnimationRanges(): any;
  25931. /**
  25932. * Computes the world matrix of the node
  25933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25934. * @returns the world matrix
  25935. */
  25936. computeWorldMatrix(force?: boolean): Matrix;
  25937. /**
  25938. * Releases resources associated with this node.
  25939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25941. */
  25942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25943. /**
  25944. * Parse animation range data from a serialization object and store them into a given node
  25945. * @param node defines where to store the animation ranges
  25946. * @param parsedNode defines the serialization object to read data from
  25947. * @param scene defines the hosting scene
  25948. */
  25949. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25950. }
  25951. }
  25952. declare module "babylonjs/Animations/animation" {
  25953. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25954. import { Path2, Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25955. import { Nullable } from "babylonjs/types";
  25956. import { Scene } from "babylonjs/scene";
  25957. import { IAnimatable } from "babylonjs/Misc/tools";
  25958. import { Node } from "babylonjs/node";
  25959. import { Animatable } from "babylonjs/Animations/animatable";
  25960. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25961. /**
  25962. * Represents the range of an animation
  25963. */
  25964. export class AnimationRange {
  25965. /**The name of the animation range**/
  25966. name: string;
  25967. /**The starting frame of the animation */
  25968. from: number;
  25969. /**The ending frame of the animation*/
  25970. to: number;
  25971. /**
  25972. * Initializes the range of an animation
  25973. * @param name The name of the animation range
  25974. * @param from The starting frame of the animation
  25975. * @param to The ending frame of the animation
  25976. */
  25977. constructor(
  25978. /**The name of the animation range**/
  25979. name: string,
  25980. /**The starting frame of the animation */
  25981. from: number,
  25982. /**The ending frame of the animation*/
  25983. to: number);
  25984. /**
  25985. * Makes a copy of the animation range
  25986. * @returns A copy of the animation range
  25987. */
  25988. clone(): AnimationRange;
  25989. }
  25990. /**
  25991. * Composed of a frame, and an action function
  25992. */
  25993. export class AnimationEvent {
  25994. /** The frame for which the event is triggered **/
  25995. frame: number;
  25996. /** The event to perform when triggered **/
  25997. action: (currentFrame: number) => void;
  25998. /** Specifies if the event should be triggered only once**/
  25999. onlyOnce?: boolean | undefined;
  26000. /**
  26001. * Specifies if the animation event is done
  26002. */
  26003. isDone: boolean;
  26004. /**
  26005. * Initializes the animation event
  26006. * @param frame The frame for which the event is triggered
  26007. * @param action The event to perform when triggered
  26008. * @param onlyOnce Specifies if the event should be triggered only once
  26009. */
  26010. constructor(
  26011. /** The frame for which the event is triggered **/
  26012. frame: number,
  26013. /** The event to perform when triggered **/
  26014. action: (currentFrame: number) => void,
  26015. /** Specifies if the event should be triggered only once**/
  26016. onlyOnce?: boolean | undefined);
  26017. /** @hidden */
  26018. _clone(): AnimationEvent;
  26019. }
  26020. /**
  26021. * A cursor which tracks a point on a path
  26022. */
  26023. export class PathCursor {
  26024. private path;
  26025. /**
  26026. * Stores path cursor callbacks for when an onchange event is triggered
  26027. */
  26028. private _onchange;
  26029. /**
  26030. * The value of the path cursor
  26031. */
  26032. value: number;
  26033. /**
  26034. * The animation array of the path cursor
  26035. */
  26036. animations: Animation[];
  26037. /**
  26038. * Initializes the path cursor
  26039. * @param path The path to track
  26040. */
  26041. constructor(path: Path2);
  26042. /**
  26043. * Gets the cursor point on the path
  26044. * @returns A point on the path cursor at the cursor location
  26045. */
  26046. getPoint(): Vector3;
  26047. /**
  26048. * Moves the cursor ahead by the step amount
  26049. * @param step The amount to move the cursor forward
  26050. * @returns This path cursor
  26051. */
  26052. moveAhead(step?: number): PathCursor;
  26053. /**
  26054. * Moves the cursor behind by the step amount
  26055. * @param step The amount to move the cursor back
  26056. * @returns This path cursor
  26057. */
  26058. moveBack(step?: number): PathCursor;
  26059. /**
  26060. * Moves the cursor by the step amount
  26061. * If the step amount is greater than one, an exception is thrown
  26062. * @param step The amount to move the cursor
  26063. * @returns This path cursor
  26064. */
  26065. move(step: number): PathCursor;
  26066. /**
  26067. * Ensures that the value is limited between zero and one
  26068. * @returns This path cursor
  26069. */
  26070. private ensureLimits;
  26071. /**
  26072. * Runs onchange callbacks on change (used by the animation engine)
  26073. * @returns This path cursor
  26074. */
  26075. private raiseOnChange;
  26076. /**
  26077. * Executes a function on change
  26078. * @param f A path cursor onchange callback
  26079. * @returns This path cursor
  26080. */
  26081. onchange(f: (cursor: PathCursor) => void): PathCursor;
  26082. }
  26083. /**
  26084. * Defines an interface which represents an animation key frame
  26085. */
  26086. export interface IAnimationKey {
  26087. /**
  26088. * Frame of the key frame
  26089. */
  26090. frame: number;
  26091. /**
  26092. * Value at the specifies key frame
  26093. */
  26094. value: any;
  26095. /**
  26096. * The input tangent for the cubic hermite spline
  26097. */
  26098. inTangent?: any;
  26099. /**
  26100. * The output tangent for the cubic hermite spline
  26101. */
  26102. outTangent?: any;
  26103. /**
  26104. * The animation interpolation type
  26105. */
  26106. interpolation?: AnimationKeyInterpolation;
  26107. }
  26108. /**
  26109. * Enum for the animation key frame interpolation type
  26110. */
  26111. export enum AnimationKeyInterpolation {
  26112. /**
  26113. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  26114. */
  26115. STEP = 1
  26116. }
  26117. /**
  26118. * Class used to store any kind of animation
  26119. */
  26120. export class Animation {
  26121. /**Name of the animation */
  26122. name: string;
  26123. /**Property to animate */
  26124. targetProperty: string;
  26125. /**The frames per second of the animation */
  26126. framePerSecond: number;
  26127. /**The data type of the animation */
  26128. dataType: number;
  26129. /**The loop mode of the animation */
  26130. loopMode?: number | undefined;
  26131. /**Specifies if blending should be enabled */
  26132. enableBlending?: boolean | undefined;
  26133. /**
  26134. * Use matrix interpolation instead of using direct key value when animating matrices
  26135. */
  26136. static AllowMatricesInterpolation: boolean;
  26137. /**
  26138. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26139. */
  26140. static AllowMatrixDecomposeForInterpolation: boolean;
  26141. /**
  26142. * Stores the key frames of the animation
  26143. */
  26144. private _keys;
  26145. /**
  26146. * Stores the easing function of the animation
  26147. */
  26148. private _easingFunction;
  26149. /**
  26150. * @hidden Internal use only
  26151. */
  26152. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26153. /**
  26154. * The set of event that will be linked to this animation
  26155. */
  26156. private _events;
  26157. /**
  26158. * Stores an array of target property paths
  26159. */
  26160. targetPropertyPath: string[];
  26161. /**
  26162. * Stores the blending speed of the animation
  26163. */
  26164. blendingSpeed: number;
  26165. /**
  26166. * Stores the animation ranges for the animation
  26167. */
  26168. private _ranges;
  26169. /**
  26170. * @hidden Internal use
  26171. */
  26172. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26173. /**
  26174. * Sets up an animation
  26175. * @param property The property to animate
  26176. * @param animationType The animation type to apply
  26177. * @param framePerSecond The frames per second of the animation
  26178. * @param easingFunction The easing function used in the animation
  26179. * @returns The created animation
  26180. */
  26181. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26182. /**
  26183. * Create and start an animation on a node
  26184. * @param name defines the name of the global animation that will be run on all nodes
  26185. * @param node defines the root node where the animation will take place
  26186. * @param targetProperty defines property to animate
  26187. * @param framePerSecond defines the number of frame per second yo use
  26188. * @param totalFrame defines the number of frames in total
  26189. * @param from defines the initial value
  26190. * @param to defines the final value
  26191. * @param loopMode defines which loop mode you want to use (off by default)
  26192. * @param easingFunction defines the easing function to use (linear by default)
  26193. * @param onAnimationEnd defines the callback to call when animation end
  26194. * @returns the animatable created for this animation
  26195. */
  26196. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26197. /**
  26198. * Create and start an animation on a node and its descendants
  26199. * @param name defines the name of the global animation that will be run on all nodes
  26200. * @param node defines the root node where the animation will take place
  26201. * @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
  26202. * @param targetProperty defines property to animate
  26203. * @param framePerSecond defines the number of frame per second to use
  26204. * @param totalFrame defines the number of frames in total
  26205. * @param from defines the initial value
  26206. * @param to defines the final value
  26207. * @param loopMode defines which loop mode you want to use (off by default)
  26208. * @param easingFunction defines the easing function to use (linear by default)
  26209. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26210. * @returns the list of animatables created for all nodes
  26211. * @example https://www.babylonjs-playground.com/#MH0VLI
  26212. */
  26213. 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[]>;
  26214. /**
  26215. * Creates a new animation, merges it with the existing animations and starts it
  26216. * @param name Name of the animation
  26217. * @param node Node which contains the scene that begins the animations
  26218. * @param targetProperty Specifies which property to animate
  26219. * @param framePerSecond The frames per second of the animation
  26220. * @param totalFrame The total number of frames
  26221. * @param from The frame at the beginning of the animation
  26222. * @param to The frame at the end of the animation
  26223. * @param loopMode Specifies the loop mode of the animation
  26224. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26225. * @param onAnimationEnd Callback to run once the animation is complete
  26226. * @returns Nullable animation
  26227. */
  26228. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26229. /**
  26230. * Transition property of an host to the target Value
  26231. * @param property The property to transition
  26232. * @param targetValue The target Value of the property
  26233. * @param host The object where the property to animate belongs
  26234. * @param scene Scene used to run the animation
  26235. * @param frameRate Framerate (in frame/s) to use
  26236. * @param transition The transition type we want to use
  26237. * @param duration The duration of the animation, in milliseconds
  26238. * @param onAnimationEnd Callback trigger at the end of the animation
  26239. * @returns Nullable animation
  26240. */
  26241. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26242. /**
  26243. * Return the array of runtime animations currently using this animation
  26244. */
  26245. readonly runtimeAnimations: RuntimeAnimation[];
  26246. /**
  26247. * Specifies if any of the runtime animations are currently running
  26248. */
  26249. readonly hasRunningRuntimeAnimations: boolean;
  26250. /**
  26251. * Initializes the animation
  26252. * @param name Name of the animation
  26253. * @param targetProperty Property to animate
  26254. * @param framePerSecond The frames per second of the animation
  26255. * @param dataType The data type of the animation
  26256. * @param loopMode The loop mode of the animation
  26257. * @param enableBlendings Specifies if blending should be enabled
  26258. */
  26259. constructor(
  26260. /**Name of the animation */
  26261. name: string,
  26262. /**Property to animate */
  26263. targetProperty: string,
  26264. /**The frames per second of the animation */
  26265. framePerSecond: number,
  26266. /**The data type of the animation */
  26267. dataType: number,
  26268. /**The loop mode of the animation */
  26269. loopMode?: number | undefined,
  26270. /**Specifies if blending should be enabled */
  26271. enableBlending?: boolean | undefined);
  26272. /**
  26273. * Converts the animation to a string
  26274. * @param fullDetails support for multiple levels of logging within scene loading
  26275. * @returns String form of the animation
  26276. */
  26277. toString(fullDetails?: boolean): string;
  26278. /**
  26279. * Add an event to this animation
  26280. * @param event Event to add
  26281. */
  26282. addEvent(event: AnimationEvent): void;
  26283. /**
  26284. * Remove all events found at the given frame
  26285. * @param frame The frame to remove events from
  26286. */
  26287. removeEvents(frame: number): void;
  26288. /**
  26289. * Retrieves all the events from the animation
  26290. * @returns Events from the animation
  26291. */
  26292. getEvents(): AnimationEvent[];
  26293. /**
  26294. * Creates an animation range
  26295. * @param name Name of the animation range
  26296. * @param from Starting frame of the animation range
  26297. * @param to Ending frame of the animation
  26298. */
  26299. createRange(name: string, from: number, to: number): void;
  26300. /**
  26301. * Deletes an animation range by name
  26302. * @param name Name of the animation range to delete
  26303. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26304. */
  26305. deleteRange(name: string, deleteFrames?: boolean): void;
  26306. /**
  26307. * Gets the animation range by name, or null if not defined
  26308. * @param name Name of the animation range
  26309. * @returns Nullable animation range
  26310. */
  26311. getRange(name: string): Nullable<AnimationRange>;
  26312. /**
  26313. * Gets the key frames from the animation
  26314. * @returns The key frames of the animation
  26315. */
  26316. getKeys(): Array<IAnimationKey>;
  26317. /**
  26318. * Gets the highest frame rate of the animation
  26319. * @returns Highest frame rate of the animation
  26320. */
  26321. getHighestFrame(): number;
  26322. /**
  26323. * Gets the easing function of the animation
  26324. * @returns Easing function of the animation
  26325. */
  26326. getEasingFunction(): IEasingFunction;
  26327. /**
  26328. * Sets the easing function of the animation
  26329. * @param easingFunction A custom mathematical formula for animation
  26330. */
  26331. setEasingFunction(easingFunction: EasingFunction): void;
  26332. /**
  26333. * Interpolates a scalar linearly
  26334. * @param startValue Start value of the animation curve
  26335. * @param endValue End value of the animation curve
  26336. * @param gradient Scalar amount to interpolate
  26337. * @returns Interpolated scalar value
  26338. */
  26339. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26340. /**
  26341. * Interpolates a scalar cubically
  26342. * @param startValue Start value of the animation curve
  26343. * @param outTangent End tangent of the animation
  26344. * @param endValue End value of the animation curve
  26345. * @param inTangent Start tangent of the animation curve
  26346. * @param gradient Scalar amount to interpolate
  26347. * @returns Interpolated scalar value
  26348. */
  26349. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26350. /**
  26351. * Interpolates a quaternion using a spherical linear interpolation
  26352. * @param startValue Start value of the animation curve
  26353. * @param endValue End value of the animation curve
  26354. * @param gradient Scalar amount to interpolate
  26355. * @returns Interpolated quaternion value
  26356. */
  26357. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26358. /**
  26359. * Interpolates a quaternion cubically
  26360. * @param startValue Start value of the animation curve
  26361. * @param outTangent End tangent of the animation curve
  26362. * @param endValue End value of the animation curve
  26363. * @param inTangent Start tangent of the animation curve
  26364. * @param gradient Scalar amount to interpolate
  26365. * @returns Interpolated quaternion value
  26366. */
  26367. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26368. /**
  26369. * Interpolates a Vector3 linearl
  26370. * @param startValue Start value of the animation curve
  26371. * @param endValue End value of the animation curve
  26372. * @param gradient Scalar amount to interpolate
  26373. * @returns Interpolated scalar value
  26374. */
  26375. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26376. /**
  26377. * Interpolates a Vector3 cubically
  26378. * @param startValue Start value of the animation curve
  26379. * @param outTangent End tangent of the animation
  26380. * @param endValue End value of the animation curve
  26381. * @param inTangent Start tangent of the animation curve
  26382. * @param gradient Scalar amount to interpolate
  26383. * @returns InterpolatedVector3 value
  26384. */
  26385. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26386. /**
  26387. * Interpolates a Vector2 linearly
  26388. * @param startValue Start value of the animation curve
  26389. * @param endValue End value of the animation curve
  26390. * @param gradient Scalar amount to interpolate
  26391. * @returns Interpolated Vector2 value
  26392. */
  26393. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26394. /**
  26395. * Interpolates a Vector2 cubically
  26396. * @param startValue Start value of the animation curve
  26397. * @param outTangent End tangent of the animation
  26398. * @param endValue End value of the animation curve
  26399. * @param inTangent Start tangent of the animation curve
  26400. * @param gradient Scalar amount to interpolate
  26401. * @returns Interpolated Vector2 value
  26402. */
  26403. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26404. /**
  26405. * Interpolates a size linearly
  26406. * @param startValue Start value of the animation curve
  26407. * @param endValue End value of the animation curve
  26408. * @param gradient Scalar amount to interpolate
  26409. * @returns Interpolated Size value
  26410. */
  26411. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26412. /**
  26413. * Interpolates a Color3 linearly
  26414. * @param startValue Start value of the animation curve
  26415. * @param endValue End value of the animation curve
  26416. * @param gradient Scalar amount to interpolate
  26417. * @returns Interpolated Color3 value
  26418. */
  26419. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26420. /**
  26421. * @hidden Internal use only
  26422. */
  26423. _getKeyValue(value: any): any;
  26424. /**
  26425. * @hidden Internal use only
  26426. */
  26427. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26428. /**
  26429. * Defines the function to use to interpolate matrices
  26430. * @param startValue defines the start matrix
  26431. * @param endValue defines the end matrix
  26432. * @param gradient defines the gradient between both matrices
  26433. * @param result defines an optional target matrix where to store the interpolation
  26434. * @returns the interpolated matrix
  26435. */
  26436. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26437. /**
  26438. * Makes a copy of the animation
  26439. * @returns Cloned animation
  26440. */
  26441. clone(): Animation;
  26442. /**
  26443. * Sets the key frames of the animation
  26444. * @param values The animation key frames to set
  26445. */
  26446. setKeys(values: Array<IAnimationKey>): void;
  26447. /**
  26448. * Serializes the animation to an object
  26449. * @returns Serialized object
  26450. */
  26451. serialize(): any;
  26452. /**
  26453. * Float animation type
  26454. */
  26455. private static _ANIMATIONTYPE_FLOAT;
  26456. /**
  26457. * Vector3 animation type
  26458. */
  26459. private static _ANIMATIONTYPE_VECTOR3;
  26460. /**
  26461. * Quaternion animation type
  26462. */
  26463. private static _ANIMATIONTYPE_QUATERNION;
  26464. /**
  26465. * Matrix animation type
  26466. */
  26467. private static _ANIMATIONTYPE_MATRIX;
  26468. /**
  26469. * Color3 animation type
  26470. */
  26471. private static _ANIMATIONTYPE_COLOR3;
  26472. /**
  26473. * Vector2 animation type
  26474. */
  26475. private static _ANIMATIONTYPE_VECTOR2;
  26476. /**
  26477. * Size animation type
  26478. */
  26479. private static _ANIMATIONTYPE_SIZE;
  26480. /**
  26481. * Relative Loop Mode
  26482. */
  26483. private static _ANIMATIONLOOPMODE_RELATIVE;
  26484. /**
  26485. * Cycle Loop Mode
  26486. */
  26487. private static _ANIMATIONLOOPMODE_CYCLE;
  26488. /**
  26489. * Constant Loop Mode
  26490. */
  26491. private static _ANIMATIONLOOPMODE_CONSTANT;
  26492. /**
  26493. * Get the float animation type
  26494. */
  26495. static readonly ANIMATIONTYPE_FLOAT: number;
  26496. /**
  26497. * Get the Vector3 animation type
  26498. */
  26499. static readonly ANIMATIONTYPE_VECTOR3: number;
  26500. /**
  26501. * Get the Vector2 animation type
  26502. */
  26503. static readonly ANIMATIONTYPE_VECTOR2: number;
  26504. /**
  26505. * Get the Size animation type
  26506. */
  26507. static readonly ANIMATIONTYPE_SIZE: number;
  26508. /**
  26509. * Get the Quaternion animation type
  26510. */
  26511. static readonly ANIMATIONTYPE_QUATERNION: number;
  26512. /**
  26513. * Get the Matrix animation type
  26514. */
  26515. static readonly ANIMATIONTYPE_MATRIX: number;
  26516. /**
  26517. * Get the Color3 animation type
  26518. */
  26519. static readonly ANIMATIONTYPE_COLOR3: number;
  26520. /**
  26521. * Get the Relative Loop Mode
  26522. */
  26523. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26524. /**
  26525. * Get the Cycle Loop Mode
  26526. */
  26527. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26528. /**
  26529. * Get the Constant Loop Mode
  26530. */
  26531. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26532. /** @hidden */
  26533. static _UniversalLerp(left: any, right: any, amount: number): any;
  26534. /**
  26535. * Parses an animation object and creates an animation
  26536. * @param parsedAnimation Parsed animation object
  26537. * @returns Animation object
  26538. */
  26539. static Parse(parsedAnimation: any): Animation;
  26540. /**
  26541. * Appends the serialized animations from the source animations
  26542. * @param source Source containing the animations
  26543. * @param destination Target to store the animations
  26544. */
  26545. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26546. }
  26547. }
  26548. declare module "babylonjs/Materials/Textures/baseTexture" {
  26549. import { Observable } from "babylonjs/Misc/observable";
  26550. import { IAnimatable } from "babylonjs/Misc/tools";
  26551. import { Nullable } from "babylonjs/types";
  26552. import { Scene } from "babylonjs/scene";
  26553. import { Matrix, ISize } from "babylonjs/Maths/math";
  26554. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26555. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26556. /**
  26557. * Base class of all the textures in babylon.
  26558. * It groups all the common properties the materials, post process, lights... might need
  26559. * in order to make a correct use of the texture.
  26560. */
  26561. export class BaseTexture implements IAnimatable {
  26562. /**
  26563. * Default anisotropic filtering level for the application.
  26564. * It is set to 4 as a good tradeoff between perf and quality.
  26565. */
  26566. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26567. /**
  26568. * Gets or sets the unique id of the texture
  26569. */
  26570. uniqueId: number;
  26571. /**
  26572. * Define the name of the texture.
  26573. */
  26574. name: string;
  26575. /**
  26576. * Gets or sets an object used to store user defined information.
  26577. */
  26578. metadata: any;
  26579. /**
  26580. * For internal use only. Please do not use.
  26581. */
  26582. reservedDataStore: any;
  26583. private _hasAlpha;
  26584. /**
  26585. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26586. */
  26587. hasAlpha: boolean;
  26588. /**
  26589. * Defines if the alpha value should be determined via the rgb values.
  26590. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26591. */
  26592. getAlphaFromRGB: boolean;
  26593. /**
  26594. * Intensity or strength of the texture.
  26595. * It is commonly used by materials to fine tune the intensity of the texture
  26596. */
  26597. level: number;
  26598. /**
  26599. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26600. * This is part of the texture as textures usually maps to one uv set.
  26601. */
  26602. coordinatesIndex: number;
  26603. private _coordinatesMode;
  26604. /**
  26605. * How a texture is mapped.
  26606. *
  26607. * | Value | Type | Description |
  26608. * | ----- | ----------------------------------- | ----------- |
  26609. * | 0 | EXPLICIT_MODE | |
  26610. * | 1 | SPHERICAL_MODE | |
  26611. * | 2 | PLANAR_MODE | |
  26612. * | 3 | CUBIC_MODE | |
  26613. * | 4 | PROJECTION_MODE | |
  26614. * | 5 | SKYBOX_MODE | |
  26615. * | 6 | INVCUBIC_MODE | |
  26616. * | 7 | EQUIRECTANGULAR_MODE | |
  26617. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26618. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26619. */
  26620. coordinatesMode: number;
  26621. /**
  26622. * | Value | Type | Description |
  26623. * | ----- | ------------------ | ----------- |
  26624. * | 0 | CLAMP_ADDRESSMODE | |
  26625. * | 1 | WRAP_ADDRESSMODE | |
  26626. * | 2 | MIRROR_ADDRESSMODE | |
  26627. */
  26628. wrapU: number;
  26629. /**
  26630. * | Value | Type | Description |
  26631. * | ----- | ------------------ | ----------- |
  26632. * | 0 | CLAMP_ADDRESSMODE | |
  26633. * | 1 | WRAP_ADDRESSMODE | |
  26634. * | 2 | MIRROR_ADDRESSMODE | |
  26635. */
  26636. wrapV: number;
  26637. /**
  26638. * | Value | Type | Description |
  26639. * | ----- | ------------------ | ----------- |
  26640. * | 0 | CLAMP_ADDRESSMODE | |
  26641. * | 1 | WRAP_ADDRESSMODE | |
  26642. * | 2 | MIRROR_ADDRESSMODE | |
  26643. */
  26644. wrapR: number;
  26645. /**
  26646. * With compliant hardware and browser (supporting anisotropic filtering)
  26647. * this defines the level of anisotropic filtering in the texture.
  26648. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26649. */
  26650. anisotropicFilteringLevel: number;
  26651. /**
  26652. * Define if the texture is a cube texture or if false a 2d texture.
  26653. */
  26654. isCube: boolean;
  26655. /**
  26656. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26657. */
  26658. is3D: boolean;
  26659. /**
  26660. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26661. * HDR texture are usually stored in linear space.
  26662. * This only impacts the PBR and Background materials
  26663. */
  26664. gammaSpace: boolean;
  26665. /**
  26666. * Gets whether or not the texture contains RGBD data.
  26667. */
  26668. readonly isRGBD: boolean;
  26669. /**
  26670. * Is Z inverted in the texture (useful in a cube texture).
  26671. */
  26672. invertZ: boolean;
  26673. /**
  26674. * Are mip maps generated for this texture or not.
  26675. */
  26676. readonly noMipmap: boolean;
  26677. /**
  26678. * @hidden
  26679. */
  26680. lodLevelInAlpha: boolean;
  26681. /**
  26682. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26683. */
  26684. lodGenerationOffset: number;
  26685. /**
  26686. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26687. */
  26688. lodGenerationScale: number;
  26689. /**
  26690. * Define if the texture is a render target.
  26691. */
  26692. isRenderTarget: boolean;
  26693. /**
  26694. * Define the unique id of the texture in the scene.
  26695. */
  26696. readonly uid: string;
  26697. /**
  26698. * Return a string representation of the texture.
  26699. * @returns the texture as a string
  26700. */
  26701. toString(): string;
  26702. /**
  26703. * Get the class name of the texture.
  26704. * @returns "BaseTexture"
  26705. */
  26706. getClassName(): string;
  26707. /**
  26708. * Define the list of animation attached to the texture.
  26709. */
  26710. animations: import("babylonjs/Animations/animation").Animation[];
  26711. /**
  26712. * An event triggered when the texture is disposed.
  26713. */
  26714. onDisposeObservable: Observable<BaseTexture>;
  26715. private _onDisposeObserver;
  26716. /**
  26717. * Callback triggered when the texture has been disposed.
  26718. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26719. */
  26720. onDispose: () => void;
  26721. /**
  26722. * Define the current state of the loading sequence when in delayed load mode.
  26723. */
  26724. delayLoadState: number;
  26725. private _scene;
  26726. /** @hidden */
  26727. _texture: Nullable<InternalTexture>;
  26728. private _uid;
  26729. /**
  26730. * Define if the texture is preventinga material to render or not.
  26731. * If not and the texture is not ready, the engine will use a default black texture instead.
  26732. */
  26733. readonly isBlocking: boolean;
  26734. /**
  26735. * Instantiates a new BaseTexture.
  26736. * Base class of all the textures in babylon.
  26737. * It groups all the common properties the materials, post process, lights... might need
  26738. * in order to make a correct use of the texture.
  26739. * @param scene Define the scene the texture blongs to
  26740. */
  26741. constructor(scene: Nullable<Scene>);
  26742. /**
  26743. * Get the scene the texture belongs to.
  26744. * @returns the scene or null if undefined
  26745. */
  26746. getScene(): Nullable<Scene>;
  26747. /**
  26748. * Get the texture transform matrix used to offset tile the texture for istance.
  26749. * @returns the transformation matrix
  26750. */
  26751. getTextureMatrix(): Matrix;
  26752. /**
  26753. * Get the texture reflection matrix used to rotate/transform the reflection.
  26754. * @returns the reflection matrix
  26755. */
  26756. getReflectionTextureMatrix(): Matrix;
  26757. /**
  26758. * Get the underlying lower level texture from Babylon.
  26759. * @returns the insternal texture
  26760. */
  26761. getInternalTexture(): Nullable<InternalTexture>;
  26762. /**
  26763. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26764. * @returns true if ready or not blocking
  26765. */
  26766. isReadyOrNotBlocking(): boolean;
  26767. /**
  26768. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26769. * @returns true if fully ready
  26770. */
  26771. isReady(): boolean;
  26772. private _cachedSize;
  26773. /**
  26774. * Get the size of the texture.
  26775. * @returns the texture size.
  26776. */
  26777. getSize(): ISize;
  26778. /**
  26779. * Get the base size of the texture.
  26780. * It can be different from the size if the texture has been resized for POT for instance
  26781. * @returns the base size
  26782. */
  26783. getBaseSize(): ISize;
  26784. /**
  26785. * Update the sampling mode of the texture.
  26786. * Default is Trilinear mode.
  26787. *
  26788. * | Value | Type | Description |
  26789. * | ----- | ------------------ | ----------- |
  26790. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26791. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26792. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26793. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26794. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26795. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26796. * | 7 | NEAREST_LINEAR | |
  26797. * | 8 | NEAREST_NEAREST | |
  26798. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26799. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26800. * | 11 | LINEAR_LINEAR | |
  26801. * | 12 | LINEAR_NEAREST | |
  26802. *
  26803. * > _mag_: magnification filter (close to the viewer)
  26804. * > _min_: minification filter (far from the viewer)
  26805. * > _mip_: filter used between mip map levels
  26806. *@param samplingMode Define the new sampling mode of the texture
  26807. */
  26808. updateSamplingMode(samplingMode: number): void;
  26809. /**
  26810. * Scales the texture if is `canRescale()`
  26811. * @param ratio the resize factor we want to use to rescale
  26812. */
  26813. scale(ratio: number): void;
  26814. /**
  26815. * Get if the texture can rescale.
  26816. */
  26817. readonly canRescale: boolean;
  26818. /** @hidden */
  26819. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26820. /** @hidden */
  26821. _rebuild(): void;
  26822. /**
  26823. * Triggers the load sequence in delayed load mode.
  26824. */
  26825. delayLoad(): void;
  26826. /**
  26827. * Clones the texture.
  26828. * @returns the cloned texture
  26829. */
  26830. clone(): Nullable<BaseTexture>;
  26831. /**
  26832. * Get the texture underlying type (INT, FLOAT...)
  26833. */
  26834. readonly textureType: number;
  26835. /**
  26836. * Get the texture underlying format (RGB, RGBA...)
  26837. */
  26838. readonly textureFormat: number;
  26839. /**
  26840. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26841. * This will returns an RGBA array buffer containing either in values (0-255) or
  26842. * float values (0-1) depending of the underlying buffer type.
  26843. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26844. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26845. * @param buffer defines a user defined buffer to fill with data (can be null)
  26846. * @returns The Array buffer containing the pixels data.
  26847. */
  26848. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26849. /**
  26850. * Release and destroy the underlying lower level texture aka internalTexture.
  26851. */
  26852. releaseInternalTexture(): void;
  26853. /**
  26854. * Get the polynomial representation of the texture data.
  26855. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26856. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26857. */
  26858. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26859. /** @hidden */
  26860. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26861. /** @hidden */
  26862. readonly _lodTextureMid: Nullable<BaseTexture>;
  26863. /** @hidden */
  26864. readonly _lodTextureLow: Nullable<BaseTexture>;
  26865. /**
  26866. * Dispose the texture and release its associated resources.
  26867. */
  26868. dispose(): void;
  26869. /**
  26870. * Serialize the texture into a JSON representation that can be parsed later on.
  26871. * @returns the JSON representation of the texture
  26872. */
  26873. serialize(): any;
  26874. /**
  26875. * Helper function to be called back once a list of texture contains only ready textures.
  26876. * @param textures Define the list of textures to wait for
  26877. * @param callback Define the callback triggered once the entire list will be ready
  26878. */
  26879. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26880. }
  26881. }
  26882. declare module "babylonjs/Materials/uniformBuffer" {
  26883. import { Nullable, FloatArray } from "babylonjs/types";
  26884. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26885. import { Engine } from "babylonjs/Engines/engine";
  26886. import { Effect } from "babylonjs/Materials/effect";
  26887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26888. /**
  26889. * Uniform buffer objects.
  26890. *
  26891. * Handles blocks of uniform on the GPU.
  26892. *
  26893. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26894. *
  26895. * For more information, please refer to :
  26896. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26897. */
  26898. export class UniformBuffer {
  26899. private _engine;
  26900. private _buffer;
  26901. private _data;
  26902. private _bufferData;
  26903. private _dynamic?;
  26904. private _uniformLocations;
  26905. private _uniformSizes;
  26906. private _uniformLocationPointer;
  26907. private _needSync;
  26908. private _noUBO;
  26909. private _currentEffect;
  26910. private static _MAX_UNIFORM_SIZE;
  26911. private static _tempBuffer;
  26912. /**
  26913. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26914. * This is dynamic to allow compat with webgl 1 and 2.
  26915. * You will need to pass the name of the uniform as well as the value.
  26916. */
  26917. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26918. /**
  26919. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26920. * This is dynamic to allow compat with webgl 1 and 2.
  26921. * You will need to pass the name of the uniform as well as the value.
  26922. */
  26923. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26924. /**
  26925. * Lambda to Update a single float in a uniform buffer.
  26926. * This is dynamic to allow compat with webgl 1 and 2.
  26927. * You will need to pass the name of the uniform as well as the value.
  26928. */
  26929. updateFloat: (name: string, x: number) => void;
  26930. /**
  26931. * Lambda to Update a vec2 of float in a uniform buffer.
  26932. * This is dynamic to allow compat with webgl 1 and 2.
  26933. * You will need to pass the name of the uniform as well as the value.
  26934. */
  26935. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26936. /**
  26937. * Lambda to Update a vec3 of float in a uniform buffer.
  26938. * This is dynamic to allow compat with webgl 1 and 2.
  26939. * You will need to pass the name of the uniform as well as the value.
  26940. */
  26941. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26942. /**
  26943. * Lambda to Update a vec4 of float in a uniform buffer.
  26944. * This is dynamic to allow compat with webgl 1 and 2.
  26945. * You will need to pass the name of the uniform as well as the value.
  26946. */
  26947. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26948. /**
  26949. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26950. * This is dynamic to allow compat with webgl 1 and 2.
  26951. * You will need to pass the name of the uniform as well as the value.
  26952. */
  26953. updateMatrix: (name: string, mat: Matrix) => void;
  26954. /**
  26955. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26956. * This is dynamic to allow compat with webgl 1 and 2.
  26957. * You will need to pass the name of the uniform as well as the value.
  26958. */
  26959. updateVector3: (name: string, vector: Vector3) => void;
  26960. /**
  26961. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26962. * This is dynamic to allow compat with webgl 1 and 2.
  26963. * You will need to pass the name of the uniform as well as the value.
  26964. */
  26965. updateVector4: (name: string, vector: Vector4) => void;
  26966. /**
  26967. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26968. * This is dynamic to allow compat with webgl 1 and 2.
  26969. * You will need to pass the name of the uniform as well as the value.
  26970. */
  26971. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26972. /**
  26973. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26974. * This is dynamic to allow compat with webgl 1 and 2.
  26975. * You will need to pass the name of the uniform as well as the value.
  26976. */
  26977. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26978. /**
  26979. * Instantiates a new Uniform buffer objects.
  26980. *
  26981. * Handles blocks of uniform on the GPU.
  26982. *
  26983. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26984. *
  26985. * For more information, please refer to :
  26986. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26987. * @param engine Define the engine the buffer is associated with
  26988. * @param data Define the data contained in the buffer
  26989. * @param dynamic Define if the buffer is updatable
  26990. */
  26991. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26992. /**
  26993. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26994. * or just falling back on setUniformXXX calls.
  26995. */
  26996. readonly useUbo: boolean;
  26997. /**
  26998. * Indicates if the WebGL underlying uniform buffer is in sync
  26999. * with the javascript cache data.
  27000. */
  27001. readonly isSync: boolean;
  27002. /**
  27003. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27004. * Also, a dynamic UniformBuffer will disable cache verification and always
  27005. * update the underlying WebGL uniform buffer to the GPU.
  27006. * @returns if Dynamic, otherwise false
  27007. */
  27008. isDynamic(): boolean;
  27009. /**
  27010. * The data cache on JS side.
  27011. * @returns the underlying data as a float array
  27012. */
  27013. getData(): Float32Array;
  27014. /**
  27015. * The underlying WebGL Uniform buffer.
  27016. * @returns the webgl buffer
  27017. */
  27018. getBuffer(): Nullable<WebGLBuffer>;
  27019. /**
  27020. * std140 layout specifies how to align data within an UBO structure.
  27021. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27022. * for specs.
  27023. */
  27024. private _fillAlignment;
  27025. /**
  27026. * Adds an uniform in the buffer.
  27027. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27028. * for the layout to be correct !
  27029. * @param name Name of the uniform, as used in the uniform block in the shader.
  27030. * @param size Data size, or data directly.
  27031. */
  27032. addUniform(name: string, size: number | number[]): void;
  27033. /**
  27034. * Adds a Matrix 4x4 to the uniform buffer.
  27035. * @param name Name of the uniform, as used in the uniform block in the shader.
  27036. * @param mat A 4x4 matrix.
  27037. */
  27038. addMatrix(name: string, mat: Matrix): void;
  27039. /**
  27040. * Adds a vec2 to the uniform buffer.
  27041. * @param name Name of the uniform, as used in the uniform block in the shader.
  27042. * @param x Define the x component value of the vec2
  27043. * @param y Define the y component value of the vec2
  27044. */
  27045. addFloat2(name: string, x: number, y: number): void;
  27046. /**
  27047. * Adds a vec3 to the uniform buffer.
  27048. * @param name Name of the uniform, as used in the uniform block in the shader.
  27049. * @param x Define the x component value of the vec3
  27050. * @param y Define the y component value of the vec3
  27051. * @param z Define the z component value of the vec3
  27052. */
  27053. addFloat3(name: string, x: number, y: number, z: number): void;
  27054. /**
  27055. * Adds a vec3 to the uniform buffer.
  27056. * @param name Name of the uniform, as used in the uniform block in the shader.
  27057. * @param color Define the vec3 from a Color
  27058. */
  27059. addColor3(name: string, color: Color3): void;
  27060. /**
  27061. * Adds a vec4 to the uniform buffer.
  27062. * @param name Name of the uniform, as used in the uniform block in the shader.
  27063. * @param color Define the rgb components from a Color
  27064. * @param alpha Define the a component of the vec4
  27065. */
  27066. addColor4(name: string, color: Color3, alpha: number): void;
  27067. /**
  27068. * Adds a vec3 to the uniform buffer.
  27069. * @param name Name of the uniform, as used in the uniform block in the shader.
  27070. * @param vector Define the vec3 components from a Vector
  27071. */
  27072. addVector3(name: string, vector: Vector3): void;
  27073. /**
  27074. * Adds a Matrix 3x3 to the uniform buffer.
  27075. * @param name Name of the uniform, as used in the uniform block in the shader.
  27076. */
  27077. addMatrix3x3(name: string): void;
  27078. /**
  27079. * Adds a Matrix 2x2 to the uniform buffer.
  27080. * @param name Name of the uniform, as used in the uniform block in the shader.
  27081. */
  27082. addMatrix2x2(name: string): void;
  27083. /**
  27084. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27085. */
  27086. create(): void;
  27087. /** @hidden */
  27088. _rebuild(): void;
  27089. /**
  27090. * Updates the WebGL Uniform Buffer on the GPU.
  27091. * If the `dynamic` flag is set to true, no cache comparison is done.
  27092. * Otherwise, the buffer will be updated only if the cache differs.
  27093. */
  27094. update(): void;
  27095. /**
  27096. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27097. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27098. * @param data Define the flattened data
  27099. * @param size Define the size of the data.
  27100. */
  27101. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27102. private _updateMatrix3x3ForUniform;
  27103. private _updateMatrix3x3ForEffect;
  27104. private _updateMatrix2x2ForEffect;
  27105. private _updateMatrix2x2ForUniform;
  27106. private _updateFloatForEffect;
  27107. private _updateFloatForUniform;
  27108. private _updateFloat2ForEffect;
  27109. private _updateFloat2ForUniform;
  27110. private _updateFloat3ForEffect;
  27111. private _updateFloat3ForUniform;
  27112. private _updateFloat4ForEffect;
  27113. private _updateFloat4ForUniform;
  27114. private _updateMatrixForEffect;
  27115. private _updateMatrixForUniform;
  27116. private _updateVector3ForEffect;
  27117. private _updateVector3ForUniform;
  27118. private _updateVector4ForEffect;
  27119. private _updateVector4ForUniform;
  27120. private _updateColor3ForEffect;
  27121. private _updateColor3ForUniform;
  27122. private _updateColor4ForEffect;
  27123. private _updateColor4ForUniform;
  27124. /**
  27125. * Sets a sampler uniform on the effect.
  27126. * @param name Define the name of the sampler.
  27127. * @param texture Define the texture to set in the sampler
  27128. */
  27129. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27130. /**
  27131. * Directly updates the value of the uniform in the cache AND on the GPU.
  27132. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27133. * @param data Define the flattened data
  27134. */
  27135. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27136. /**
  27137. * Binds this uniform buffer to an effect.
  27138. * @param effect Define the effect to bind the buffer to
  27139. * @param name Name of the uniform block in the shader.
  27140. */
  27141. bindToEffect(effect: Effect, name: string): void;
  27142. /**
  27143. * Disposes the uniform buffer.
  27144. */
  27145. dispose(): void;
  27146. }
  27147. }
  27148. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  27149. import { Nullable } from "babylonjs/types";
  27150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27151. /**
  27152. * This represents the required contract to create a new type of texture loader.
  27153. */
  27154. export interface IInternalTextureLoader {
  27155. /**
  27156. * Defines wether the loader supports cascade loading the different faces.
  27157. */
  27158. supportCascades: boolean;
  27159. /**
  27160. * This returns if the loader support the current file information.
  27161. * @param extension defines the file extension of the file being loaded
  27162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27163. * @param fallback defines the fallback internal texture if any
  27164. * @param isBase64 defines whether the texture is encoded as a base64
  27165. * @param isBuffer defines whether the texture data are stored as a buffer
  27166. * @returns true if the loader can load the specified file
  27167. */
  27168. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  27169. /**
  27170. * Transform the url before loading if required.
  27171. * @param rootUrl the url of the texture
  27172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27173. * @returns the transformed texture
  27174. */
  27175. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  27176. /**
  27177. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  27178. * @param rootUrl the url of the texture
  27179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27180. * @returns the fallback texture
  27181. */
  27182. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  27183. /**
  27184. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  27185. * @param data contains the texture data
  27186. * @param texture defines the BabylonJS internal texture
  27187. * @param createPolynomials will be true if polynomials have been requested
  27188. * @param onLoad defines the callback to trigger once the texture is ready
  27189. * @param onError defines the callback to trigger in case of error
  27190. */
  27191. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  27192. /**
  27193. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  27194. * @param data contains the texture data
  27195. * @param texture defines the BabylonJS internal texture
  27196. * @param callback defines the method to call once ready to upload
  27197. */
  27198. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  27199. }
  27200. }
  27201. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  27202. import { Scene } from "babylonjs/scene";
  27203. import { Engine } from "babylonjs/Engines/engine";
  27204. import { Texture } from "babylonjs/Materials/Textures/texture";
  27205. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27206. /**
  27207. * Creation options of the multi render target texture.
  27208. */
  27209. export interface IMultiRenderTargetOptions {
  27210. /**
  27211. * Define if the texture needs to create mip maps after render.
  27212. */
  27213. generateMipMaps?: boolean;
  27214. /**
  27215. * Define the types of all the draw buffers we want to create
  27216. */
  27217. types?: number[];
  27218. /**
  27219. * Define the sampling modes of all the draw buffers we want to create
  27220. */
  27221. samplingModes?: number[];
  27222. /**
  27223. * Define if a depth buffer is required
  27224. */
  27225. generateDepthBuffer?: boolean;
  27226. /**
  27227. * Define if a stencil buffer is required
  27228. */
  27229. generateStencilBuffer?: boolean;
  27230. /**
  27231. * Define if a depth texture is required instead of a depth buffer
  27232. */
  27233. generateDepthTexture?: boolean;
  27234. /**
  27235. * Define the number of desired draw buffers
  27236. */
  27237. textureCount?: number;
  27238. /**
  27239. * Define if aspect ratio should be adapted to the texture or stay the scene one
  27240. */
  27241. doNotChangeAspectRatio?: boolean;
  27242. /**
  27243. * Define the default type of the buffers we are creating
  27244. */
  27245. defaultType?: number;
  27246. }
  27247. /**
  27248. * A multi render target, like a render target provides the ability to render to a texture.
  27249. * Unlike the render target, it can render to several draw buffers in one draw.
  27250. * This is specially interesting in deferred rendering or for any effects requiring more than
  27251. * just one color from a single pass.
  27252. */
  27253. export class MultiRenderTarget extends RenderTargetTexture {
  27254. private _internalTextures;
  27255. private _textures;
  27256. private _multiRenderTargetOptions;
  27257. /**
  27258. * Get if draw buffers are currently supported by the used hardware and browser.
  27259. */
  27260. readonly isSupported: boolean;
  27261. /**
  27262. * Get the list of textures generated by the multi render target.
  27263. */
  27264. readonly textures: Texture[];
  27265. /**
  27266. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  27267. */
  27268. readonly depthTexture: Texture;
  27269. /**
  27270. * Set the wrapping mode on U of all the textures we are rendering to.
  27271. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27272. */
  27273. wrapU: number;
  27274. /**
  27275. * Set the wrapping mode on V of all the textures we are rendering to.
  27276. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27277. */
  27278. wrapV: number;
  27279. /**
  27280. * Instantiate a new multi render target texture.
  27281. * A multi render target, like a render target provides the ability to render to a texture.
  27282. * Unlike the render target, it can render to several draw buffers in one draw.
  27283. * This is specially interesting in deferred rendering or for any effects requiring more than
  27284. * just one color from a single pass.
  27285. * @param name Define the name of the texture
  27286. * @param size Define the size of the buffers to render to
  27287. * @param count Define the number of target we are rendering into
  27288. * @param scene Define the scene the texture belongs to
  27289. * @param options Define the options used to create the multi render target
  27290. */
  27291. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27292. /** @hidden */
  27293. _rebuild(): void;
  27294. private _createInternalTextures;
  27295. private _createTextures;
  27296. /**
  27297. * Define the number of samples used if MSAA is enabled.
  27298. */
  27299. samples: number;
  27300. /**
  27301. * Resize all the textures in the multi render target.
  27302. * Be carrefull as it will recreate all the data in the new texture.
  27303. * @param size Define the new size
  27304. */
  27305. resize(size: any): void;
  27306. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27307. /**
  27308. * Dispose the render targets and their associated resources
  27309. */
  27310. dispose(): void;
  27311. /**
  27312. * Release all the underlying texture used as draw buffers.
  27313. */
  27314. releaseInternalTextures(): void;
  27315. }
  27316. }
  27317. declare module "babylonjs/Audio/analyser" {
  27318. import { Scene } from "babylonjs/scene";
  27319. /**
  27320. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27322. */
  27323. export class Analyser {
  27324. /**
  27325. * Gets or sets the smoothing
  27326. * @ignorenaming
  27327. */
  27328. SMOOTHING: number;
  27329. /**
  27330. * Gets or sets the FFT table size
  27331. * @ignorenaming
  27332. */
  27333. FFT_SIZE: number;
  27334. /**
  27335. * Gets or sets the bar graph amplitude
  27336. * @ignorenaming
  27337. */
  27338. BARGRAPHAMPLITUDE: number;
  27339. /**
  27340. * Gets or sets the position of the debug canvas
  27341. * @ignorenaming
  27342. */
  27343. DEBUGCANVASPOS: {
  27344. x: number;
  27345. y: number;
  27346. };
  27347. /**
  27348. * Gets or sets the debug canvas size
  27349. * @ignorenaming
  27350. */
  27351. DEBUGCANVASSIZE: {
  27352. width: number;
  27353. height: number;
  27354. };
  27355. private _byteFreqs;
  27356. private _byteTime;
  27357. private _floatFreqs;
  27358. private _webAudioAnalyser;
  27359. private _debugCanvas;
  27360. private _debugCanvasContext;
  27361. private _scene;
  27362. private _registerFunc;
  27363. private _audioEngine;
  27364. /**
  27365. * Creates a new analyser
  27366. * @param scene defines hosting scene
  27367. */
  27368. constructor(scene: Scene);
  27369. /**
  27370. * Get the number of data values you will have to play with for the visualization
  27371. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27372. * @returns a number
  27373. */
  27374. getFrequencyBinCount(): number;
  27375. /**
  27376. * Gets the current frequency data as a byte array
  27377. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27378. * @returns a Uint8Array
  27379. */
  27380. getByteFrequencyData(): Uint8Array;
  27381. /**
  27382. * Gets the current waveform as a byte array
  27383. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27384. * @returns a Uint8Array
  27385. */
  27386. getByteTimeDomainData(): Uint8Array;
  27387. /**
  27388. * Gets the current frequency data as a float array
  27389. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27390. * @returns a Float32Array
  27391. */
  27392. getFloatFrequencyData(): Float32Array;
  27393. /**
  27394. * Renders the debug canvas
  27395. */
  27396. drawDebugCanvas(): void;
  27397. /**
  27398. * Stops rendering the debug canvas and removes it
  27399. */
  27400. stopDebugCanvas(): void;
  27401. /**
  27402. * Connects two audio nodes
  27403. * @param inputAudioNode defines first node to connect
  27404. * @param outputAudioNode defines second node to connect
  27405. */
  27406. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27407. /**
  27408. * Releases all associated resources
  27409. */
  27410. dispose(): void;
  27411. }
  27412. }
  27413. declare module "babylonjs/Audio/audioEngine" {
  27414. import { IDisposable } from "babylonjs/scene";
  27415. import { Analyser } from "babylonjs/Audio/analyser";
  27416. import { Nullable } from "babylonjs/types";
  27417. import { Observable } from "babylonjs/Misc/observable";
  27418. /**
  27419. * This represents an audio engine and it is responsible
  27420. * to play, synchronize and analyse sounds throughout the application.
  27421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27422. */
  27423. export interface IAudioEngine extends IDisposable {
  27424. /**
  27425. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27426. */
  27427. readonly canUseWebAudio: boolean;
  27428. /**
  27429. * Gets the current AudioContext if available.
  27430. */
  27431. readonly audioContext: Nullable<AudioContext>;
  27432. /**
  27433. * The master gain node defines the global audio volume of your audio engine.
  27434. */
  27435. readonly masterGain: GainNode;
  27436. /**
  27437. * Gets whether or not mp3 are supported by your browser.
  27438. */
  27439. readonly isMP3supported: boolean;
  27440. /**
  27441. * Gets whether or not ogg are supported by your browser.
  27442. */
  27443. readonly isOGGsupported: boolean;
  27444. /**
  27445. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27446. * @ignoreNaming
  27447. */
  27448. WarnedWebAudioUnsupported: boolean;
  27449. /**
  27450. * Defines if the audio engine relies on a custom unlocked button.
  27451. * In this case, the embedded button will not be displayed.
  27452. */
  27453. useCustomUnlockedButton: boolean;
  27454. /**
  27455. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27456. */
  27457. readonly unlocked: boolean;
  27458. /**
  27459. * Event raised when audio has been unlocked on the browser.
  27460. */
  27461. onAudioUnlockedObservable: Observable<AudioEngine>;
  27462. /**
  27463. * Event raised when audio has been locked on the browser.
  27464. */
  27465. onAudioLockedObservable: Observable<AudioEngine>;
  27466. /**
  27467. * Flags the audio engine in Locked state.
  27468. * This happens due to new browser policies preventing audio to autoplay.
  27469. */
  27470. lock(): void;
  27471. /**
  27472. * Unlocks the audio engine once a user action has been done on the dom.
  27473. * This is helpful to resume play once browser policies have been satisfied.
  27474. */
  27475. unlock(): void;
  27476. }
  27477. /**
  27478. * This represents the default audio engine used in babylon.
  27479. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27481. */
  27482. export class AudioEngine implements IAudioEngine {
  27483. private _audioContext;
  27484. private _audioContextInitialized;
  27485. private _muteButton;
  27486. private _hostElement;
  27487. /**
  27488. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27489. */
  27490. canUseWebAudio: boolean;
  27491. /**
  27492. * The master gain node defines the global audio volume of your audio engine.
  27493. */
  27494. masterGain: GainNode;
  27495. /**
  27496. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27497. * @ignoreNaming
  27498. */
  27499. WarnedWebAudioUnsupported: boolean;
  27500. /**
  27501. * Gets whether or not mp3 are supported by your browser.
  27502. */
  27503. isMP3supported: boolean;
  27504. /**
  27505. * Gets whether or not ogg are supported by your browser.
  27506. */
  27507. isOGGsupported: boolean;
  27508. /**
  27509. * Gets whether audio has been unlocked on the device.
  27510. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27511. * a user interaction has happened.
  27512. */
  27513. unlocked: boolean;
  27514. /**
  27515. * Defines if the audio engine relies on a custom unlocked button.
  27516. * In this case, the embedded button will not be displayed.
  27517. */
  27518. useCustomUnlockedButton: boolean;
  27519. /**
  27520. * Event raised when audio has been unlocked on the browser.
  27521. */
  27522. onAudioUnlockedObservable: Observable<AudioEngine>;
  27523. /**
  27524. * Event raised when audio has been locked on the browser.
  27525. */
  27526. onAudioLockedObservable: Observable<AudioEngine>;
  27527. /**
  27528. * Gets the current AudioContext if available.
  27529. */
  27530. readonly audioContext: Nullable<AudioContext>;
  27531. private _connectedAnalyser;
  27532. /**
  27533. * Instantiates a new audio engine.
  27534. *
  27535. * There should be only one per page as some browsers restrict the number
  27536. * of audio contexts you can create.
  27537. * @param hostElement defines the host element where to display the mute icon if necessary
  27538. */
  27539. constructor(hostElement?: Nullable<HTMLElement>);
  27540. /**
  27541. * Flags the audio engine in Locked state.
  27542. * This happens due to new browser policies preventing audio to autoplay.
  27543. */
  27544. lock(): void;
  27545. /**
  27546. * Unlocks the audio engine once a user action has been done on the dom.
  27547. * This is helpful to resume play once browser policies have been satisfied.
  27548. */
  27549. unlock(): void;
  27550. private _resumeAudioContext;
  27551. private _initializeAudioContext;
  27552. private _tryToRun;
  27553. private _triggerRunningState;
  27554. private _triggerSuspendedState;
  27555. private _displayMuteButton;
  27556. private _moveButtonToTopLeft;
  27557. private _onResize;
  27558. private _hideMuteButton;
  27559. /**
  27560. * Destroy and release the resources associated with the audio ccontext.
  27561. */
  27562. dispose(): void;
  27563. /**
  27564. * Gets the global volume sets on the master gain.
  27565. * @returns the global volume if set or -1 otherwise
  27566. */
  27567. getGlobalVolume(): number;
  27568. /**
  27569. * Sets the global volume of your experience (sets on the master gain).
  27570. * @param newVolume Defines the new global volume of the application
  27571. */
  27572. setGlobalVolume(newVolume: number): void;
  27573. /**
  27574. * Connect the audio engine to an audio analyser allowing some amazing
  27575. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27577. * @param analyser The analyser to connect to the engine
  27578. */
  27579. connectToAnalyser(analyser: Analyser): void;
  27580. }
  27581. }
  27582. declare module "babylonjs/Loading/loadingScreen" {
  27583. /**
  27584. * Interface used to present a loading screen while loading a scene
  27585. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27586. */
  27587. export interface ILoadingScreen {
  27588. /**
  27589. * Function called to display the loading screen
  27590. */
  27591. displayLoadingUI: () => void;
  27592. /**
  27593. * Function called to hide the loading screen
  27594. */
  27595. hideLoadingUI: () => void;
  27596. /**
  27597. * Gets or sets the color to use for the background
  27598. */
  27599. loadingUIBackgroundColor: string;
  27600. /**
  27601. * Gets or sets the text to display while loading
  27602. */
  27603. loadingUIText: string;
  27604. }
  27605. /**
  27606. * Class used for the default loading screen
  27607. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27608. */
  27609. export class DefaultLoadingScreen implements ILoadingScreen {
  27610. private _renderingCanvas;
  27611. private _loadingText;
  27612. private _loadingDivBackgroundColor;
  27613. private _loadingDiv;
  27614. private _loadingTextDiv;
  27615. /**
  27616. * Creates a new default loading screen
  27617. * @param _renderingCanvas defines the canvas used to render the scene
  27618. * @param _loadingText defines the default text to display
  27619. * @param _loadingDivBackgroundColor defines the default background color
  27620. */
  27621. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27622. /**
  27623. * Function called to display the loading screen
  27624. */
  27625. displayLoadingUI(): void;
  27626. /**
  27627. * Function called to hide the loading screen
  27628. */
  27629. hideLoadingUI(): void;
  27630. /**
  27631. * Gets or sets the text to display while loading
  27632. */
  27633. loadingUIText: string;
  27634. /**
  27635. * Gets or sets the color to use for the background
  27636. */
  27637. loadingUIBackgroundColor: string;
  27638. private _resizeLoadingUI;
  27639. }
  27640. }
  27641. declare module "babylonjs/Materials/Textures/videoTexture" {
  27642. import { Observable } from "babylonjs/Misc/observable";
  27643. import { Nullable } from "babylonjs/types";
  27644. import { Scene } from "babylonjs/scene";
  27645. import { Texture } from "babylonjs/Materials/Textures/texture";
  27646. /**
  27647. * Settings for finer control over video usage
  27648. */
  27649. export interface VideoTextureSettings {
  27650. /**
  27651. * Applies `autoplay` to video, if specified
  27652. */
  27653. autoPlay?: boolean;
  27654. /**
  27655. * Applies `loop` to video, if specified
  27656. */
  27657. loop?: boolean;
  27658. /**
  27659. * Automatically updates internal texture from video at every frame in the render loop
  27660. */
  27661. autoUpdateTexture: boolean;
  27662. /**
  27663. * Image src displayed during the video loading or until the user interacts with the video.
  27664. */
  27665. poster?: string;
  27666. }
  27667. /**
  27668. * If you want to display a video in your scene, this is the special texture for that.
  27669. * This special texture works similar to other textures, with the exception of a few parameters.
  27670. * @see https://doc.babylonjs.com/how_to/video_texture
  27671. */
  27672. export class VideoTexture extends Texture {
  27673. /**
  27674. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27675. */
  27676. readonly autoUpdateTexture: boolean;
  27677. /**
  27678. * The video instance used by the texture internally
  27679. */
  27680. readonly video: HTMLVideoElement;
  27681. private _onUserActionRequestedObservable;
  27682. /**
  27683. * Event triggerd when a dom action is required by the user to play the video.
  27684. * This happens due to recent changes in browser policies preventing video to auto start.
  27685. */
  27686. readonly onUserActionRequestedObservable: Observable<Texture>;
  27687. private _generateMipMaps;
  27688. private _engine;
  27689. private _stillImageCaptured;
  27690. private _displayingPosterTexture;
  27691. private _settings;
  27692. private _createInternalTextureOnEvent;
  27693. /**
  27694. * Creates a video texture.
  27695. * If you want to display a video in your scene, this is the special texture for that.
  27696. * This special texture works similar to other textures, with the exception of a few parameters.
  27697. * @see https://doc.babylonjs.com/how_to/video_texture
  27698. * @param name optional name, will detect from video source, if not defined
  27699. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27700. * @param scene is obviously the current scene.
  27701. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27702. * @param invertY is false by default but can be used to invert video on Y axis
  27703. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27704. * @param settings allows finer control over video usage
  27705. */
  27706. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27707. private _getName;
  27708. private _getVideo;
  27709. private _createInternalTexture;
  27710. private reset;
  27711. /**
  27712. * @hidden Internal method to initiate `update`.
  27713. */
  27714. _rebuild(): void;
  27715. /**
  27716. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27717. */
  27718. update(): void;
  27719. /**
  27720. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27721. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27722. */
  27723. updateTexture(isVisible: boolean): void;
  27724. protected _updateInternalTexture: () => void;
  27725. /**
  27726. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27727. * @param url New url.
  27728. */
  27729. updateURL(url: string): void;
  27730. /**
  27731. * Dispose the texture and release its associated resources.
  27732. */
  27733. dispose(): void;
  27734. /**
  27735. * Creates a video texture straight from your WebCam video feed.
  27736. * @param scene Define the scene the texture should be created in
  27737. * @param onReady Define a callback to triggered once the texture will be ready
  27738. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27739. */
  27740. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27741. minWidth: number;
  27742. maxWidth: number;
  27743. minHeight: number;
  27744. maxHeight: number;
  27745. deviceId: string;
  27746. }): void;
  27747. }
  27748. }
  27749. declare module "babylonjs/Engines/engine" {
  27750. import { Observable } from "babylonjs/Misc/observable";
  27751. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27752. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27753. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27754. import { Camera } from "babylonjs/Cameras/camera";
  27755. import { Scene } from "babylonjs/scene";
  27756. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27757. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27758. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27759. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27760. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27761. import { Material } from "babylonjs/Materials/material";
  27762. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27765. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27766. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27767. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27768. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27769. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27770. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27771. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27773. /**
  27774. * Interface for attribute information associated with buffer instanciation
  27775. */
  27776. export class InstancingAttributeInfo {
  27777. /**
  27778. * Index/offset of the attribute in the vertex shader
  27779. */
  27780. index: number;
  27781. /**
  27782. * size of the attribute, 1, 2, 3 or 4
  27783. */
  27784. attributeSize: number;
  27785. /**
  27786. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27787. * default is FLOAT
  27788. */
  27789. attribyteType: number;
  27790. /**
  27791. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27792. */
  27793. normalized: boolean;
  27794. /**
  27795. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27796. */
  27797. offset: number;
  27798. /**
  27799. * Name of the GLSL attribute, for debugging purpose only
  27800. */
  27801. attributeName: string;
  27802. }
  27803. /**
  27804. * Define options used to create a depth texture
  27805. */
  27806. export class DepthTextureCreationOptions {
  27807. /** Specifies whether or not a stencil should be allocated in the texture */
  27808. generateStencil?: boolean;
  27809. /** Specifies whether or not bilinear filtering is enable on the texture */
  27810. bilinearFiltering?: boolean;
  27811. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27812. comparisonFunction?: number;
  27813. /** Specifies if the created texture is a cube texture */
  27814. isCube?: boolean;
  27815. }
  27816. /**
  27817. * Class used to describe the capabilities of the engine relatively to the current browser
  27818. */
  27819. export class EngineCapabilities {
  27820. /** Maximum textures units per fragment shader */
  27821. maxTexturesImageUnits: number;
  27822. /** Maximum texture units per vertex shader */
  27823. maxVertexTextureImageUnits: number;
  27824. /** Maximum textures units in the entire pipeline */
  27825. maxCombinedTexturesImageUnits: number;
  27826. /** Maximum texture size */
  27827. maxTextureSize: number;
  27828. /** Maximum cube texture size */
  27829. maxCubemapTextureSize: number;
  27830. /** Maximum render texture size */
  27831. maxRenderTextureSize: number;
  27832. /** Maximum number of vertex attributes */
  27833. maxVertexAttribs: number;
  27834. /** Maximum number of varyings */
  27835. maxVaryingVectors: number;
  27836. /** Maximum number of uniforms per vertex shader */
  27837. maxVertexUniformVectors: number;
  27838. /** Maximum number of uniforms per fragment shader */
  27839. maxFragmentUniformVectors: number;
  27840. /** Defines if standard derivates (dx/dy) are supported */
  27841. standardDerivatives: boolean;
  27842. /** Defines if s3tc texture compression is supported */
  27843. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27844. /** Defines if pvrtc texture compression is supported */
  27845. pvrtc: any;
  27846. /** Defines if etc1 texture compression is supported */
  27847. etc1: any;
  27848. /** Defines if etc2 texture compression is supported */
  27849. etc2: any;
  27850. /** Defines if astc texture compression is supported */
  27851. astc: any;
  27852. /** Defines if float textures are supported */
  27853. textureFloat: boolean;
  27854. /** Defines if vertex array objects are supported */
  27855. vertexArrayObject: boolean;
  27856. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27857. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27858. /** Gets the maximum level of anisotropy supported */
  27859. maxAnisotropy: number;
  27860. /** Defines if instancing is supported */
  27861. instancedArrays: boolean;
  27862. /** Defines if 32 bits indices are supported */
  27863. uintIndices: boolean;
  27864. /** Defines if high precision shaders are supported */
  27865. highPrecisionShaderSupported: boolean;
  27866. /** Defines if depth reading in the fragment shader is supported */
  27867. fragmentDepthSupported: boolean;
  27868. /** Defines if float texture linear filtering is supported*/
  27869. textureFloatLinearFiltering: boolean;
  27870. /** Defines if rendering to float textures is supported */
  27871. textureFloatRender: boolean;
  27872. /** Defines if half float textures are supported*/
  27873. textureHalfFloat: boolean;
  27874. /** Defines if half float texture linear filtering is supported*/
  27875. textureHalfFloatLinearFiltering: boolean;
  27876. /** Defines if rendering to half float textures is supported */
  27877. textureHalfFloatRender: boolean;
  27878. /** Defines if textureLOD shader command is supported */
  27879. textureLOD: boolean;
  27880. /** Defines if draw buffers extension is supported */
  27881. drawBuffersExtension: boolean;
  27882. /** Defines if depth textures are supported */
  27883. depthTextureExtension: boolean;
  27884. /** Defines if float color buffer are supported */
  27885. colorBufferFloat: boolean;
  27886. /** Gets disjoint timer query extension (null if not supported) */
  27887. timerQuery: EXT_disjoint_timer_query;
  27888. /** Defines if timestamp can be used with timer query */
  27889. canUseTimestampForTimerQuery: boolean;
  27890. /** Function used to let the system compiles shaders in background */
  27891. parallelShaderCompile: {
  27892. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27893. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27894. COMPLETION_STATUS_KHR: number;
  27895. };
  27896. }
  27897. /** Interface defining initialization parameters for Engine class */
  27898. export interface EngineOptions extends WebGLContextAttributes {
  27899. /**
  27900. * Defines if the engine should no exceed a specified device ratio
  27901. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27902. */
  27903. limitDeviceRatio?: number;
  27904. /**
  27905. * Defines if webvr should be enabled automatically
  27906. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27907. */
  27908. autoEnableWebVR?: boolean;
  27909. /**
  27910. * Defines if webgl2 should be turned off even if supported
  27911. * @see http://doc.babylonjs.com/features/webgl2
  27912. */
  27913. disableWebGL2Support?: boolean;
  27914. /**
  27915. * Defines if webaudio should be initialized as well
  27916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27917. */
  27918. audioEngine?: boolean;
  27919. /**
  27920. * Defines if animations should run using a deterministic lock step
  27921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27922. */
  27923. deterministicLockstep?: boolean;
  27924. /** Defines the maximum steps to use with deterministic lock step mode */
  27925. lockstepMaxSteps?: number;
  27926. /**
  27927. * Defines that engine should ignore context lost events
  27928. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27929. */
  27930. doNotHandleContextLost?: boolean;
  27931. /**
  27932. * Defines that engine should ignore modifying touch action attribute and style
  27933. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27934. */
  27935. doNotHandleTouchAction?: boolean;
  27936. }
  27937. /**
  27938. * Defines the interface used by display changed events
  27939. */
  27940. export interface IDisplayChangedEventArgs {
  27941. /** Gets the vrDisplay object (if any) */
  27942. vrDisplay: Nullable<any>;
  27943. /** Gets a boolean indicating if webVR is supported */
  27944. vrSupported: boolean;
  27945. }
  27946. /**
  27947. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27948. */
  27949. export class Engine {
  27950. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27951. static ExceptionList: ({
  27952. key: string;
  27953. capture: string;
  27954. captureConstraint: number;
  27955. targets: string[];
  27956. } | {
  27957. key: string;
  27958. capture: null;
  27959. captureConstraint: null;
  27960. targets: string[];
  27961. })[];
  27962. /** Gets the list of created engines */
  27963. static readonly Instances: Engine[];
  27964. /**
  27965. * Gets the latest created engine
  27966. */
  27967. static readonly LastCreatedEngine: Nullable<Engine>;
  27968. /**
  27969. * Gets the latest created scene
  27970. */
  27971. static readonly LastCreatedScene: Nullable<Scene>;
  27972. /**
  27973. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27974. * @param flag defines which part of the materials must be marked as dirty
  27975. * @param predicate defines a predicate used to filter which materials should be affected
  27976. */
  27977. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27978. /**
  27979. * Hidden
  27980. */
  27981. static _TextureLoaders: IInternalTextureLoader[];
  27982. /** Defines that alpha blending is disabled */
  27983. static readonly ALPHA_DISABLE: number;
  27984. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27985. static readonly ALPHA_ADD: number;
  27986. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27987. static readonly ALPHA_COMBINE: number;
  27988. /** Defines that alpha blending to DEST - SRC * DEST */
  27989. static readonly ALPHA_SUBTRACT: number;
  27990. /** Defines that alpha blending to SRC * DEST */
  27991. static readonly ALPHA_MULTIPLY: number;
  27992. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27993. static readonly ALPHA_MAXIMIZED: number;
  27994. /** Defines that alpha blending to SRC + DEST */
  27995. static readonly ALPHA_ONEONE: number;
  27996. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27997. static readonly ALPHA_PREMULTIPLIED: number;
  27998. /**
  27999. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28000. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28001. */
  28002. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28003. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28004. static readonly ALPHA_INTERPOLATE: number;
  28005. /**
  28006. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28007. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28008. */
  28009. static readonly ALPHA_SCREENMODE: number;
  28010. /** Defines that the ressource is not delayed*/
  28011. static readonly DELAYLOADSTATE_NONE: number;
  28012. /** Defines that the ressource was successfully delay loaded */
  28013. static readonly DELAYLOADSTATE_LOADED: number;
  28014. /** Defines that the ressource is currently delay loading */
  28015. static readonly DELAYLOADSTATE_LOADING: number;
  28016. /** Defines that the ressource is delayed and has not started loading */
  28017. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28018. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28019. static readonly NEVER: number;
  28020. /** 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 */
  28021. static readonly ALWAYS: number;
  28022. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28023. static readonly LESS: number;
  28024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28025. static readonly EQUAL: number;
  28026. /** 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 */
  28027. static readonly LEQUAL: number;
  28028. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28029. static readonly GREATER: number;
  28030. /** 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 */
  28031. static readonly GEQUAL: number;
  28032. /** 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 */
  28033. static readonly NOTEQUAL: number;
  28034. /** Passed to stencilOperation to specify that stencil value must be kept */
  28035. static readonly KEEP: number;
  28036. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28037. static readonly REPLACE: number;
  28038. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28039. static readonly INCR: number;
  28040. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28041. static readonly DECR: number;
  28042. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28043. static readonly INVERT: number;
  28044. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28045. static readonly INCR_WRAP: number;
  28046. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28047. static readonly DECR_WRAP: number;
  28048. /** Texture is not repeating outside of 0..1 UVs */
  28049. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28050. /** Texture is repeating outside of 0..1 UVs */
  28051. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28052. /** Texture is repeating and mirrored */
  28053. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28054. /** ALPHA */
  28055. static readonly TEXTUREFORMAT_ALPHA: number;
  28056. /** LUMINANCE */
  28057. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28058. /** LUMINANCE_ALPHA */
  28059. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28060. /** RGB */
  28061. static readonly TEXTUREFORMAT_RGB: number;
  28062. /** RGBA */
  28063. static readonly TEXTUREFORMAT_RGBA: number;
  28064. /** RED */
  28065. static readonly TEXTUREFORMAT_RED: number;
  28066. /** RED (2nd reference) */
  28067. static readonly TEXTUREFORMAT_R: number;
  28068. /** RG */
  28069. static readonly TEXTUREFORMAT_RG: number;
  28070. /** RED_INTEGER */
  28071. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28072. /** RED_INTEGER (2nd reference) */
  28073. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28074. /** RG_INTEGER */
  28075. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28076. /** RGB_INTEGER */
  28077. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28078. /** RGBA_INTEGER */
  28079. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28080. /** UNSIGNED_BYTE */
  28081. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28082. /** UNSIGNED_BYTE (2nd reference) */
  28083. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28084. /** FLOAT */
  28085. static readonly TEXTURETYPE_FLOAT: number;
  28086. /** HALF_FLOAT */
  28087. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28088. /** BYTE */
  28089. static readonly TEXTURETYPE_BYTE: number;
  28090. /** SHORT */
  28091. static readonly TEXTURETYPE_SHORT: number;
  28092. /** UNSIGNED_SHORT */
  28093. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28094. /** INT */
  28095. static readonly TEXTURETYPE_INT: number;
  28096. /** UNSIGNED_INT */
  28097. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28098. /** UNSIGNED_SHORT_4_4_4_4 */
  28099. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28100. /** UNSIGNED_SHORT_5_5_5_1 */
  28101. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28102. /** UNSIGNED_SHORT_5_6_5 */
  28103. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28104. /** UNSIGNED_INT_2_10_10_10_REV */
  28105. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28106. /** UNSIGNED_INT_24_8 */
  28107. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28108. /** UNSIGNED_INT_10F_11F_11F_REV */
  28109. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28110. /** UNSIGNED_INT_5_9_9_9_REV */
  28111. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28112. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28113. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28114. /** nearest is mag = nearest and min = nearest and mip = linear */
  28115. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28116. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28117. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28118. /** Trilinear is mag = linear and min = linear and mip = linear */
  28119. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28120. /** nearest is mag = nearest and min = nearest and mip = linear */
  28121. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28123. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28124. /** Trilinear is mag = linear and min = linear and mip = linear */
  28125. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28126. /** mag = nearest and min = nearest and mip = nearest */
  28127. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28128. /** mag = nearest and min = linear and mip = nearest */
  28129. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28130. /** mag = nearest and min = linear and mip = linear */
  28131. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28132. /** mag = nearest and min = linear and mip = none */
  28133. static readonly TEXTURE_NEAREST_LINEAR: number;
  28134. /** mag = nearest and min = nearest and mip = none */
  28135. static readonly TEXTURE_NEAREST_NEAREST: number;
  28136. /** mag = linear and min = nearest and mip = nearest */
  28137. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28138. /** mag = linear and min = nearest and mip = linear */
  28139. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28140. /** mag = linear and min = linear and mip = none */
  28141. static readonly TEXTURE_LINEAR_LINEAR: number;
  28142. /** mag = linear and min = nearest and mip = none */
  28143. static readonly TEXTURE_LINEAR_NEAREST: number;
  28144. /** Explicit coordinates mode */
  28145. static readonly TEXTURE_EXPLICIT_MODE: number;
  28146. /** Spherical coordinates mode */
  28147. static readonly TEXTURE_SPHERICAL_MODE: number;
  28148. /** Planar coordinates mode */
  28149. static readonly TEXTURE_PLANAR_MODE: number;
  28150. /** Cubic coordinates mode */
  28151. static readonly TEXTURE_CUBIC_MODE: number;
  28152. /** Projection coordinates mode */
  28153. static readonly TEXTURE_PROJECTION_MODE: number;
  28154. /** Skybox coordinates mode */
  28155. static readonly TEXTURE_SKYBOX_MODE: number;
  28156. /** Inverse Cubic coordinates mode */
  28157. static readonly TEXTURE_INVCUBIC_MODE: number;
  28158. /** Equirectangular coordinates mode */
  28159. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28160. /** Equirectangular Fixed coordinates mode */
  28161. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28162. /** Equirectangular Fixed Mirrored coordinates mode */
  28163. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28164. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28165. static readonly SCALEMODE_FLOOR: number;
  28166. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28167. static readonly SCALEMODE_NEAREST: number;
  28168. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28169. static readonly SCALEMODE_CEILING: number;
  28170. /**
  28171. * Returns the current version of the framework
  28172. */
  28173. static readonly Version: string;
  28174. /**
  28175. * Returns a string describing the current engine
  28176. */
  28177. readonly description: string;
  28178. /**
  28179. * Gets or sets the epsilon value used by collision engine
  28180. */
  28181. static CollisionsEpsilon: number;
  28182. /**
  28183. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28184. */
  28185. static ShadersRepository: string;
  28186. /**
  28187. * Method called to create the default loading screen.
  28188. * This can be overriden in your own app.
  28189. * @param canvas The rendering canvas element
  28190. * @returns The loading screen
  28191. */
  28192. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28193. /**
  28194. * Method called to create the default rescale post process on each engine.
  28195. */
  28196. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28197. /**
  28198. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28199. */
  28200. forcePOTTextures: boolean;
  28201. /**
  28202. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28203. */
  28204. isFullscreen: boolean;
  28205. /**
  28206. * Gets a boolean indicating if the pointer is currently locked
  28207. */
  28208. isPointerLock: boolean;
  28209. /**
  28210. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28211. */
  28212. cullBackFaces: boolean;
  28213. /**
  28214. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28215. */
  28216. renderEvenInBackground: boolean;
  28217. /**
  28218. * Gets or sets a boolean indicating that cache can be kept between frames
  28219. */
  28220. preventCacheWipeBetweenFrames: boolean;
  28221. /**
  28222. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28223. **/
  28224. enableOfflineSupport: boolean;
  28225. /**
  28226. * 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)
  28227. **/
  28228. disableManifestCheck: boolean;
  28229. /**
  28230. * Gets the list of created scenes
  28231. */
  28232. scenes: Scene[];
  28233. /**
  28234. * Event raised when a new scene is created
  28235. */
  28236. onNewSceneAddedObservable: Observable<Scene>;
  28237. /**
  28238. * Gets the list of created postprocesses
  28239. */
  28240. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28241. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28242. validateShaderPrograms: boolean;
  28243. /**
  28244. * Observable event triggered each time the rendering canvas is resized
  28245. */
  28246. onResizeObservable: Observable<Engine>;
  28247. /**
  28248. * Observable event triggered each time the canvas loses focus
  28249. */
  28250. onCanvasBlurObservable: Observable<Engine>;
  28251. /**
  28252. * Observable event triggered each time the canvas gains focus
  28253. */
  28254. onCanvasFocusObservable: Observable<Engine>;
  28255. /**
  28256. * Observable event triggered each time the canvas receives pointerout event
  28257. */
  28258. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28259. /**
  28260. * Observable event triggered before each texture is initialized
  28261. */
  28262. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28263. private _vrDisplay;
  28264. private _vrSupported;
  28265. private _oldSize;
  28266. private _oldHardwareScaleFactor;
  28267. private _vrExclusivePointerMode;
  28268. private _webVRInitPromise;
  28269. /**
  28270. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28271. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28272. */
  28273. readonly isInVRExclusivePointerMode: boolean;
  28274. /**
  28275. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28276. */
  28277. disableUniformBuffers: boolean;
  28278. /** @hidden */
  28279. _uniformBuffers: UniformBuffer[];
  28280. /**
  28281. * Gets a boolean indicating that the engine supports uniform buffers
  28282. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28283. */
  28284. readonly supportsUniformBuffers: boolean;
  28285. /**
  28286. * Observable raised when the engine begins a new frame
  28287. */
  28288. onBeginFrameObservable: Observable<Engine>;
  28289. /**
  28290. * If set, will be used to request the next animation frame for the render loop
  28291. */
  28292. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28293. /**
  28294. * Observable raised when the engine ends the current frame
  28295. */
  28296. onEndFrameObservable: Observable<Engine>;
  28297. /**
  28298. * Observable raised when the engine is about to compile a shader
  28299. */
  28300. onBeforeShaderCompilationObservable: Observable<Engine>;
  28301. /**
  28302. * Observable raised when the engine has jsut compiled a shader
  28303. */
  28304. onAfterShaderCompilationObservable: Observable<Engine>;
  28305. /** @hidden */
  28306. _gl: WebGLRenderingContext;
  28307. private _renderingCanvas;
  28308. private _windowIsBackground;
  28309. private _webGLVersion;
  28310. /**
  28311. * Gets a boolean indicating that only power of 2 textures are supported
  28312. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28313. */
  28314. readonly needPOTTextures: boolean;
  28315. /** @hidden */
  28316. _badOS: boolean;
  28317. /** @hidden */
  28318. _badDesktopOS: boolean;
  28319. /**
  28320. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28321. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28322. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28323. */
  28324. disableTextureBindingOptimization: boolean;
  28325. /**
  28326. * Gets the audio engine
  28327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28328. * @ignorenaming
  28329. */
  28330. static audioEngine: IAudioEngine;
  28331. /**
  28332. * Default AudioEngine factory responsible of creating the Audio Engine.
  28333. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28334. */
  28335. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28336. /**
  28337. * Default offline support factory responsible of creating a tool used to store data locally.
  28338. * By default, this will create a Database object if the workload has been embedded.
  28339. */
  28340. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28341. private _onFocus;
  28342. private _onBlur;
  28343. private _onCanvasPointerOut;
  28344. private _onCanvasBlur;
  28345. private _onCanvasFocus;
  28346. private _onFullscreenChange;
  28347. private _onPointerLockChange;
  28348. private _onVRDisplayPointerRestricted;
  28349. private _onVRDisplayPointerUnrestricted;
  28350. private _onVrDisplayConnect;
  28351. private _onVrDisplayDisconnect;
  28352. private _onVrDisplayPresentChange;
  28353. /**
  28354. * Observable signaled when VR display mode changes
  28355. */
  28356. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28357. /**
  28358. * Observable signaled when VR request present is complete
  28359. */
  28360. onVRRequestPresentComplete: Observable<boolean>;
  28361. /**
  28362. * Observable signaled when VR request present starts
  28363. */
  28364. onVRRequestPresentStart: Observable<Engine>;
  28365. private _hardwareScalingLevel;
  28366. /** @hidden */
  28367. protected _caps: EngineCapabilities;
  28368. private _pointerLockRequested;
  28369. private _isStencilEnable;
  28370. private _colorWrite;
  28371. private _loadingScreen;
  28372. /** @hidden */
  28373. _drawCalls: PerfCounter;
  28374. /** @hidden */
  28375. _textureCollisions: PerfCounter;
  28376. private _glVersion;
  28377. private _glRenderer;
  28378. private _glVendor;
  28379. private _videoTextureSupported;
  28380. private _renderingQueueLaunched;
  28381. private _activeRenderLoops;
  28382. private _deterministicLockstep;
  28383. private _lockstepMaxSteps;
  28384. /**
  28385. * Observable signaled when a context lost event is raised
  28386. */
  28387. onContextLostObservable: Observable<Engine>;
  28388. /**
  28389. * Observable signaled when a context restored event is raised
  28390. */
  28391. onContextRestoredObservable: Observable<Engine>;
  28392. private _onContextLost;
  28393. private _onContextRestored;
  28394. private _contextWasLost;
  28395. private _doNotHandleContextLost;
  28396. /**
  28397. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28399. */
  28400. doNotHandleContextLost: boolean;
  28401. private _performanceMonitor;
  28402. private _fps;
  28403. private _deltaTime;
  28404. /**
  28405. * Turn this value on if you want to pause FPS computation when in background
  28406. */
  28407. disablePerformanceMonitorInBackground: boolean;
  28408. /**
  28409. * Gets the performance monitor attached to this engine
  28410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28411. */
  28412. readonly performanceMonitor: PerformanceMonitor;
  28413. /** @hidden */
  28414. protected _depthCullingState: _DepthCullingState;
  28415. /** @hidden */
  28416. protected _stencilState: _StencilState;
  28417. /** @hidden */
  28418. protected _alphaState: _AlphaState;
  28419. /** @hidden */
  28420. protected _alphaMode: number;
  28421. protected _internalTexturesCache: InternalTexture[];
  28422. /** @hidden */
  28423. protected _activeChannel: number;
  28424. private _currentTextureChannel;
  28425. /** @hidden */
  28426. protected _boundTexturesCache: {
  28427. [key: string]: Nullable<InternalTexture>;
  28428. };
  28429. /** @hidden */
  28430. protected _currentEffect: Nullable<Effect>;
  28431. /** @hidden */
  28432. protected _currentProgram: Nullable<WebGLProgram>;
  28433. private _compiledEffects;
  28434. private _vertexAttribArraysEnabled;
  28435. /** @hidden */
  28436. protected _cachedViewport: Nullable<Viewport>;
  28437. private _cachedVertexArrayObject;
  28438. /** @hidden */
  28439. protected _cachedVertexBuffers: any;
  28440. /** @hidden */
  28441. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28442. /** @hidden */
  28443. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28444. /** @hidden */
  28445. protected _currentRenderTarget: Nullable<InternalTexture>;
  28446. private _uintIndicesCurrentlySet;
  28447. private _currentBoundBuffer;
  28448. /** @hidden */
  28449. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28450. private _currentBufferPointers;
  28451. private _currentInstanceLocations;
  28452. private _currentInstanceBuffers;
  28453. private _textureUnits;
  28454. private _firstBoundInternalTextureTracker;
  28455. private _lastBoundInternalTextureTracker;
  28456. private _workingCanvas;
  28457. private _workingContext;
  28458. private _rescalePostProcess;
  28459. private _dummyFramebuffer;
  28460. private _externalData;
  28461. private _bindedRenderFunction;
  28462. private _vaoRecordInProgress;
  28463. private _mustWipeVertexAttributes;
  28464. private _emptyTexture;
  28465. private _emptyCubeTexture;
  28466. private _emptyTexture3D;
  28467. /** @hidden */
  28468. _frameHandler: number;
  28469. private _nextFreeTextureSlots;
  28470. private _maxSimultaneousTextures;
  28471. private _activeRequests;
  28472. private _texturesSupported;
  28473. private _textureFormatInUse;
  28474. /**
  28475. * Gets the list of texture formats supported
  28476. */
  28477. readonly texturesSupported: Array<string>;
  28478. /**
  28479. * Gets the list of texture formats in use
  28480. */
  28481. readonly textureFormatInUse: Nullable<string>;
  28482. /**
  28483. * Gets the current viewport
  28484. */
  28485. readonly currentViewport: Nullable<Viewport>;
  28486. /**
  28487. * Gets the default empty texture
  28488. */
  28489. readonly emptyTexture: InternalTexture;
  28490. /**
  28491. * Gets the default empty 3D texture
  28492. */
  28493. readonly emptyTexture3D: InternalTexture;
  28494. /**
  28495. * Gets the default empty cube texture
  28496. */
  28497. readonly emptyCubeTexture: InternalTexture;
  28498. /**
  28499. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28500. */
  28501. readonly premultipliedAlpha: boolean;
  28502. /**
  28503. * Creates a new engine
  28504. * @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
  28505. * @param antialias defines enable antialiasing (default: false)
  28506. * @param options defines further options to be sent to the getContext() function
  28507. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28508. */
  28509. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28510. private _disableTouchAction;
  28511. private _rebuildInternalTextures;
  28512. private _rebuildEffects;
  28513. /**
  28514. * Gets a boolean indicating if all created effects are ready
  28515. * @returns true if all effects are ready
  28516. */
  28517. areAllEffectsReady(): boolean;
  28518. private _rebuildBuffers;
  28519. private _initGLContext;
  28520. /**
  28521. * Gets version of the current webGL context
  28522. */
  28523. readonly webGLVersion: number;
  28524. /**
  28525. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28526. */
  28527. readonly isStencilEnable: boolean;
  28528. private _prepareWorkingCanvas;
  28529. /**
  28530. * Reset the texture cache to empty state
  28531. */
  28532. resetTextureCache(): void;
  28533. /**
  28534. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28536. * @returns true if engine is in deterministic lock step mode
  28537. */
  28538. isDeterministicLockStep(): boolean;
  28539. /**
  28540. * Gets the max steps when engine is running in deterministic lock step
  28541. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28542. * @returns the max steps
  28543. */
  28544. getLockstepMaxSteps(): number;
  28545. /**
  28546. * Gets an object containing information about the current webGL context
  28547. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28548. */
  28549. getGlInfo(): {
  28550. vendor: string;
  28551. renderer: string;
  28552. version: string;
  28553. };
  28554. /**
  28555. * Gets current aspect ratio
  28556. * @param camera defines the camera to use to get the aspect ratio
  28557. * @param useScreen defines if screen size must be used (or the current render target if any)
  28558. * @returns a number defining the aspect ratio
  28559. */
  28560. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28561. /**
  28562. * Gets current screen aspect ratio
  28563. * @returns a number defining the aspect ratio
  28564. */
  28565. getScreenAspectRatio(): number;
  28566. /**
  28567. * Gets the current render width
  28568. * @param useScreen defines if screen size must be used (or the current render target if any)
  28569. * @returns a number defining the current render width
  28570. */
  28571. getRenderWidth(useScreen?: boolean): number;
  28572. /**
  28573. * Gets the current render height
  28574. * @param useScreen defines if screen size must be used (or the current render target if any)
  28575. * @returns a number defining the current render height
  28576. */
  28577. getRenderHeight(useScreen?: boolean): number;
  28578. /**
  28579. * Gets the HTML canvas attached with the current webGL context
  28580. * @returns a HTML canvas
  28581. */
  28582. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28583. /**
  28584. * Gets the client rect of the HTML canvas attached with the current webGL context
  28585. * @returns a client rectanglee
  28586. */
  28587. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28588. /**
  28589. * Defines the hardware scaling level.
  28590. * By default the hardware scaling level is computed from the window device ratio.
  28591. * 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.
  28592. * @param level defines the level to use
  28593. */
  28594. setHardwareScalingLevel(level: number): void;
  28595. /**
  28596. * Gets the current hardware scaling level.
  28597. * By default the hardware scaling level is computed from the window device ratio.
  28598. * 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.
  28599. * @returns a number indicating the current hardware scaling level
  28600. */
  28601. getHardwareScalingLevel(): number;
  28602. /**
  28603. * Gets the list of loaded textures
  28604. * @returns an array containing all loaded textures
  28605. */
  28606. getLoadedTexturesCache(): InternalTexture[];
  28607. /**
  28608. * Gets the object containing all engine capabilities
  28609. * @returns the EngineCapabilities object
  28610. */
  28611. getCaps(): EngineCapabilities;
  28612. /**
  28613. * Gets the current depth function
  28614. * @returns a number defining the depth function
  28615. */
  28616. getDepthFunction(): Nullable<number>;
  28617. /**
  28618. * Sets the current depth function
  28619. * @param depthFunc defines the function to use
  28620. */
  28621. setDepthFunction(depthFunc: number): void;
  28622. /**
  28623. * Sets the current depth function to GREATER
  28624. */
  28625. setDepthFunctionToGreater(): void;
  28626. /**
  28627. * Sets the current depth function to GEQUAL
  28628. */
  28629. setDepthFunctionToGreaterOrEqual(): void;
  28630. /**
  28631. * Sets the current depth function to LESS
  28632. */
  28633. setDepthFunctionToLess(): void;
  28634. /**
  28635. * Sets the current depth function to LEQUAL
  28636. */
  28637. setDepthFunctionToLessOrEqual(): void;
  28638. /**
  28639. * Gets a boolean indicating if stencil buffer is enabled
  28640. * @returns the current stencil buffer state
  28641. */
  28642. getStencilBuffer(): boolean;
  28643. /**
  28644. * Enable or disable the stencil buffer
  28645. * @param enable defines if the stencil buffer must be enabled or disabled
  28646. */
  28647. setStencilBuffer(enable: boolean): void;
  28648. /**
  28649. * Gets the current stencil mask
  28650. * @returns a number defining the new stencil mask to use
  28651. */
  28652. getStencilMask(): number;
  28653. /**
  28654. * Sets the current stencil mask
  28655. * @param mask defines the new stencil mask to use
  28656. */
  28657. setStencilMask(mask: number): void;
  28658. /**
  28659. * Gets the current stencil function
  28660. * @returns a number defining the stencil function to use
  28661. */
  28662. getStencilFunction(): number;
  28663. /**
  28664. * Gets the current stencil reference value
  28665. * @returns a number defining the stencil reference value to use
  28666. */
  28667. getStencilFunctionReference(): number;
  28668. /**
  28669. * Gets the current stencil mask
  28670. * @returns a number defining the stencil mask to use
  28671. */
  28672. getStencilFunctionMask(): number;
  28673. /**
  28674. * Sets the current stencil function
  28675. * @param stencilFunc defines the new stencil function to use
  28676. */
  28677. setStencilFunction(stencilFunc: number): void;
  28678. /**
  28679. * Sets the current stencil reference
  28680. * @param reference defines the new stencil reference to use
  28681. */
  28682. setStencilFunctionReference(reference: number): void;
  28683. /**
  28684. * Sets the current stencil mask
  28685. * @param mask defines the new stencil mask to use
  28686. */
  28687. setStencilFunctionMask(mask: number): void;
  28688. /**
  28689. * Gets the current stencil operation when stencil fails
  28690. * @returns a number defining stencil operation to use when stencil fails
  28691. */
  28692. getStencilOperationFail(): number;
  28693. /**
  28694. * Gets the current stencil operation when depth fails
  28695. * @returns a number defining stencil operation to use when depth fails
  28696. */
  28697. getStencilOperationDepthFail(): number;
  28698. /**
  28699. * Gets the current stencil operation when stencil passes
  28700. * @returns a number defining stencil operation to use when stencil passes
  28701. */
  28702. getStencilOperationPass(): number;
  28703. /**
  28704. * Sets the stencil operation to use when stencil fails
  28705. * @param operation defines the stencil operation to use when stencil fails
  28706. */
  28707. setStencilOperationFail(operation: number): void;
  28708. /**
  28709. * Sets the stencil operation to use when depth fails
  28710. * @param operation defines the stencil operation to use when depth fails
  28711. */
  28712. setStencilOperationDepthFail(operation: number): void;
  28713. /**
  28714. * Sets the stencil operation to use when stencil passes
  28715. * @param operation defines the stencil operation to use when stencil passes
  28716. */
  28717. setStencilOperationPass(operation: number): void;
  28718. /**
  28719. * Sets a boolean indicating if the dithering state is enabled or disabled
  28720. * @param value defines the dithering state
  28721. */
  28722. setDitheringState(value: boolean): void;
  28723. /**
  28724. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28725. * @param value defines the rasterizer state
  28726. */
  28727. setRasterizerState(value: boolean): void;
  28728. /**
  28729. * stop executing a render loop function and remove it from the execution array
  28730. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28731. */
  28732. stopRenderLoop(renderFunction?: () => void): void;
  28733. /** @hidden */
  28734. _renderLoop(): void;
  28735. /**
  28736. * Register and execute a render loop. The engine can have more than one render function
  28737. * @param renderFunction defines the function to continuously execute
  28738. */
  28739. runRenderLoop(renderFunction: () => void): void;
  28740. /**
  28741. * Toggle full screen mode
  28742. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28743. */
  28744. switchFullscreen(requestPointerLock: boolean): void;
  28745. /**
  28746. * Clear the current render buffer or the current render target (if any is set up)
  28747. * @param color defines the color to use
  28748. * @param backBuffer defines if the back buffer must be cleared
  28749. * @param depth defines if the depth buffer must be cleared
  28750. * @param stencil defines if the stencil buffer must be cleared
  28751. */
  28752. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28753. /**
  28754. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28755. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28756. * @param y defines the y-coordinate of the corner of the clear rectangle
  28757. * @param width defines the width of the clear rectangle
  28758. * @param height defines the height of the clear rectangle
  28759. * @param clearColor defines the clear color
  28760. */
  28761. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28762. /**
  28763. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28764. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28765. * @param y defines the y-coordinate of the corner of the clear rectangle
  28766. * @param width defines the width of the clear rectangle
  28767. * @param height defines the height of the clear rectangle
  28768. */
  28769. enableScissor(x: number, y: number, width: number, height: number): void;
  28770. /**
  28771. * Disable previously set scissor test rectangle
  28772. */
  28773. disableScissor(): void;
  28774. private _viewportCached;
  28775. /** @hidden */
  28776. _viewport(x: number, y: number, width: number, height: number): void;
  28777. /**
  28778. * Set the WebGL's viewport
  28779. * @param viewport defines the viewport element to be used
  28780. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28781. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28782. */
  28783. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28784. /**
  28785. * Directly set the WebGL Viewport
  28786. * @param x defines the x coordinate of the viewport (in screen space)
  28787. * @param y defines the y coordinate of the viewport (in screen space)
  28788. * @param width defines the width of the viewport (in screen space)
  28789. * @param height defines the height of the viewport (in screen space)
  28790. * @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
  28791. */
  28792. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28793. /**
  28794. * Begin a new frame
  28795. */
  28796. beginFrame(): void;
  28797. /**
  28798. * Enf the current frame
  28799. */
  28800. endFrame(): void;
  28801. /**
  28802. * Resize the view according to the canvas' size
  28803. */
  28804. resize(): void;
  28805. /**
  28806. * Force a specific size of the canvas
  28807. * @param width defines the new canvas' width
  28808. * @param height defines the new canvas' height
  28809. */
  28810. setSize(width: number, height: number): void;
  28811. /**
  28812. * Gets a boolean indicating if a webVR device was detected
  28813. * @returns true if a webVR device was detected
  28814. */
  28815. isVRDevicePresent(): boolean;
  28816. /**
  28817. * Gets the current webVR device
  28818. * @returns the current webVR device (or null)
  28819. */
  28820. getVRDevice(): any;
  28821. /**
  28822. * Initializes a webVR display and starts listening to display change events
  28823. * The onVRDisplayChangedObservable will be notified upon these changes
  28824. * @returns The onVRDisplayChangedObservable
  28825. */
  28826. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28827. /**
  28828. * Initializes a webVR display and starts listening to display change events
  28829. * The onVRDisplayChangedObservable will be notified upon these changes
  28830. * @returns A promise containing a VRDisplay and if vr is supported
  28831. */
  28832. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28833. /**
  28834. * Call this function to switch to webVR mode
  28835. * Will do nothing if webVR is not supported or if there is no webVR device
  28836. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28837. */
  28838. enableVR(): void;
  28839. /**
  28840. * Call this function to leave webVR mode
  28841. * Will do nothing if webVR is not supported or if there is no webVR device
  28842. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28843. */
  28844. disableVR(): void;
  28845. private _onVRFullScreenTriggered;
  28846. private _getVRDisplaysAsync;
  28847. /**
  28848. * Binds the frame buffer to the specified texture.
  28849. * @param texture The texture to render to or null for the default canvas
  28850. * @param faceIndex The face of the texture to render to in case of cube texture
  28851. * @param requiredWidth The width of the target to render to
  28852. * @param requiredHeight The height of the target to render to
  28853. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28854. * @param depthStencilTexture The depth stencil texture to use to render
  28855. * @param lodLevel defines le lod level to bind to the frame buffer
  28856. */
  28857. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28858. private bindUnboundFramebuffer;
  28859. /**
  28860. * Unbind the current render target texture from the webGL context
  28861. * @param texture defines the render target texture to unbind
  28862. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28863. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28864. */
  28865. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28866. /**
  28867. * Unbind a list of render target textures from the webGL context
  28868. * This is used only when drawBuffer extension or webGL2 are active
  28869. * @param textures defines the render target textures to unbind
  28870. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28871. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28872. */
  28873. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28874. /**
  28875. * Force the mipmap generation for the given render target texture
  28876. * @param texture defines the render target texture to use
  28877. */
  28878. generateMipMapsForCubemap(texture: InternalTexture): void;
  28879. /**
  28880. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28881. */
  28882. flushFramebuffer(): void;
  28883. /**
  28884. * Unbind the current render target and bind the default framebuffer
  28885. */
  28886. restoreDefaultFramebuffer(): void;
  28887. /**
  28888. * Create an uniform buffer
  28889. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28890. * @param elements defines the content of the uniform buffer
  28891. * @returns the webGL uniform buffer
  28892. */
  28893. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28894. /**
  28895. * Create a dynamic uniform buffer
  28896. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28897. * @param elements defines the content of the uniform buffer
  28898. * @returns the webGL uniform buffer
  28899. */
  28900. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28901. /**
  28902. * Update an existing uniform buffer
  28903. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28904. * @param uniformBuffer defines the target uniform buffer
  28905. * @param elements defines the content to update
  28906. * @param offset defines the offset in the uniform buffer where update should start
  28907. * @param count defines the size of the data to update
  28908. */
  28909. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28910. private _resetVertexBufferBinding;
  28911. /**
  28912. * Creates a vertex buffer
  28913. * @param data the data for the vertex buffer
  28914. * @returns the new WebGL static buffer
  28915. */
  28916. createVertexBuffer(data: DataArray): WebGLBuffer;
  28917. /**
  28918. * Creates a dynamic vertex buffer
  28919. * @param data the data for the dynamic vertex buffer
  28920. * @returns the new WebGL dynamic buffer
  28921. */
  28922. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28923. /**
  28924. * Update a dynamic index buffer
  28925. * @param indexBuffer defines the target index buffer
  28926. * @param indices defines the data to update
  28927. * @param offset defines the offset in the target index buffer where update should start
  28928. */
  28929. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28930. /**
  28931. * Updates a dynamic vertex buffer.
  28932. * @param vertexBuffer the vertex buffer to update
  28933. * @param data the data used to update the vertex buffer
  28934. * @param byteOffset the byte offset of the data
  28935. * @param byteLength the byte length of the data
  28936. */
  28937. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28938. private _resetIndexBufferBinding;
  28939. /**
  28940. * Creates a new index buffer
  28941. * @param indices defines the content of the index buffer
  28942. * @param updatable defines if the index buffer must be updatable
  28943. * @returns a new webGL buffer
  28944. */
  28945. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28946. /**
  28947. * Bind a webGL buffer to the webGL context
  28948. * @param buffer defines the buffer to bind
  28949. */
  28950. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28951. /**
  28952. * Bind an uniform buffer to the current webGL context
  28953. * @param buffer defines the buffer to bind
  28954. */
  28955. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28956. /**
  28957. * Bind a buffer to the current webGL context at a given location
  28958. * @param buffer defines the buffer to bind
  28959. * @param location defines the index where to bind the buffer
  28960. */
  28961. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28962. /**
  28963. * Bind a specific block at a given index in a specific shader program
  28964. * @param shaderProgram defines the shader program
  28965. * @param blockName defines the block name
  28966. * @param index defines the index where to bind the block
  28967. */
  28968. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28969. private bindIndexBuffer;
  28970. private bindBuffer;
  28971. /**
  28972. * update the bound buffer with the given data
  28973. * @param data defines the data to update
  28974. */
  28975. updateArrayBuffer(data: Float32Array): void;
  28976. private _vertexAttribPointer;
  28977. private _bindIndexBufferWithCache;
  28978. private _bindVertexBuffersAttributes;
  28979. /**
  28980. * Records a vertex array object
  28981. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28982. * @param vertexBuffers defines the list of vertex buffers to store
  28983. * @param indexBuffer defines the index buffer to store
  28984. * @param effect defines the effect to store
  28985. * @returns the new vertex array object
  28986. */
  28987. recordVertexArrayObject(vertexBuffers: {
  28988. [key: string]: VertexBuffer;
  28989. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28990. /**
  28991. * Bind a specific vertex array object
  28992. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28993. * @param vertexArrayObject defines the vertex array object to bind
  28994. * @param indexBuffer defines the index buffer to bind
  28995. */
  28996. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28997. /**
  28998. * Bind webGl buffers directly to the webGL context
  28999. * @param vertexBuffer defines the vertex buffer to bind
  29000. * @param indexBuffer defines the index buffer to bind
  29001. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29002. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29003. * @param effect defines the effect associated with the vertex buffer
  29004. */
  29005. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29006. private _unbindVertexArrayObject;
  29007. /**
  29008. * Bind a list of vertex buffers to the webGL context
  29009. * @param vertexBuffers defines the list of vertex buffers to bind
  29010. * @param indexBuffer defines the index buffer to bind
  29011. * @param effect defines the effect associated with the vertex buffers
  29012. */
  29013. bindBuffers(vertexBuffers: {
  29014. [key: string]: Nullable<VertexBuffer>;
  29015. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  29016. /**
  29017. * Unbind all instance attributes
  29018. */
  29019. unbindInstanceAttributes(): void;
  29020. /**
  29021. * Release and free the memory of a vertex array object
  29022. * @param vao defines the vertex array object to delete
  29023. */
  29024. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29025. /** @hidden */
  29026. _releaseBuffer(buffer: WebGLBuffer): boolean;
  29027. /**
  29028. * Creates a webGL buffer to use with instanciation
  29029. * @param capacity defines the size of the buffer
  29030. * @returns the webGL buffer
  29031. */
  29032. createInstancesBuffer(capacity: number): WebGLBuffer;
  29033. /**
  29034. * Delete a webGL buffer used with instanciation
  29035. * @param buffer defines the webGL buffer to delete
  29036. */
  29037. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29038. /**
  29039. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29040. * @param instancesBuffer defines the webGL buffer to update and bind
  29041. * @param data defines the data to store in the buffer
  29042. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29043. */
  29044. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29045. /**
  29046. * Apply all cached states (depth, culling, stencil and alpha)
  29047. */
  29048. applyStates(): void;
  29049. /**
  29050. * Send a draw order
  29051. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29052. * @param indexStart defines the starting index
  29053. * @param indexCount defines the number of index to draw
  29054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29055. */
  29056. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29057. /**
  29058. * Draw a list of points
  29059. * @param verticesStart defines the index of first vertex to draw
  29060. * @param verticesCount defines the count of vertices to draw
  29061. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29062. */
  29063. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29064. /**
  29065. * Draw a list of unindexed primitives
  29066. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29067. * @param verticesStart defines the index of first vertex to draw
  29068. * @param verticesCount defines the count of vertices to draw
  29069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29070. */
  29071. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29072. /**
  29073. * Draw a list of indexed primitives
  29074. * @param fillMode defines the primitive to use
  29075. * @param indexStart defines the starting index
  29076. * @param indexCount defines the number of index to draw
  29077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29078. */
  29079. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29080. /**
  29081. * Draw a list of unindexed primitives
  29082. * @param fillMode defines the primitive to use
  29083. * @param verticesStart defines the index of first vertex to draw
  29084. * @param verticesCount defines the count of vertices to draw
  29085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29086. */
  29087. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29088. private _drawMode;
  29089. /** @hidden */
  29090. _releaseEffect(effect: Effect): void;
  29091. /** @hidden */
  29092. _deleteProgram(program: WebGLProgram): void;
  29093. /**
  29094. * Create a new effect (used to store vertex/fragment shaders)
  29095. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29096. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29097. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29098. * @param samplers defines an array of string used to represent textures
  29099. * @param defines defines the string containing the defines to use to compile the shaders
  29100. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29101. * @param onCompiled defines a function to call when the effect creation is successful
  29102. * @param onError defines a function to call when the effect creation has failed
  29103. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29104. * @returns the new Effect
  29105. */
  29106. 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;
  29107. private _compileShader;
  29108. private _compileRawShader;
  29109. /**
  29110. * Directly creates a webGL program
  29111. * @param vertexCode defines the vertex shader code to use
  29112. * @param fragmentCode defines the fragment shader code to use
  29113. * @param context defines the webGL context to use (if not set, the current one will be used)
  29114. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29115. * @returns the new webGL program
  29116. */
  29117. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29118. /**
  29119. * Creates a webGL program
  29120. * @param vertexCode defines the vertex shader code to use
  29121. * @param fragmentCode defines the fragment shader code to use
  29122. * @param defines defines the string containing the defines to use to compile the shaders
  29123. * @param context defines the webGL context to use (if not set, the current one will be used)
  29124. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29125. * @returns the new webGL program
  29126. */
  29127. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29128. private _createShaderProgram;
  29129. private _finalizeProgram;
  29130. /** @hidden */
  29131. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  29132. /** @hidden */
  29133. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  29134. /**
  29135. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29136. * @param shaderProgram defines the webGL program to use
  29137. * @param uniformsNames defines the list of uniform names
  29138. * @returns an array of webGL uniform locations
  29139. */
  29140. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29141. /**
  29142. * Gets the lsit of active attributes for a given webGL program
  29143. * @param shaderProgram defines the webGL program to use
  29144. * @param attributesNames defines the list of attribute names to get
  29145. * @returns an array of indices indicating the offset of each attribute
  29146. */
  29147. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  29148. /**
  29149. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29150. * @param effect defines the effect to activate
  29151. */
  29152. enableEffect(effect: Nullable<Effect>): void;
  29153. /**
  29154. * Set the value of an uniform to an array of int32
  29155. * @param uniform defines the webGL uniform location where to store the value
  29156. * @param array defines the array of int32 to store
  29157. */
  29158. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29159. /**
  29160. * Set the value of an uniform to an array of int32 (stored as vec2)
  29161. * @param uniform defines the webGL uniform location where to store the value
  29162. * @param array defines the array of int32 to store
  29163. */
  29164. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29165. /**
  29166. * Set the value of an uniform to an array of int32 (stored as vec3)
  29167. * @param uniform defines the webGL uniform location where to store the value
  29168. * @param array defines the array of int32 to store
  29169. */
  29170. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29171. /**
  29172. * Set the value of an uniform to an array of int32 (stored as vec4)
  29173. * @param uniform defines the webGL uniform location where to store the value
  29174. * @param array defines the array of int32 to store
  29175. */
  29176. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29177. /**
  29178. * Set the value of an uniform to an array of float32
  29179. * @param uniform defines the webGL uniform location where to store the value
  29180. * @param array defines the array of float32 to store
  29181. */
  29182. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29183. /**
  29184. * Set the value of an uniform to an array of float32 (stored as vec2)
  29185. * @param uniform defines the webGL uniform location where to store the value
  29186. * @param array defines the array of float32 to store
  29187. */
  29188. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29189. /**
  29190. * Set the value of an uniform to an array of float32 (stored as vec3)
  29191. * @param uniform defines the webGL uniform location where to store the value
  29192. * @param array defines the array of float32 to store
  29193. */
  29194. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29195. /**
  29196. * Set the value of an uniform to an array of float32 (stored as vec4)
  29197. * @param uniform defines the webGL uniform location where to store the value
  29198. * @param array defines the array of float32 to store
  29199. */
  29200. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29201. /**
  29202. * Set the value of an uniform to an array of number
  29203. * @param uniform defines the webGL uniform location where to store the value
  29204. * @param array defines the array of number to store
  29205. */
  29206. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29207. /**
  29208. * Set the value of an uniform to an array of number (stored as vec2)
  29209. * @param uniform defines the webGL uniform location where to store the value
  29210. * @param array defines the array of number to store
  29211. */
  29212. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29213. /**
  29214. * Set the value of an uniform to an array of number (stored as vec3)
  29215. * @param uniform defines the webGL uniform location where to store the value
  29216. * @param array defines the array of number to store
  29217. */
  29218. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29219. /**
  29220. * Set the value of an uniform to an array of number (stored as vec4)
  29221. * @param uniform defines the webGL uniform location where to store the value
  29222. * @param array defines the array of number to store
  29223. */
  29224. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29225. /**
  29226. * Set the value of an uniform to an array of float32 (stored as matrices)
  29227. * @param uniform defines the webGL uniform location where to store the value
  29228. * @param matrices defines the array of float32 to store
  29229. */
  29230. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29231. /**
  29232. * Set the value of an uniform to a matrix
  29233. * @param uniform defines the webGL uniform location where to store the value
  29234. * @param matrix defines the matrix to store
  29235. */
  29236. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29237. /**
  29238. * Set the value of an uniform to a matrix (3x3)
  29239. * @param uniform defines the webGL uniform location where to store the value
  29240. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29241. */
  29242. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29243. /**
  29244. * Set the value of an uniform to a matrix (2x2)
  29245. * @param uniform defines the webGL uniform location where to store the value
  29246. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29247. */
  29248. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29249. /**
  29250. * Set the value of an uniform to a number (int)
  29251. * @param uniform defines the webGL uniform location where to store the value
  29252. * @param value defines the int number to store
  29253. */
  29254. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29255. /**
  29256. * Set the value of an uniform to a number (float)
  29257. * @param uniform defines the webGL uniform location where to store the value
  29258. * @param value defines the float number to store
  29259. */
  29260. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29261. /**
  29262. * Set the value of an uniform to a vec2
  29263. * @param uniform defines the webGL uniform location where to store the value
  29264. * @param x defines the 1st component of the value
  29265. * @param y defines the 2nd component of the value
  29266. */
  29267. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29268. /**
  29269. * Set the value of an uniform to a vec3
  29270. * @param uniform defines the webGL uniform location where to store the value
  29271. * @param x defines the 1st component of the value
  29272. * @param y defines the 2nd component of the value
  29273. * @param z defines the 3rd component of the value
  29274. */
  29275. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29276. /**
  29277. * Set the value of an uniform to a boolean
  29278. * @param uniform defines the webGL uniform location where to store the value
  29279. * @param bool defines the boolean to store
  29280. */
  29281. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29282. /**
  29283. * Set the value of an uniform to a vec4
  29284. * @param uniform defines the webGL uniform location where to store the value
  29285. * @param x defines the 1st component of the value
  29286. * @param y defines the 2nd component of the value
  29287. * @param z defines the 3rd component of the value
  29288. * @param w defines the 4th component of the value
  29289. */
  29290. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29291. /**
  29292. * Set the value of an uniform to a Color3
  29293. * @param uniform defines the webGL uniform location where to store the value
  29294. * @param color3 defines the color to store
  29295. */
  29296. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29297. /**
  29298. * Set the value of an uniform to a Color3 and an alpha value
  29299. * @param uniform defines the webGL uniform location where to store the value
  29300. * @param color3 defines the color to store
  29301. * @param alpha defines the alpha component to store
  29302. */
  29303. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29304. /**
  29305. * Sets a Color4 on a uniform variable
  29306. * @param uniform defines the uniform location
  29307. * @param color4 defines the value to be set
  29308. */
  29309. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29310. /**
  29311. * Set various states to the webGL context
  29312. * @param culling defines backface culling state
  29313. * @param zOffset defines the value to apply to zOffset (0 by default)
  29314. * @param force defines if states must be applied even if cache is up to date
  29315. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29316. */
  29317. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29318. /**
  29319. * Set the z offset to apply to current rendering
  29320. * @param value defines the offset to apply
  29321. */
  29322. setZOffset(value: number): void;
  29323. /**
  29324. * Gets the current value of the zOffset
  29325. * @returns the current zOffset state
  29326. */
  29327. getZOffset(): number;
  29328. /**
  29329. * Enable or disable depth buffering
  29330. * @param enable defines the state to set
  29331. */
  29332. setDepthBuffer(enable: boolean): void;
  29333. /**
  29334. * Gets a boolean indicating if depth writing is enabled
  29335. * @returns the current depth writing state
  29336. */
  29337. getDepthWrite(): boolean;
  29338. /**
  29339. * Enable or disable depth writing
  29340. * @param enable defines the state to set
  29341. */
  29342. setDepthWrite(enable: boolean): void;
  29343. /**
  29344. * Enable or disable color writing
  29345. * @param enable defines the state to set
  29346. */
  29347. setColorWrite(enable: boolean): void;
  29348. /**
  29349. * Gets a boolean indicating if color writing is enabled
  29350. * @returns the current color writing state
  29351. */
  29352. getColorWrite(): boolean;
  29353. /**
  29354. * Sets alpha constants used by some alpha blending modes
  29355. * @param r defines the red component
  29356. * @param g defines the green component
  29357. * @param b defines the blue component
  29358. * @param a defines the alpha component
  29359. */
  29360. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29361. /**
  29362. * Sets the current alpha mode
  29363. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29364. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29365. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29366. */
  29367. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29368. /**
  29369. * Gets the current alpha mode
  29370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29371. * @returns the current alpha mode
  29372. */
  29373. getAlphaMode(): number;
  29374. /**
  29375. * Clears the list of texture accessible through engine.
  29376. * This can help preventing texture load conflict due to name collision.
  29377. */
  29378. clearInternalTexturesCache(): void;
  29379. /**
  29380. * Force the entire cache to be cleared
  29381. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29382. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29383. */
  29384. wipeCaches(bruteForce?: boolean): void;
  29385. /**
  29386. * Set the compressed texture format to use, based on the formats you have, and the formats
  29387. * supported by the hardware / browser.
  29388. *
  29389. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29390. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29391. * to API arguments needed to compressed textures. This puts the burden on the container
  29392. * generator to house the arcane code for determining these for current & future formats.
  29393. *
  29394. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29395. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29396. *
  29397. * Note: The result of this call is not taken into account when a texture is base64.
  29398. *
  29399. * @param formatsAvailable defines the list of those format families you have created
  29400. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29401. *
  29402. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29403. * @returns The extension selected.
  29404. */
  29405. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29406. private _getSamplingParameters;
  29407. private _partialLoadImg;
  29408. private _cascadeLoadImgs;
  29409. /** @hidden */
  29410. _createTexture(): WebGLTexture;
  29411. /**
  29412. * Usually called from Texture.ts.
  29413. * Passed information to create a WebGLTexture
  29414. * @param urlArg defines a value which contains one of the following:
  29415. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29416. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29417. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29419. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  29420. * @param scene needed for loading to the correct scene
  29421. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29422. * @param onLoad optional callback to be called upon successful completion
  29423. * @param onError optional callback to be called upon failure
  29424. * @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
  29425. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29426. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29427. * @param forcedExtension defines the extension to use to pick the right loader
  29428. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29429. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29430. */
  29431. 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;
  29432. private _rescaleTexture;
  29433. /**
  29434. * Update a raw texture
  29435. * @param texture defines the texture to update
  29436. * @param data defines the data to store in the texture
  29437. * @param format defines the format of the data
  29438. * @param invertY defines if data must be stored with Y axis inverted
  29439. * @param compression defines the compression used (null by default)
  29440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29441. */
  29442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29443. /**
  29444. * Creates a raw texture
  29445. * @param data defines the data to store in the texture
  29446. * @param width defines the width of the texture
  29447. * @param height defines the height of the texture
  29448. * @param format defines the format of the data
  29449. * @param generateMipMaps defines if the engine should generate the mip levels
  29450. * @param invertY defines if data must be stored with Y axis inverted
  29451. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29452. * @param compression defines the compression used (null by default)
  29453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29454. * @returns the raw texture inside an InternalTexture
  29455. */
  29456. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29457. private _unpackFlipYCached;
  29458. /**
  29459. * In case you are sharing the context with other applications, it might
  29460. * be interested to not cache the unpack flip y state to ensure a consistent
  29461. * value would be set.
  29462. */
  29463. enableUnpackFlipYCached: boolean;
  29464. /** @hidden */
  29465. _unpackFlipY(value: boolean): void;
  29466. /** @hidden */
  29467. _getUnpackAlignement(): number;
  29468. /**
  29469. * Creates a dynamic texture
  29470. * @param width defines the width of the texture
  29471. * @param height defines the height of the texture
  29472. * @param generateMipMaps defines if the engine should generate the mip levels
  29473. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29474. * @returns the dynamic texture inside an InternalTexture
  29475. */
  29476. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29477. /**
  29478. * Update the sampling mode of a given texture
  29479. * @param samplingMode defines the required sampling mode
  29480. * @param texture defines the texture to update
  29481. */
  29482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29483. /**
  29484. * Update the content of a dynamic texture
  29485. * @param texture defines the texture to update
  29486. * @param canvas defines the canvas containing the source
  29487. * @param invertY defines if data must be stored with Y axis inverted
  29488. * @param premulAlpha defines if alpha is stored as premultiplied
  29489. * @param format defines the format of the data
  29490. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29491. */
  29492. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29493. /**
  29494. * Update a video texture
  29495. * @param texture defines the texture to update
  29496. * @param video defines the video element to use
  29497. * @param invertY defines if data must be stored with Y axis inverted
  29498. */
  29499. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29500. /**
  29501. * Updates a depth texture Comparison Mode and Function.
  29502. * If the comparison Function is equal to 0, the mode will be set to none.
  29503. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29504. * @param texture The texture to set the comparison function for
  29505. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29506. */
  29507. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29508. private _setupDepthStencilTexture;
  29509. /**
  29510. * Creates a depth stencil texture.
  29511. * This is only available in WebGL 2 or with the depth texture extension available.
  29512. * @param size The size of face edge in the texture.
  29513. * @param options The options defining the texture.
  29514. * @returns The texture
  29515. */
  29516. createDepthStencilTexture(size: number | {
  29517. width: number;
  29518. height: number;
  29519. }, options: DepthTextureCreationOptions): InternalTexture;
  29520. /**
  29521. * Creates a depth stencil texture.
  29522. * This is only available in WebGL 2 or with the depth texture extension available.
  29523. * @param size The size of face edge in the texture.
  29524. * @param options The options defining the texture.
  29525. * @returns The texture
  29526. */
  29527. private _createDepthStencilTexture;
  29528. /**
  29529. * Creates a depth stencil cube texture.
  29530. * This is only available in WebGL 2.
  29531. * @param size The size of face edge in the cube texture.
  29532. * @param options The options defining the cube texture.
  29533. * @returns The cube texture
  29534. */
  29535. private _createDepthStencilCubeTexture;
  29536. /**
  29537. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29538. * @param renderTarget The render target to set the frame buffer for
  29539. */
  29540. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29541. /**
  29542. * Creates a new render target texture
  29543. * @param size defines the size of the texture
  29544. * @param options defines the options used to create the texture
  29545. * @returns a new render target texture stored in an InternalTexture
  29546. */
  29547. createRenderTargetTexture(size: number | {
  29548. width: number;
  29549. height: number;
  29550. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29551. /**
  29552. * Create a multi render target texture
  29553. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29554. * @param size defines the size of the texture
  29555. * @param options defines the creation options
  29556. * @returns the cube texture as an InternalTexture
  29557. */
  29558. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29559. private _setupFramebufferDepthAttachments;
  29560. /**
  29561. * Updates the sample count of a render target texture
  29562. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29563. * @param texture defines the texture to update
  29564. * @param samples defines the sample count to set
  29565. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29566. */
  29567. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29568. /**
  29569. * Update the sample count for a given multiple render target texture
  29570. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29571. * @param textures defines the textures to update
  29572. * @param samples defines the sample count to set
  29573. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29574. */
  29575. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29576. /** @hidden */
  29577. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29578. /** @hidden */
  29579. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29580. /** @hidden */
  29581. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29582. /** @hidden */
  29583. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29584. /**
  29585. * Creates a new render target cube texture
  29586. * @param size defines the size of the texture
  29587. * @param options defines the options used to create the texture
  29588. * @returns a new render target cube texture stored in an InternalTexture
  29589. */
  29590. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29591. /**
  29592. * Creates a cube texture
  29593. * @param rootUrl defines the url where the files to load is located
  29594. * @param scene defines the current scene
  29595. * @param files defines the list of files to load (1 per face)
  29596. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29597. * @param onLoad defines an optional callback raised when the texture is loaded
  29598. * @param onError defines an optional callback raised if there is an issue to load the texture
  29599. * @param format defines the format of the data
  29600. * @param forcedExtension defines the extension to use to pick the right loader
  29601. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29602. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29603. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29604. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29605. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29606. * @returns the cube texture as an InternalTexture
  29607. */
  29608. 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;
  29609. /**
  29610. * @hidden
  29611. */
  29612. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29613. /**
  29614. * Update a raw cube texture
  29615. * @param texture defines the texture to udpdate
  29616. * @param data defines the data to store
  29617. * @param format defines the data format
  29618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29619. * @param invertY defines if data must be stored with Y axis inverted
  29620. * @param compression defines the compression used (null by default)
  29621. * @param level defines which level of the texture to update
  29622. */
  29623. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29624. /**
  29625. * Creates a new raw cube texture
  29626. * @param data defines the array of data to use to create each face
  29627. * @param size defines the size of the textures
  29628. * @param format defines the format of the data
  29629. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29630. * @param generateMipMaps defines if the engine should generate the mip levels
  29631. * @param invertY defines if data must be stored with Y axis inverted
  29632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29633. * @param compression defines the compression used (null by default)
  29634. * @returns the cube texture as an InternalTexture
  29635. */
  29636. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29637. /**
  29638. * Creates a new raw cube texture from a specified url
  29639. * @param url defines the url where the data is located
  29640. * @param scene defines the current scene
  29641. * @param size defines the size of the textures
  29642. * @param format defines the format of the data
  29643. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29644. * @param noMipmap defines if the engine should avoid generating the mip levels
  29645. * @param callback defines a callback used to extract texture data from loaded data
  29646. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29647. * @param onLoad defines a callback called when texture is loaded
  29648. * @param onError defines a callback called if there is an error
  29649. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29650. * @param invertY defines if data must be stored with Y axis inverted
  29651. * @returns the cube texture as an InternalTexture
  29652. */
  29653. 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;
  29654. /**
  29655. * Update a raw 3D texture
  29656. * @param texture defines the texture to update
  29657. * @param data defines the data to store
  29658. * @param format defines the data format
  29659. * @param invertY defines if data must be stored with Y axis inverted
  29660. * @param compression defines the used compression (can be null)
  29661. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29662. */
  29663. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29664. /**
  29665. * Creates a new raw 3D texture
  29666. * @param data defines the data used to create the texture
  29667. * @param width defines the width of the texture
  29668. * @param height defines the height of the texture
  29669. * @param depth defines the depth of the texture
  29670. * @param format defines the format of the texture
  29671. * @param generateMipMaps defines if the engine must generate mip levels
  29672. * @param invertY defines if data must be stored with Y axis inverted
  29673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29674. * @param compression defines the compressed used (can be null)
  29675. * @param textureType defines the compressed used (can be null)
  29676. * @returns a new raw 3D texture (stored in an InternalTexture)
  29677. */
  29678. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29679. private _prepareWebGLTextureContinuation;
  29680. private _prepareWebGLTexture;
  29681. private _convertRGBtoRGBATextureData;
  29682. /** @hidden */
  29683. _releaseFramebufferObjects(texture: InternalTexture): void;
  29684. /** @hidden */
  29685. _releaseTexture(texture: InternalTexture): void;
  29686. private setProgram;
  29687. private _boundUniforms;
  29688. /**
  29689. * Binds an effect to the webGL context
  29690. * @param effect defines the effect to bind
  29691. */
  29692. bindSamplers(effect: Effect): void;
  29693. private _moveBoundTextureOnTop;
  29694. private _getCorrectTextureChannel;
  29695. private _linkTrackers;
  29696. private _removeDesignatedSlot;
  29697. private _activateCurrentTexture;
  29698. /** @hidden */
  29699. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29700. /** @hidden */
  29701. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29702. /**
  29703. * Sets a texture to the webGL context from a postprocess
  29704. * @param channel defines the channel to use
  29705. * @param postProcess defines the source postprocess
  29706. */
  29707. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29708. /**
  29709. * Binds the output of the passed in post process to the texture channel specified
  29710. * @param channel The channel the texture should be bound to
  29711. * @param postProcess The post process which's output should be bound
  29712. */
  29713. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29714. /**
  29715. * Unbind all textures from the webGL context
  29716. */
  29717. unbindAllTextures(): void;
  29718. /**
  29719. * Sets a texture to the according uniform.
  29720. * @param channel The texture channel
  29721. * @param uniform The uniform to set
  29722. * @param texture The texture to apply
  29723. */
  29724. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29725. /**
  29726. * Sets a depth stencil texture from a render target to the according uniform.
  29727. * @param channel The texture channel
  29728. * @param uniform The uniform to set
  29729. * @param texture The render target texture containing the depth stencil texture to apply
  29730. */
  29731. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29732. private _bindSamplerUniformToChannel;
  29733. private _getTextureWrapMode;
  29734. private _setTexture;
  29735. /**
  29736. * Sets an array of texture to the webGL context
  29737. * @param channel defines the channel where the texture array must be set
  29738. * @param uniform defines the associated uniform location
  29739. * @param textures defines the array of textures to bind
  29740. */
  29741. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29742. /** @hidden */
  29743. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29744. private _setTextureParameterFloat;
  29745. private _setTextureParameterInteger;
  29746. /**
  29747. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29748. * @param x defines the x coordinate of the rectangle where pixels must be read
  29749. * @param y defines the y coordinate of the rectangle where pixels must be read
  29750. * @param width defines the width of the rectangle where pixels must be read
  29751. * @param height defines the height of the rectangle where pixels must be read
  29752. * @returns a Uint8Array containing RGBA colors
  29753. */
  29754. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29755. /**
  29756. * Add an externaly attached data from its key.
  29757. * This method call will fail and return false, if such key already exists.
  29758. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29759. * @param key the unique key that identifies the data
  29760. * @param data the data object to associate to the key for this Engine instance
  29761. * @return true if no such key were already present and the data was added successfully, false otherwise
  29762. */
  29763. addExternalData<T>(key: string, data: T): boolean;
  29764. /**
  29765. * Get an externaly attached data from its key
  29766. * @param key the unique key that identifies the data
  29767. * @return the associated data, if present (can be null), or undefined if not present
  29768. */
  29769. getExternalData<T>(key: string): T;
  29770. /**
  29771. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29772. * @param key the unique key that identifies the data
  29773. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29774. * @return the associated data, can be null if the factory returned null.
  29775. */
  29776. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29777. /**
  29778. * Remove an externaly attached data from the Engine instance
  29779. * @param key the unique key that identifies the data
  29780. * @return true if the data was successfully removed, false if it doesn't exist
  29781. */
  29782. removeExternalData(key: string): boolean;
  29783. /**
  29784. * Unbind all vertex attributes from the webGL context
  29785. */
  29786. unbindAllAttributes(): void;
  29787. /**
  29788. * 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
  29789. */
  29790. releaseEffects(): void;
  29791. /**
  29792. * Dispose and release all associated resources
  29793. */
  29794. dispose(): void;
  29795. /**
  29796. * Display the loading screen
  29797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29798. */
  29799. displayLoadingUI(): void;
  29800. /**
  29801. * Hide the loading screen
  29802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29803. */
  29804. hideLoadingUI(): void;
  29805. /**
  29806. * Gets the current loading screen object
  29807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29808. */
  29809. /**
  29810. * Sets the current loading screen object
  29811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29812. */
  29813. loadingScreen: ILoadingScreen;
  29814. /**
  29815. * Sets the current loading screen text
  29816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29817. */
  29818. loadingUIText: string;
  29819. /**
  29820. * Sets the current loading screen background color
  29821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29822. */
  29823. loadingUIBackgroundColor: string;
  29824. /**
  29825. * Attach a new callback raised when context lost event is fired
  29826. * @param callback defines the callback to call
  29827. */
  29828. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29829. /**
  29830. * Attach a new callback raised when context restored event is fired
  29831. * @param callback defines the callback to call
  29832. */
  29833. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29834. /**
  29835. * Gets the source code of the vertex shader associated with a specific webGL program
  29836. * @param program defines the program to use
  29837. * @returns a string containing the source code of the vertex shader associated with the program
  29838. */
  29839. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29840. /**
  29841. * Gets the source code of the fragment shader associated with a specific webGL program
  29842. * @param program defines the program to use
  29843. * @returns a string containing the source code of the fragment shader associated with the program
  29844. */
  29845. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29846. /**
  29847. * Get the current error code of the webGL context
  29848. * @returns the error code
  29849. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29850. */
  29851. getError(): number;
  29852. /**
  29853. * Gets the current framerate
  29854. * @returns a number representing the framerate
  29855. */
  29856. getFps(): number;
  29857. /**
  29858. * Gets the time spent between current and previous frame
  29859. * @returns a number representing the delta time in ms
  29860. */
  29861. getDeltaTime(): number;
  29862. private _measureFps;
  29863. /** @hidden */
  29864. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29865. private _canRenderToFloatFramebuffer;
  29866. private _canRenderToHalfFloatFramebuffer;
  29867. private _canRenderToFramebuffer;
  29868. /** @hidden */
  29869. _getWebGLTextureType(type: number): number;
  29870. private _getInternalFormat;
  29871. /** @hidden */
  29872. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29873. /** @hidden */
  29874. _getRGBAMultiSampleBufferFormat(type: number): number;
  29875. /** @hidden */
  29876. _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;
  29877. /** @hidden */
  29878. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29879. private _partialLoadFile;
  29880. private _cascadeLoadFiles;
  29881. /**
  29882. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29883. * @returns true if the engine can be created
  29884. * @ignorenaming
  29885. */
  29886. static isSupported(): boolean;
  29887. }
  29888. }
  29889. declare module "babylonjs/Materials/effect" {
  29890. import { Observable } from "babylonjs/Misc/observable";
  29891. import { Nullable } from "babylonjs/types";
  29892. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29893. import { Engine } from "babylonjs/Engines/engine";
  29894. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29897. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29899. /**
  29900. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29901. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29902. */
  29903. export class EffectFallbacks {
  29904. private _defines;
  29905. private _currentRank;
  29906. private _maxRank;
  29907. private _mesh;
  29908. /**
  29909. * Removes the fallback from the bound mesh.
  29910. */
  29911. unBindMesh(): void;
  29912. /**
  29913. * Adds a fallback on the specified property.
  29914. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29915. * @param define The name of the define in the shader
  29916. */
  29917. addFallback(rank: number, define: string): void;
  29918. /**
  29919. * Sets the mesh to use CPU skinning when needing to fallback.
  29920. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29921. * @param mesh The mesh to use the fallbacks.
  29922. */
  29923. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29924. /**
  29925. * Checks to see if more fallbacks are still availible.
  29926. */
  29927. readonly isMoreFallbacks: boolean;
  29928. /**
  29929. * Removes the defines that shoould be removed when falling back.
  29930. * @param currentDefines defines the current define statements for the shader.
  29931. * @param effect defines the current effect we try to compile
  29932. * @returns The resulting defines with defines of the current rank removed.
  29933. */
  29934. reduce(currentDefines: string, effect: Effect): string;
  29935. }
  29936. /**
  29937. * Options to be used when creating an effect.
  29938. */
  29939. export class EffectCreationOptions {
  29940. /**
  29941. * Atrributes that will be used in the shader.
  29942. */
  29943. attributes: string[];
  29944. /**
  29945. * Uniform varible names that will be set in the shader.
  29946. */
  29947. uniformsNames: string[];
  29948. /**
  29949. * Uniform buffer varible names that will be set in the shader.
  29950. */
  29951. uniformBuffersNames: string[];
  29952. /**
  29953. * Sampler texture variable names that will be set in the shader.
  29954. */
  29955. samplers: string[];
  29956. /**
  29957. * Define statements that will be set in the shader.
  29958. */
  29959. defines: any;
  29960. /**
  29961. * Possible fallbacks for this effect to improve performance when needed.
  29962. */
  29963. fallbacks: Nullable<EffectFallbacks>;
  29964. /**
  29965. * Callback that will be called when the shader is compiled.
  29966. */
  29967. onCompiled: Nullable<(effect: Effect) => void>;
  29968. /**
  29969. * Callback that will be called if an error occurs during shader compilation.
  29970. */
  29971. onError: Nullable<(effect: Effect, errors: string) => void>;
  29972. /**
  29973. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29974. */
  29975. indexParameters: any;
  29976. /**
  29977. * Max number of lights that can be used in the shader.
  29978. */
  29979. maxSimultaneousLights: number;
  29980. /**
  29981. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29982. */
  29983. transformFeedbackVaryings: Nullable<string[]>;
  29984. }
  29985. /**
  29986. * Effect containing vertex and fragment shader that can be executed on an object.
  29987. */
  29988. export class Effect {
  29989. /**
  29990. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29991. */
  29992. static ShadersRepository: string;
  29993. /**
  29994. * Name of the effect.
  29995. */
  29996. name: any;
  29997. /**
  29998. * String container all the define statements that should be set on the shader.
  29999. */
  30000. defines: string;
  30001. /**
  30002. * Callback that will be called when the shader is compiled.
  30003. */
  30004. onCompiled: Nullable<(effect: Effect) => void>;
  30005. /**
  30006. * Callback that will be called if an error occurs during shader compilation.
  30007. */
  30008. onError: Nullable<(effect: Effect, errors: string) => void>;
  30009. /**
  30010. * Callback that will be called when effect is bound.
  30011. */
  30012. onBind: Nullable<(effect: Effect) => void>;
  30013. /**
  30014. * Unique ID of the effect.
  30015. */
  30016. uniqueId: number;
  30017. /**
  30018. * Observable that will be called when the shader is compiled.
  30019. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30020. */
  30021. onCompileObservable: Observable<Effect>;
  30022. /**
  30023. * Observable that will be called if an error occurs during shader compilation.
  30024. */
  30025. onErrorObservable: Observable<Effect>;
  30026. /** @hidden */
  30027. _onBindObservable: Nullable<Observable<Effect>>;
  30028. /**
  30029. * Observable that will be called when effect is bound.
  30030. */
  30031. readonly onBindObservable: Observable<Effect>;
  30032. /** @hidden */
  30033. _bonesComputationForcedToCPU: boolean;
  30034. private static _uniqueIdSeed;
  30035. private _engine;
  30036. private _uniformBuffersNames;
  30037. private _uniformsNames;
  30038. private _samplers;
  30039. private _isReady;
  30040. private _compilationError;
  30041. private _attributesNames;
  30042. private _attributes;
  30043. private _uniforms;
  30044. /**
  30045. * Key for the effect.
  30046. * @hidden
  30047. */
  30048. _key: string;
  30049. private _indexParameters;
  30050. private _fallbacks;
  30051. private _vertexSourceCode;
  30052. private _fragmentSourceCode;
  30053. private _vertexSourceCodeOverride;
  30054. private _fragmentSourceCodeOverride;
  30055. private _transformFeedbackVaryings;
  30056. /**
  30057. * Compiled shader to webGL program.
  30058. * @hidden
  30059. */
  30060. _program: WebGLProgram;
  30061. private _valueCache;
  30062. private static _baseCache;
  30063. /**
  30064. * Instantiates an effect.
  30065. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30066. * @param baseName Name of the effect.
  30067. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30068. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30069. * @param samplers List of sampler variables that will be passed to the shader.
  30070. * @param engine Engine to be used to render the effect
  30071. * @param defines Define statements to be added to the shader.
  30072. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30073. * @param onCompiled Callback that will be called when the shader is compiled.
  30074. * @param onError Callback that will be called if an error occurs during shader compilation.
  30075. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30076. */
  30077. 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);
  30078. /**
  30079. * Unique key for this effect
  30080. */
  30081. readonly key: string;
  30082. /**
  30083. * If the effect has been compiled and prepared.
  30084. * @returns if the effect is compiled and prepared.
  30085. */
  30086. isReady(): boolean;
  30087. /**
  30088. * The engine the effect was initialized with.
  30089. * @returns the engine.
  30090. */
  30091. getEngine(): Engine;
  30092. /**
  30093. * The compiled webGL program for the effect
  30094. * @returns the webGL program.
  30095. */
  30096. getProgram(): WebGLProgram;
  30097. /**
  30098. * The set of names of attribute variables for the shader.
  30099. * @returns An array of attribute names.
  30100. */
  30101. getAttributesNames(): string[];
  30102. /**
  30103. * Returns the attribute at the given index.
  30104. * @param index The index of the attribute.
  30105. * @returns The location of the attribute.
  30106. */
  30107. getAttributeLocation(index: number): number;
  30108. /**
  30109. * Returns the attribute based on the name of the variable.
  30110. * @param name of the attribute to look up.
  30111. * @returns the attribute location.
  30112. */
  30113. getAttributeLocationByName(name: string): number;
  30114. /**
  30115. * The number of attributes.
  30116. * @returns the numnber of attributes.
  30117. */
  30118. getAttributesCount(): number;
  30119. /**
  30120. * Gets the index of a uniform variable.
  30121. * @param uniformName of the uniform to look up.
  30122. * @returns the index.
  30123. */
  30124. getUniformIndex(uniformName: string): number;
  30125. /**
  30126. * Returns the attribute based on the name of the variable.
  30127. * @param uniformName of the uniform to look up.
  30128. * @returns the location of the uniform.
  30129. */
  30130. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30131. /**
  30132. * Returns an array of sampler variable names
  30133. * @returns The array of sampler variable neames.
  30134. */
  30135. getSamplers(): string[];
  30136. /**
  30137. * The error from the last compilation.
  30138. * @returns the error string.
  30139. */
  30140. getCompilationError(): string;
  30141. /**
  30142. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30143. * @param func The callback to be used.
  30144. */
  30145. executeWhenCompiled(func: (effect: Effect) => void): void;
  30146. private _checkIsReady;
  30147. /** @hidden */
  30148. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30149. /** @hidden */
  30150. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30151. /** @hidden */
  30152. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30153. private _processShaderConversion;
  30154. private _processIncludes;
  30155. private _processPrecision;
  30156. /**
  30157. * Recompiles the webGL program
  30158. * @param vertexSourceCode The source code for the vertex shader.
  30159. * @param fragmentSourceCode The source code for the fragment shader.
  30160. * @param onCompiled Callback called when completed.
  30161. * @param onError Callback called on error.
  30162. * @hidden
  30163. */
  30164. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  30165. /**
  30166. * Gets the uniform locations of the the specified variable names
  30167. * @param names THe names of the variables to lookup.
  30168. * @returns Array of locations in the same order as variable names.
  30169. */
  30170. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  30171. /**
  30172. * Prepares the effect
  30173. * @hidden
  30174. */
  30175. _prepareEffect(): void;
  30176. /**
  30177. * Checks if the effect is supported. (Must be called after compilation)
  30178. */
  30179. readonly isSupported: boolean;
  30180. /**
  30181. * Binds a texture to the engine to be used as output of the shader.
  30182. * @param channel Name of the output variable.
  30183. * @param texture Texture to bind.
  30184. * @hidden
  30185. */
  30186. _bindTexture(channel: string, texture: InternalTexture): void;
  30187. /**
  30188. * Sets a texture on the engine to be used in the shader.
  30189. * @param channel Name of the sampler variable.
  30190. * @param texture Texture to set.
  30191. */
  30192. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30193. /**
  30194. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30195. * @param channel Name of the sampler variable.
  30196. * @param texture Texture to set.
  30197. */
  30198. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30199. /**
  30200. * Sets an array of textures on the engine to be used in the shader.
  30201. * @param channel Name of the variable.
  30202. * @param textures Textures to set.
  30203. */
  30204. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30205. /**
  30206. * 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)
  30207. * @param channel Name of the sampler variable.
  30208. * @param postProcess Post process to get the input texture from.
  30209. */
  30210. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30211. /**
  30212. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30213. * 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)
  30214. * @param channel Name of the sampler variable.
  30215. * @param postProcess Post process to get the output texture from.
  30216. */
  30217. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30218. /** @hidden */
  30219. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30220. /** @hidden */
  30221. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30222. /** @hidden */
  30223. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30224. /** @hidden */
  30225. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30226. /**
  30227. * Binds a buffer to a uniform.
  30228. * @param buffer Buffer to bind.
  30229. * @param name Name of the uniform variable to bind to.
  30230. */
  30231. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  30232. /**
  30233. * Binds block to a uniform.
  30234. * @param blockName Name of the block to bind.
  30235. * @param index Index to bind.
  30236. */
  30237. bindUniformBlock(blockName: string, index: number): void;
  30238. /**
  30239. * Sets an interger value on a uniform variable.
  30240. * @param uniformName Name of the variable.
  30241. * @param value Value to be set.
  30242. * @returns this effect.
  30243. */
  30244. setInt(uniformName: string, value: number): Effect;
  30245. /**
  30246. * Sets an int array on a uniform variable.
  30247. * @param uniformName Name of the variable.
  30248. * @param array array to be set.
  30249. * @returns this effect.
  30250. */
  30251. setIntArray(uniformName: string, array: Int32Array): Effect;
  30252. /**
  30253. * 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)
  30254. * @param uniformName Name of the variable.
  30255. * @param array array to be set.
  30256. * @returns this effect.
  30257. */
  30258. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30259. /**
  30260. * 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)
  30261. * @param uniformName Name of the variable.
  30262. * @param array array to be set.
  30263. * @returns this effect.
  30264. */
  30265. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30266. /**
  30267. * 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)
  30268. * @param uniformName Name of the variable.
  30269. * @param array array to be set.
  30270. * @returns this effect.
  30271. */
  30272. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30273. /**
  30274. * Sets an float array on a uniform variable.
  30275. * @param uniformName Name of the variable.
  30276. * @param array array to be set.
  30277. * @returns this effect.
  30278. */
  30279. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30280. /**
  30281. * 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)
  30282. * @param uniformName Name of the variable.
  30283. * @param array array to be set.
  30284. * @returns this effect.
  30285. */
  30286. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30287. /**
  30288. * 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)
  30289. * @param uniformName Name of the variable.
  30290. * @param array array to be set.
  30291. * @returns this effect.
  30292. */
  30293. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30294. /**
  30295. * 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)
  30296. * @param uniformName Name of the variable.
  30297. * @param array array to be set.
  30298. * @returns this effect.
  30299. */
  30300. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30301. /**
  30302. * Sets an array on a uniform variable.
  30303. * @param uniformName Name of the variable.
  30304. * @param array array to be set.
  30305. * @returns this effect.
  30306. */
  30307. setArray(uniformName: string, array: number[]): Effect;
  30308. /**
  30309. * 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)
  30310. * @param uniformName Name of the variable.
  30311. * @param array array to be set.
  30312. * @returns this effect.
  30313. */
  30314. setArray2(uniformName: string, array: number[]): Effect;
  30315. /**
  30316. * 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)
  30317. * @param uniformName Name of the variable.
  30318. * @param array array to be set.
  30319. * @returns this effect.
  30320. */
  30321. setArray3(uniformName: string, array: number[]): Effect;
  30322. /**
  30323. * 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)
  30324. * @param uniformName Name of the variable.
  30325. * @param array array to be set.
  30326. * @returns this effect.
  30327. */
  30328. setArray4(uniformName: string, array: number[]): Effect;
  30329. /**
  30330. * Sets matrices on a uniform variable.
  30331. * @param uniformName Name of the variable.
  30332. * @param matrices matrices to be set.
  30333. * @returns this effect.
  30334. */
  30335. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30336. /**
  30337. * Sets matrix on a uniform variable.
  30338. * @param uniformName Name of the variable.
  30339. * @param matrix matrix to be set.
  30340. * @returns this effect.
  30341. */
  30342. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30343. /**
  30344. * 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)
  30345. * @param uniformName Name of the variable.
  30346. * @param matrix matrix to be set.
  30347. * @returns this effect.
  30348. */
  30349. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30350. /**
  30351. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30352. * @param uniformName Name of the variable.
  30353. * @param matrix matrix to be set.
  30354. * @returns this effect.
  30355. */
  30356. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30357. /**
  30358. * Sets a float on a uniform variable.
  30359. * @param uniformName Name of the variable.
  30360. * @param value value to be set.
  30361. * @returns this effect.
  30362. */
  30363. setFloat(uniformName: string, value: number): Effect;
  30364. /**
  30365. * Sets a boolean on a uniform variable.
  30366. * @param uniformName Name of the variable.
  30367. * @param bool value to be set.
  30368. * @returns this effect.
  30369. */
  30370. setBool(uniformName: string, bool: boolean): Effect;
  30371. /**
  30372. * Sets a Vector2 on a uniform variable.
  30373. * @param uniformName Name of the variable.
  30374. * @param vector2 vector2 to be set.
  30375. * @returns this effect.
  30376. */
  30377. setVector2(uniformName: string, vector2: Vector2): Effect;
  30378. /**
  30379. * Sets a float2 on a uniform variable.
  30380. * @param uniformName Name of the variable.
  30381. * @param x First float in float2.
  30382. * @param y Second float in float2.
  30383. * @returns this effect.
  30384. */
  30385. setFloat2(uniformName: string, x: number, y: number): Effect;
  30386. /**
  30387. * Sets a Vector3 on a uniform variable.
  30388. * @param uniformName Name of the variable.
  30389. * @param vector3 Value to be set.
  30390. * @returns this effect.
  30391. */
  30392. setVector3(uniformName: string, vector3: Vector3): Effect;
  30393. /**
  30394. * Sets a float3 on a uniform variable.
  30395. * @param uniformName Name of the variable.
  30396. * @param x First float in float3.
  30397. * @param y Second float in float3.
  30398. * @param z Third float in float3.
  30399. * @returns this effect.
  30400. */
  30401. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30402. /**
  30403. * Sets a Vector4 on a uniform variable.
  30404. * @param uniformName Name of the variable.
  30405. * @param vector4 Value to be set.
  30406. * @returns this effect.
  30407. */
  30408. setVector4(uniformName: string, vector4: Vector4): Effect;
  30409. /**
  30410. * Sets a float4 on a uniform variable.
  30411. * @param uniformName Name of the variable.
  30412. * @param x First float in float4.
  30413. * @param y Second float in float4.
  30414. * @param z Third float in float4.
  30415. * @param w Fourth float in float4.
  30416. * @returns this effect.
  30417. */
  30418. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30419. /**
  30420. * Sets a Color3 on a uniform variable.
  30421. * @param uniformName Name of the variable.
  30422. * @param color3 Value to be set.
  30423. * @returns this effect.
  30424. */
  30425. setColor3(uniformName: string, color3: Color3): Effect;
  30426. /**
  30427. * Sets a Color4 on a uniform variable.
  30428. * @param uniformName Name of the variable.
  30429. * @param color3 Value to be set.
  30430. * @param alpha Alpha value to be set.
  30431. * @returns this effect.
  30432. */
  30433. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30434. /**
  30435. * Sets a Color4 on a uniform variable
  30436. * @param uniformName defines the name of the variable
  30437. * @param color4 defines the value to be set
  30438. * @returns this effect.
  30439. */
  30440. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30441. /**
  30442. * This function will add a new shader to the shader store
  30443. * @param name the name of the shader
  30444. * @param pixelShader optional pixel shader content
  30445. * @param vertexShader optional vertex shader content
  30446. */
  30447. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30448. /**
  30449. * Store of each shader (The can be looked up using effect.key)
  30450. */
  30451. static ShadersStore: {
  30452. [key: string]: string;
  30453. };
  30454. /**
  30455. * Store of each included file for a shader (The can be looked up using effect.key)
  30456. */
  30457. static IncludesShadersStore: {
  30458. [key: string]: string;
  30459. };
  30460. /**
  30461. * Resets the cache of effects.
  30462. */
  30463. static ResetCache(): void;
  30464. }
  30465. }
  30466. declare module "babylonjs/Materials/colorCurves" {
  30467. import { Effect } from "babylonjs/Materials/effect";
  30468. /**
  30469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30471. * 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;
  30472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30473. */
  30474. export class ColorCurves {
  30475. private _dirty;
  30476. private _tempColor;
  30477. private _globalCurve;
  30478. private _highlightsCurve;
  30479. private _midtonesCurve;
  30480. private _shadowsCurve;
  30481. private _positiveCurve;
  30482. private _negativeCurve;
  30483. private _globalHue;
  30484. private _globalDensity;
  30485. private _globalSaturation;
  30486. private _globalExposure;
  30487. /**
  30488. * Gets the global Hue value.
  30489. * 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).
  30490. */
  30491. /**
  30492. * Sets the global Hue value.
  30493. * 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).
  30494. */
  30495. globalHue: number;
  30496. /**
  30497. * Gets the global Density value.
  30498. * 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.
  30499. * Values less than zero provide a filter of opposite hue.
  30500. */
  30501. /**
  30502. * Sets the global Density value.
  30503. * 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.
  30504. * Values less than zero provide a filter of opposite hue.
  30505. */
  30506. globalDensity: number;
  30507. /**
  30508. * Gets the global Saturation value.
  30509. * 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.
  30510. */
  30511. /**
  30512. * Sets the global Saturation value.
  30513. * 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.
  30514. */
  30515. globalSaturation: number;
  30516. /**
  30517. * Gets the global Exposure value.
  30518. * 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.
  30519. */
  30520. /**
  30521. * Sets the global Exposure value.
  30522. * 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.
  30523. */
  30524. globalExposure: number;
  30525. private _highlightsHue;
  30526. private _highlightsDensity;
  30527. private _highlightsSaturation;
  30528. private _highlightsExposure;
  30529. /**
  30530. * Gets the highlights Hue value.
  30531. * 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).
  30532. */
  30533. /**
  30534. * Sets the highlights Hue value.
  30535. * 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).
  30536. */
  30537. highlightsHue: number;
  30538. /**
  30539. * Gets the highlights Density value.
  30540. * 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.
  30541. * Values less than zero provide a filter of opposite hue.
  30542. */
  30543. /**
  30544. * Sets the highlights Density value.
  30545. * 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.
  30546. * Values less than zero provide a filter of opposite hue.
  30547. */
  30548. highlightsDensity: number;
  30549. /**
  30550. * Gets the highlights Saturation value.
  30551. * 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.
  30552. */
  30553. /**
  30554. * Sets the highlights Saturation value.
  30555. * 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.
  30556. */
  30557. highlightsSaturation: number;
  30558. /**
  30559. * Gets the highlights Exposure value.
  30560. * 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.
  30561. */
  30562. /**
  30563. * Sets the highlights Exposure value.
  30564. * 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.
  30565. */
  30566. highlightsExposure: number;
  30567. private _midtonesHue;
  30568. private _midtonesDensity;
  30569. private _midtonesSaturation;
  30570. private _midtonesExposure;
  30571. /**
  30572. * Gets the midtones Hue value.
  30573. * 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).
  30574. */
  30575. /**
  30576. * Sets the midtones Hue value.
  30577. * 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).
  30578. */
  30579. midtonesHue: number;
  30580. /**
  30581. * Gets the midtones Density value.
  30582. * 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.
  30583. * Values less than zero provide a filter of opposite hue.
  30584. */
  30585. /**
  30586. * Sets the midtones Density value.
  30587. * 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.
  30588. * Values less than zero provide a filter of opposite hue.
  30589. */
  30590. midtonesDensity: number;
  30591. /**
  30592. * Gets the midtones Saturation value.
  30593. * 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.
  30594. */
  30595. /**
  30596. * Sets the midtones Saturation value.
  30597. * 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.
  30598. */
  30599. midtonesSaturation: number;
  30600. /**
  30601. * Gets the midtones Exposure value.
  30602. * 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.
  30603. */
  30604. /**
  30605. * Sets the midtones Exposure value.
  30606. * 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.
  30607. */
  30608. midtonesExposure: number;
  30609. private _shadowsHue;
  30610. private _shadowsDensity;
  30611. private _shadowsSaturation;
  30612. private _shadowsExposure;
  30613. /**
  30614. * Gets the shadows Hue value.
  30615. * 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).
  30616. */
  30617. /**
  30618. * Sets the shadows Hue value.
  30619. * 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).
  30620. */
  30621. shadowsHue: number;
  30622. /**
  30623. * Gets the shadows Density value.
  30624. * 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.
  30625. * Values less than zero provide a filter of opposite hue.
  30626. */
  30627. /**
  30628. * Sets the shadows Density value.
  30629. * 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.
  30630. * Values less than zero provide a filter of opposite hue.
  30631. */
  30632. shadowsDensity: number;
  30633. /**
  30634. * Gets the shadows Saturation value.
  30635. * 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.
  30636. */
  30637. /**
  30638. * Sets the shadows Saturation value.
  30639. * 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.
  30640. */
  30641. shadowsSaturation: number;
  30642. /**
  30643. * Gets the shadows Exposure value.
  30644. * 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.
  30645. */
  30646. /**
  30647. * Sets the shadows Exposure value.
  30648. * 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.
  30649. */
  30650. shadowsExposure: number;
  30651. /**
  30652. * Returns the class name
  30653. * @returns The class name
  30654. */
  30655. getClassName(): string;
  30656. /**
  30657. * Binds the color curves to the shader.
  30658. * @param colorCurves The color curve to bind
  30659. * @param effect The effect to bind to
  30660. * @param positiveUniform The positive uniform shader parameter
  30661. * @param neutralUniform The neutral uniform shader parameter
  30662. * @param negativeUniform The negative uniform shader parameter
  30663. */
  30664. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30665. /**
  30666. * Prepare the list of uniforms associated with the ColorCurves effects.
  30667. * @param uniformsList The list of uniforms used in the effect
  30668. */
  30669. static PrepareUniforms(uniformsList: string[]): void;
  30670. /**
  30671. * Returns color grading data based on a hue, density, saturation and exposure value.
  30672. * @param filterHue The hue of the color filter.
  30673. * @param filterDensity The density of the color filter.
  30674. * @param saturation The saturation.
  30675. * @param exposure The exposure.
  30676. * @param result The result data container.
  30677. */
  30678. private getColorGradingDataToRef;
  30679. /**
  30680. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30681. * @param value The input slider value in range [-100,100].
  30682. * @returns Adjusted value.
  30683. */
  30684. private static applyColorGradingSliderNonlinear;
  30685. /**
  30686. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30687. * @param hue The hue (H) input.
  30688. * @param saturation The saturation (S) input.
  30689. * @param brightness The brightness (B) input.
  30690. * @result An RGBA color represented as Vector4.
  30691. */
  30692. private static fromHSBToRef;
  30693. /**
  30694. * Returns a value clamped between min and max
  30695. * @param value The value to clamp
  30696. * @param min The minimum of value
  30697. * @param max The maximum of value
  30698. * @returns The clamped value.
  30699. */
  30700. private static clamp;
  30701. /**
  30702. * Clones the current color curve instance.
  30703. * @return The cloned curves
  30704. */
  30705. clone(): ColorCurves;
  30706. /**
  30707. * Serializes the current color curve instance to a json representation.
  30708. * @return a JSON representation
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Parses the color curve from a json representation.
  30713. * @param source the JSON source to parse
  30714. * @return The parsed curves
  30715. */
  30716. static Parse(source: any): ColorCurves;
  30717. }
  30718. }
  30719. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30720. import { Observable } from "babylonjs/Misc/observable";
  30721. import { Nullable } from "babylonjs/types";
  30722. import { Color4 } from "babylonjs/Maths/math";
  30723. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30724. import { Effect } from "babylonjs/Materials/effect";
  30725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30726. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30727. /**
  30728. * Interface to follow in your material defines to integrate easily the
  30729. * Image proccessing functions.
  30730. * @hidden
  30731. */
  30732. export interface IImageProcessingConfigurationDefines {
  30733. IMAGEPROCESSING: boolean;
  30734. VIGNETTE: boolean;
  30735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30736. VIGNETTEBLENDMODEOPAQUE: boolean;
  30737. TONEMAPPING: boolean;
  30738. TONEMAPPING_ACES: boolean;
  30739. CONTRAST: boolean;
  30740. EXPOSURE: boolean;
  30741. COLORCURVES: boolean;
  30742. COLORGRADING: boolean;
  30743. COLORGRADING3D: boolean;
  30744. SAMPLER3DGREENDEPTH: boolean;
  30745. SAMPLER3DBGRMAP: boolean;
  30746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30747. }
  30748. /**
  30749. * @hidden
  30750. */
  30751. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30752. IMAGEPROCESSING: boolean;
  30753. VIGNETTE: boolean;
  30754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30755. VIGNETTEBLENDMODEOPAQUE: boolean;
  30756. TONEMAPPING: boolean;
  30757. TONEMAPPING_ACES: boolean;
  30758. CONTRAST: boolean;
  30759. COLORCURVES: boolean;
  30760. COLORGRADING: boolean;
  30761. COLORGRADING3D: boolean;
  30762. SAMPLER3DGREENDEPTH: boolean;
  30763. SAMPLER3DBGRMAP: boolean;
  30764. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30765. EXPOSURE: boolean;
  30766. constructor();
  30767. }
  30768. /**
  30769. * This groups together the common properties used for image processing either in direct forward pass
  30770. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30771. * or not.
  30772. */
  30773. export class ImageProcessingConfiguration {
  30774. /**
  30775. * Default tone mapping applied in BabylonJS.
  30776. */
  30777. static readonly TONEMAPPING_STANDARD: number;
  30778. /**
  30779. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30780. * to other engines rendering to increase portability.
  30781. */
  30782. static readonly TONEMAPPING_ACES: number;
  30783. /**
  30784. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30785. */
  30786. colorCurves: Nullable<ColorCurves>;
  30787. private _colorCurvesEnabled;
  30788. /**
  30789. * Gets wether the color curves effect is enabled.
  30790. */
  30791. /**
  30792. * Sets wether the color curves effect is enabled.
  30793. */
  30794. colorCurvesEnabled: boolean;
  30795. private _colorGradingTexture;
  30796. /**
  30797. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30798. */
  30799. /**
  30800. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30801. */
  30802. colorGradingTexture: Nullable<BaseTexture>;
  30803. private _colorGradingEnabled;
  30804. /**
  30805. * Gets wether the color grading effect is enabled.
  30806. */
  30807. /**
  30808. * Sets wether the color grading effect is enabled.
  30809. */
  30810. colorGradingEnabled: boolean;
  30811. private _colorGradingWithGreenDepth;
  30812. /**
  30813. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30814. */
  30815. /**
  30816. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30817. */
  30818. colorGradingWithGreenDepth: boolean;
  30819. private _colorGradingBGR;
  30820. /**
  30821. * Gets wether the color grading texture contains BGR values.
  30822. */
  30823. /**
  30824. * Sets wether the color grading texture contains BGR values.
  30825. */
  30826. colorGradingBGR: boolean;
  30827. /** @hidden */
  30828. _exposure: number;
  30829. /**
  30830. * Gets the Exposure used in the effect.
  30831. */
  30832. /**
  30833. * Sets the Exposure used in the effect.
  30834. */
  30835. exposure: number;
  30836. private _toneMappingEnabled;
  30837. /**
  30838. * Gets wether the tone mapping effect is enabled.
  30839. */
  30840. /**
  30841. * Sets wether the tone mapping effect is enabled.
  30842. */
  30843. toneMappingEnabled: boolean;
  30844. private _toneMappingType;
  30845. /**
  30846. * Gets the type of tone mapping effect.
  30847. */
  30848. /**
  30849. * Sets the type of tone mapping effect used in BabylonJS.
  30850. */
  30851. toneMappingType: number;
  30852. protected _contrast: number;
  30853. /**
  30854. * Gets the contrast used in the effect.
  30855. */
  30856. /**
  30857. * Sets the contrast used in the effect.
  30858. */
  30859. contrast: number;
  30860. /**
  30861. * Vignette stretch size.
  30862. */
  30863. vignetteStretch: number;
  30864. /**
  30865. * Vignette centre X Offset.
  30866. */
  30867. vignetteCentreX: number;
  30868. /**
  30869. * Vignette centre Y Offset.
  30870. */
  30871. vignetteCentreY: number;
  30872. /**
  30873. * Vignette weight or intensity of the vignette effect.
  30874. */
  30875. vignetteWeight: number;
  30876. /**
  30877. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30878. * if vignetteEnabled is set to true.
  30879. */
  30880. vignetteColor: Color4;
  30881. /**
  30882. * Camera field of view used by the Vignette effect.
  30883. */
  30884. vignetteCameraFov: number;
  30885. private _vignetteBlendMode;
  30886. /**
  30887. * Gets the vignette blend mode allowing different kind of effect.
  30888. */
  30889. /**
  30890. * Sets the vignette blend mode allowing different kind of effect.
  30891. */
  30892. vignetteBlendMode: number;
  30893. private _vignetteEnabled;
  30894. /**
  30895. * Gets wether the vignette effect is enabled.
  30896. */
  30897. /**
  30898. * Sets wether the vignette effect is enabled.
  30899. */
  30900. vignetteEnabled: boolean;
  30901. private _applyByPostProcess;
  30902. /**
  30903. * Gets wether the image processing is applied through a post process or not.
  30904. */
  30905. /**
  30906. * Sets wether the image processing is applied through a post process or not.
  30907. */
  30908. applyByPostProcess: boolean;
  30909. private _isEnabled;
  30910. /**
  30911. * Gets wether the image processing is enabled or not.
  30912. */
  30913. /**
  30914. * Sets wether the image processing is enabled or not.
  30915. */
  30916. isEnabled: boolean;
  30917. /**
  30918. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30919. */
  30920. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30921. /**
  30922. * Method called each time the image processing information changes requires to recompile the effect.
  30923. */
  30924. protected _updateParameters(): void;
  30925. /**
  30926. * Gets the current class name.
  30927. * @return "ImageProcessingConfiguration"
  30928. */
  30929. getClassName(): string;
  30930. /**
  30931. * Prepare the list of uniforms associated with the Image Processing effects.
  30932. * @param uniforms The list of uniforms used in the effect
  30933. * @param defines the list of defines currently in use
  30934. */
  30935. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30936. /**
  30937. * Prepare the list of samplers associated with the Image Processing effects.
  30938. * @param samplersList The list of uniforms used in the effect
  30939. * @param defines the list of defines currently in use
  30940. */
  30941. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30942. /**
  30943. * Prepare the list of defines associated to the shader.
  30944. * @param defines the list of defines to complete
  30945. * @param forPostProcess Define if we are currently in post process mode or not
  30946. */
  30947. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30948. /**
  30949. * Returns true if all the image processing information are ready.
  30950. * @returns True if ready, otherwise, false
  30951. */
  30952. isReady(): boolean;
  30953. /**
  30954. * Binds the image processing to the shader.
  30955. * @param effect The effect to bind to
  30956. * @param aspectRatio Define the current aspect ratio of the effect
  30957. */
  30958. bind(effect: Effect, aspectRatio?: number): void;
  30959. /**
  30960. * Clones the current image processing instance.
  30961. * @return The cloned image processing
  30962. */
  30963. clone(): ImageProcessingConfiguration;
  30964. /**
  30965. * Serializes the current image processing instance to a json representation.
  30966. * @return a JSON representation
  30967. */
  30968. serialize(): any;
  30969. /**
  30970. * Parses the image processing from a json representation.
  30971. * @param source the JSON source to parse
  30972. * @return The parsed image processing
  30973. */
  30974. static Parse(source: any): ImageProcessingConfiguration;
  30975. private static _VIGNETTEMODE_MULTIPLY;
  30976. private static _VIGNETTEMODE_OPAQUE;
  30977. /**
  30978. * Used to apply the vignette as a mix with the pixel color.
  30979. */
  30980. static readonly VIGNETTEMODE_MULTIPLY: number;
  30981. /**
  30982. * Used to apply the vignette as a replacement of the pixel color.
  30983. */
  30984. static readonly VIGNETTEMODE_OPAQUE: number;
  30985. }
  30986. }
  30987. declare module "babylonjs/Materials/fresnelParameters" {
  30988. import { Color3 } from "babylonjs/Maths/math";
  30989. /**
  30990. * This represents all the required information to add a fresnel effect on a material:
  30991. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30992. */
  30993. export class FresnelParameters {
  30994. private _isEnabled;
  30995. /**
  30996. * Define if the fresnel effect is enable or not.
  30997. */
  30998. isEnabled: boolean;
  30999. /**
  31000. * Define the color used on edges (grazing angle)
  31001. */
  31002. leftColor: Color3;
  31003. /**
  31004. * Define the color used on center
  31005. */
  31006. rightColor: Color3;
  31007. /**
  31008. * Define bias applied to computed fresnel term
  31009. */
  31010. bias: number;
  31011. /**
  31012. * Defined the power exponent applied to fresnel term
  31013. */
  31014. power: number;
  31015. /**
  31016. * Clones the current fresnel and its valuues
  31017. * @returns a clone fresnel configuration
  31018. */
  31019. clone(): FresnelParameters;
  31020. /**
  31021. * Serializes the current fresnel parameters to a JSON representation.
  31022. * @return the JSON serialization
  31023. */
  31024. serialize(): any;
  31025. /**
  31026. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31027. * @param parsedFresnelParameters Define the JSON representation
  31028. * @returns the parsed parameters
  31029. */
  31030. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31031. }
  31032. }
  31033. declare module "babylonjs/Misc/decorators" {
  31034. import { Nullable } from "babylonjs/types";
  31035. import { Scene } from "babylonjs/scene";
  31036. import { IAnimatable } from "babylonjs/Misc/tools";
  31037. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31038. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31039. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31040. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31041. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31042. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31043. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31044. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31045. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31046. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31047. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31048. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31049. /**
  31050. * Decorator used to define property that can be serialized as reference to a camera
  31051. * @param sourceName defines the name of the property to decorate
  31052. */
  31053. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31054. /**
  31055. * Class used to help serialization objects
  31056. */
  31057. export class SerializationHelper {
  31058. /** hidden */
  31059. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31060. /** hidden */
  31061. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31062. /** hidden */
  31063. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31064. /** hidden */
  31065. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31066. /**
  31067. * Appends the serialized animations from the source animations
  31068. * @param source Source containing the animations
  31069. * @param destination Target to store the animations
  31070. */
  31071. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31072. /**
  31073. * Static function used to serialized a specific entity
  31074. * @param entity defines the entity to serialize
  31075. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31076. * @returns a JSON compatible object representing the serialization of the entity
  31077. */
  31078. static Serialize<T>(entity: T, serializationObject?: any): any;
  31079. /**
  31080. * Creates a new entity from a serialization data object
  31081. * @param creationFunction defines a function used to instanciated the new entity
  31082. * @param source defines the source serialization data
  31083. * @param scene defines the hosting scene
  31084. * @param rootUrl defines the root url for resources
  31085. * @returns a new entity
  31086. */
  31087. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31088. /**
  31089. * Clones an object
  31090. * @param creationFunction defines the function used to instanciate the new object
  31091. * @param source defines the source object
  31092. * @returns the cloned object
  31093. */
  31094. static Clone<T>(creationFunction: () => T, source: T): T;
  31095. /**
  31096. * Instanciates a new object based on a source one (some data will be shared between both object)
  31097. * @param creationFunction defines the function used to instanciate the new object
  31098. * @param source defines the source object
  31099. * @returns the new object
  31100. */
  31101. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31102. }
  31103. }
  31104. declare module "babylonjs/Cameras/camera" {
  31105. import { SmartArray } from "babylonjs/Misc/smartArray";
  31106. import { Observable } from "babylonjs/Misc/observable";
  31107. import { Nullable } from "babylonjs/types";
  31108. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31109. import { Scene } from "babylonjs/scene";
  31110. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31111. import { Node } from "babylonjs/node";
  31112. import { Mesh } from "babylonjs/Meshes/mesh";
  31113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31114. import { Ray } from "babylonjs/Culling/ray";
  31115. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31119. /**
  31120. * This is the base class of all the camera used in the application.
  31121. * @see http://doc.babylonjs.com/features/cameras
  31122. */
  31123. export class Camera extends Node {
  31124. /** @hidden */
  31125. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31126. /**
  31127. * This is the default projection mode used by the cameras.
  31128. * It helps recreating a feeling of perspective and better appreciate depth.
  31129. * This is the best way to simulate real life cameras.
  31130. */
  31131. static readonly PERSPECTIVE_CAMERA: number;
  31132. /**
  31133. * This helps creating camera with an orthographic mode.
  31134. * 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.
  31135. */
  31136. static readonly ORTHOGRAPHIC_CAMERA: number;
  31137. /**
  31138. * This is the default FOV mode for perspective cameras.
  31139. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31140. */
  31141. static readonly FOVMODE_VERTICAL_FIXED: number;
  31142. /**
  31143. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31144. */
  31145. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31146. /**
  31147. * This specifies ther is no need for a camera rig.
  31148. * Basically only one eye is rendered corresponding to the camera.
  31149. */
  31150. static readonly RIG_MODE_NONE: number;
  31151. /**
  31152. * Simulates a camera Rig with one blue eye and one red eye.
  31153. * This can be use with 3d blue and red glasses.
  31154. */
  31155. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31156. /**
  31157. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31158. */
  31159. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31160. /**
  31161. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31162. */
  31163. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31164. /**
  31165. * Defines that both eyes of the camera will be rendered over under each other.
  31166. */
  31167. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31168. /**
  31169. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31170. */
  31171. static readonly RIG_MODE_VR: number;
  31172. /**
  31173. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31174. */
  31175. static readonly RIG_MODE_WEBVR: number;
  31176. /**
  31177. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31178. */
  31179. static readonly RIG_MODE_CUSTOM: number;
  31180. /**
  31181. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31182. */
  31183. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31184. /**
  31185. * @hidden
  31186. * Might be removed once multiview will be a thing
  31187. */
  31188. static UseAlternateWebVRRendering: boolean;
  31189. /**
  31190. * Define the input manager associated with the camera.
  31191. */
  31192. inputs: CameraInputsManager<Camera>;
  31193. /**
  31194. * Define the current local position of the camera in the scene
  31195. */
  31196. position: Vector3;
  31197. /**
  31198. * The vector the camera should consider as up.
  31199. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31200. */
  31201. upVector: Vector3;
  31202. /**
  31203. * Define the current limit on the left side for an orthographic camera
  31204. * In scene unit
  31205. */
  31206. orthoLeft: Nullable<number>;
  31207. /**
  31208. * Define the current limit on the right side for an orthographic camera
  31209. * In scene unit
  31210. */
  31211. orthoRight: Nullable<number>;
  31212. /**
  31213. * Define the current limit on the bottom side for an orthographic camera
  31214. * In scene unit
  31215. */
  31216. orthoBottom: Nullable<number>;
  31217. /**
  31218. * Define the current limit on the top side for an orthographic camera
  31219. * In scene unit
  31220. */
  31221. orthoTop: Nullable<number>;
  31222. /**
  31223. * Field Of View is set in Radians. (default is 0.8)
  31224. */
  31225. fov: number;
  31226. /**
  31227. * Define the minimum distance the camera can see from.
  31228. * This is important to note that the depth buffer are not infinite and the closer it starts
  31229. * the more your scene might encounter depth fighting issue.
  31230. */
  31231. minZ: number;
  31232. /**
  31233. * Define the maximum distance the camera can see to.
  31234. * This is important to note that the depth buffer are not infinite and the further it end
  31235. * the more your scene might encounter depth fighting issue.
  31236. */
  31237. maxZ: number;
  31238. /**
  31239. * Define the default inertia of the camera.
  31240. * This helps giving a smooth feeling to the camera movement.
  31241. */
  31242. inertia: number;
  31243. /**
  31244. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31245. */
  31246. mode: number;
  31247. /**
  31248. * Define wether the camera is intermediate.
  31249. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31250. */
  31251. isIntermediate: boolean;
  31252. /**
  31253. * Define the viewport of the camera.
  31254. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31255. */
  31256. viewport: Viewport;
  31257. /**
  31258. * Restricts the camera to viewing objects with the same layerMask.
  31259. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31260. */
  31261. layerMask: number;
  31262. /**
  31263. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31264. */
  31265. fovMode: number;
  31266. /**
  31267. * Rig mode of the camera.
  31268. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31269. * This is normally controlled byt the camera themselves as internal use.
  31270. */
  31271. cameraRigMode: number;
  31272. /**
  31273. * Defines the distance between both "eyes" in case of a RIG
  31274. */
  31275. interaxialDistance: number;
  31276. /**
  31277. * Defines if stereoscopic rendering is done side by side or over under.
  31278. */
  31279. isStereoscopicSideBySide: boolean;
  31280. /**
  31281. * 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
  31282. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31283. * else in the scene.
  31284. */
  31285. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31286. /**
  31287. * When set, the camera will render to this render target instead of the default canvas
  31288. */
  31289. outputRenderTarget: Nullable<RenderTargetTexture>;
  31290. /**
  31291. * Observable triggered when the camera view matrix has changed.
  31292. */
  31293. onViewMatrixChangedObservable: Observable<Camera>;
  31294. /**
  31295. * Observable triggered when the camera Projection matrix has changed.
  31296. */
  31297. onProjectionMatrixChangedObservable: Observable<Camera>;
  31298. /**
  31299. * Observable triggered when the inputs have been processed.
  31300. */
  31301. onAfterCheckInputsObservable: Observable<Camera>;
  31302. /**
  31303. * Observable triggered when reset has been called and applied to the camera.
  31304. */
  31305. onRestoreStateObservable: Observable<Camera>;
  31306. /** @hidden */
  31307. _cameraRigParams: any;
  31308. /** @hidden */
  31309. _rigCameras: Camera[];
  31310. /** @hidden */
  31311. _rigPostProcess: Nullable<PostProcess>;
  31312. protected _webvrViewMatrix: Matrix;
  31313. /** @hidden */
  31314. _skipRendering: boolean;
  31315. /** @hidden */
  31316. _alternateCamera: Camera;
  31317. /** @hidden */
  31318. _projectionMatrix: Matrix;
  31319. /** @hidden */
  31320. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31321. /** @hidden */
  31322. _activeMeshes: SmartArray<AbstractMesh>;
  31323. protected _globalPosition: Vector3;
  31324. /** hidden */
  31325. _computedViewMatrix: Matrix;
  31326. private _doNotComputeProjectionMatrix;
  31327. private _transformMatrix;
  31328. private _frustumPlanes;
  31329. private _refreshFrustumPlanes;
  31330. private _storedFov;
  31331. private _stateStored;
  31332. /**
  31333. * Instantiates a new camera object.
  31334. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31335. * @see http://doc.babylonjs.com/features/cameras
  31336. * @param name Defines the name of the camera in the scene
  31337. * @param position Defines the position of the camera
  31338. * @param scene Defines the scene the camera belongs too
  31339. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31340. */
  31341. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31342. /**
  31343. * Store current camera state (fov, position, etc..)
  31344. * @returns the camera
  31345. */
  31346. storeState(): Camera;
  31347. /**
  31348. * Restores the camera state values if it has been stored. You must call storeState() first
  31349. */
  31350. protected _restoreStateValues(): boolean;
  31351. /**
  31352. * Restored camera state. You must call storeState() first.
  31353. * @returns true if restored and false otherwise
  31354. */
  31355. restoreState(): boolean;
  31356. /**
  31357. * Gets the class name of the camera.
  31358. * @returns the class name
  31359. */
  31360. getClassName(): string;
  31361. /** @hidden */
  31362. readonly _isCamera: boolean;
  31363. /**
  31364. * Gets a string representation of the camera useful for debug purpose.
  31365. * @param fullDetails Defines that a more verboe level of logging is required
  31366. * @returns the string representation
  31367. */
  31368. toString(fullDetails?: boolean): string;
  31369. /**
  31370. * Gets the current world space position of the camera.
  31371. */
  31372. readonly globalPosition: Vector3;
  31373. /**
  31374. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31375. * @returns the active meshe list
  31376. */
  31377. getActiveMeshes(): SmartArray<AbstractMesh>;
  31378. /**
  31379. * Check wether a mesh is part of the current active mesh list of the camera
  31380. * @param mesh Defines the mesh to check
  31381. * @returns true if active, false otherwise
  31382. */
  31383. isActiveMesh(mesh: Mesh): boolean;
  31384. /**
  31385. * Is this camera ready to be used/rendered
  31386. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31387. * @return true if the camera is ready
  31388. */
  31389. isReady(completeCheck?: boolean): boolean;
  31390. /** @hidden */
  31391. _initCache(): void;
  31392. /** @hidden */
  31393. _updateCache(ignoreParentClass?: boolean): void;
  31394. /** @hidden */
  31395. _isSynchronized(): boolean;
  31396. /** @hidden */
  31397. _isSynchronizedViewMatrix(): boolean;
  31398. /** @hidden */
  31399. _isSynchronizedProjectionMatrix(): boolean;
  31400. /**
  31401. * Attach the input controls to a specific dom element to get the input from.
  31402. * @param element Defines the element the controls should be listened from
  31403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31404. */
  31405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31406. /**
  31407. * Detach the current controls from the specified dom element.
  31408. * @param element Defines the element to stop listening the inputs from
  31409. */
  31410. detachControl(element: HTMLElement): void;
  31411. /**
  31412. * Update the camera state according to the different inputs gathered during the frame.
  31413. */
  31414. update(): void;
  31415. /** @hidden */
  31416. _checkInputs(): void;
  31417. /** @hidden */
  31418. readonly rigCameras: Camera[];
  31419. /**
  31420. * Gets the post process used by the rig cameras
  31421. */
  31422. readonly rigPostProcess: Nullable<PostProcess>;
  31423. /**
  31424. * Internal, gets the first post proces.
  31425. * @returns the first post process to be run on this camera.
  31426. */
  31427. _getFirstPostProcess(): Nullable<PostProcess>;
  31428. private _cascadePostProcessesToRigCams;
  31429. /**
  31430. * Attach a post process to the camera.
  31431. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31432. * @param postProcess The post process to attach to the camera
  31433. * @param insertAt The position of the post process in case several of them are in use in the scene
  31434. * @returns the position the post process has been inserted at
  31435. */
  31436. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31437. /**
  31438. * Detach a post process to the camera.
  31439. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31440. * @param postProcess The post process to detach from the camera
  31441. */
  31442. detachPostProcess(postProcess: PostProcess): void;
  31443. /**
  31444. * Gets the current world matrix of the camera
  31445. */
  31446. getWorldMatrix(): Matrix;
  31447. /** @hidden */
  31448. _getViewMatrix(): Matrix;
  31449. /**
  31450. * Gets the current view matrix of the camera.
  31451. * @param force forces the camera to recompute the matrix without looking at the cached state
  31452. * @returns the view matrix
  31453. */
  31454. getViewMatrix(force?: boolean): Matrix;
  31455. /**
  31456. * Freeze the projection matrix.
  31457. * It will prevent the cache check of the camera projection compute and can speed up perf
  31458. * if no parameter of the camera are meant to change
  31459. * @param projection Defines manually a projection if necessary
  31460. */
  31461. freezeProjectionMatrix(projection?: Matrix): void;
  31462. /**
  31463. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31464. */
  31465. unfreezeProjectionMatrix(): void;
  31466. /**
  31467. * Gets the current projection matrix of the camera.
  31468. * @param force forces the camera to recompute the matrix without looking at the cached state
  31469. * @returns the projection matrix
  31470. */
  31471. getProjectionMatrix(force?: boolean): Matrix;
  31472. /**
  31473. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31474. * @returns a Matrix
  31475. */
  31476. getTransformationMatrix(): Matrix;
  31477. private _updateFrustumPlanes;
  31478. /**
  31479. * Checks if a cullable object (mesh...) is in the camera frustum
  31480. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31481. * @param target The object to check
  31482. * @returns true if the object is in frustum otherwise false
  31483. */
  31484. isInFrustum(target: ICullable): boolean;
  31485. /**
  31486. * Checks if a cullable object (mesh...) is in the camera frustum
  31487. * Unlike isInFrustum this cheks the full bounding box
  31488. * @param target The object to check
  31489. * @returns true if the object is in frustum otherwise false
  31490. */
  31491. isCompletelyInFrustum(target: ICullable): boolean;
  31492. /**
  31493. * Gets a ray in the forward direction from the camera.
  31494. * @param length Defines the length of the ray to create
  31495. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31496. * @param origin Defines the start point of the ray which defaults to the camera position
  31497. * @returns the forward ray
  31498. */
  31499. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31500. /**
  31501. * Releases resources associated with this node.
  31502. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31503. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31504. */
  31505. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31506. /**
  31507. * Gets the left camera of a rig setup in case of Rigged Camera
  31508. */
  31509. readonly leftCamera: Nullable<FreeCamera>;
  31510. /**
  31511. * Gets the right camera of a rig setup in case of Rigged Camera
  31512. */
  31513. readonly rightCamera: Nullable<FreeCamera>;
  31514. /**
  31515. * Gets the left camera target of a rig setup in case of Rigged Camera
  31516. * @returns the target position
  31517. */
  31518. getLeftTarget(): Nullable<Vector3>;
  31519. /**
  31520. * Gets the right camera target of a rig setup in case of Rigged Camera
  31521. * @returns the target position
  31522. */
  31523. getRightTarget(): Nullable<Vector3>;
  31524. /**
  31525. * @hidden
  31526. */
  31527. setCameraRigMode(mode: number, rigParams: any): void;
  31528. /** @hidden */
  31529. static _setStereoscopicRigMode(camera: Camera): void;
  31530. /** @hidden */
  31531. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31532. /** @hidden */
  31533. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31534. /** @hidden */
  31535. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31536. /** @hidden */
  31537. _getVRProjectionMatrix(): Matrix;
  31538. protected _updateCameraRotationMatrix(): void;
  31539. protected _updateWebVRCameraRotationMatrix(): void;
  31540. /**
  31541. * This function MUST be overwritten by the different WebVR cameras available.
  31542. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31543. * @hidden
  31544. */
  31545. _getWebVRProjectionMatrix(): Matrix;
  31546. /**
  31547. * This function MUST be overwritten by the different WebVR cameras available.
  31548. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31549. * @hidden
  31550. */
  31551. _getWebVRViewMatrix(): Matrix;
  31552. /** @hidden */
  31553. setCameraRigParameter(name: string, value: any): void;
  31554. /**
  31555. * needs to be overridden by children so sub has required properties to be copied
  31556. * @hidden
  31557. */
  31558. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31559. /**
  31560. * May need to be overridden by children
  31561. * @hidden
  31562. */
  31563. _updateRigCameras(): void;
  31564. /** @hidden */
  31565. _setupInputs(): void;
  31566. /**
  31567. * Serialiaze the camera setup to a json represention
  31568. * @returns the JSON representation
  31569. */
  31570. serialize(): any;
  31571. /**
  31572. * Clones the current camera.
  31573. * @param name The cloned camera name
  31574. * @returns the cloned camera
  31575. */
  31576. clone(name: string): Camera;
  31577. /**
  31578. * Gets the direction of the camera relative to a given local axis.
  31579. * @param localAxis Defines the reference axis to provide a relative direction.
  31580. * @return the direction
  31581. */
  31582. getDirection(localAxis: Vector3): Vector3;
  31583. /**
  31584. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31585. * @param localAxis Defines the reference axis to provide a relative direction.
  31586. * @param result Defines the vector to store the result in
  31587. */
  31588. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31589. /**
  31590. * Gets a camera constructor for a given camera type
  31591. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31592. * @param name The name of the camera the result will be able to instantiate
  31593. * @param scene The scene the result will construct the camera in
  31594. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31595. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31596. * @returns a factory method to construc the camera
  31597. */
  31598. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31599. /**
  31600. * Compute the world matrix of the camera.
  31601. * @returns the camera workd matrix
  31602. */
  31603. computeWorldMatrix(): Matrix;
  31604. /**
  31605. * Parse a JSON and creates the camera from the parsed information
  31606. * @param parsedCamera The JSON to parse
  31607. * @param scene The scene to instantiate the camera in
  31608. * @returns the newly constructed camera
  31609. */
  31610. static Parse(parsedCamera: any, scene: Scene): Camera;
  31611. }
  31612. }
  31613. declare module "babylonjs/Misc/tools" {
  31614. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31615. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31616. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31617. import { Observable } from "babylonjs/Misc/observable";
  31618. import { DomManagement } from "babylonjs/Misc/domManagement";
  31619. import { Camera } from "babylonjs/Cameras/camera";
  31620. import { Engine } from "babylonjs/Engines/engine";
  31621. import { Animation } from "babylonjs/Animations/animation";
  31622. /**
  31623. * Interface for any object that can request an animation frame
  31624. */
  31625. export interface ICustomAnimationFrameRequester {
  31626. /**
  31627. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31628. */
  31629. renderFunction?: Function;
  31630. /**
  31631. * Called to request the next frame to render to
  31632. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31633. */
  31634. requestAnimationFrame: Function;
  31635. /**
  31636. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31637. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31638. */
  31639. requestID?: number;
  31640. }
  31641. /**
  31642. * Interface containing an array of animations
  31643. */
  31644. export interface IAnimatable {
  31645. /**
  31646. * Array of animations
  31647. */
  31648. animations: Array<Animation>;
  31649. }
  31650. /** Interface used by value gradients (color, factor, ...) */
  31651. export interface IValueGradient {
  31652. /**
  31653. * Gets or sets the gradient value (between 0 and 1)
  31654. */
  31655. gradient: number;
  31656. }
  31657. /** Class used to store color4 gradient */
  31658. export class ColorGradient implements IValueGradient {
  31659. /**
  31660. * Gets or sets the gradient value (between 0 and 1)
  31661. */
  31662. gradient: number;
  31663. /**
  31664. * Gets or sets first associated color
  31665. */
  31666. color1: Color4;
  31667. /**
  31668. * Gets or sets second associated color
  31669. */
  31670. color2?: Color4;
  31671. /**
  31672. * Will get a color picked randomly between color1 and color2.
  31673. * If color2 is undefined then color1 will be used
  31674. * @param result defines the target Color4 to store the result in
  31675. */
  31676. getColorToRef(result: Color4): void;
  31677. }
  31678. /** Class used to store color 3 gradient */
  31679. export class Color3Gradient implements IValueGradient {
  31680. /**
  31681. * Gets or sets the gradient value (between 0 and 1)
  31682. */
  31683. gradient: number;
  31684. /**
  31685. * Gets or sets the associated color
  31686. */
  31687. color: Color3;
  31688. }
  31689. /** Class used to store factor gradient */
  31690. export class FactorGradient implements IValueGradient {
  31691. /**
  31692. * Gets or sets the gradient value (between 0 and 1)
  31693. */
  31694. gradient: number;
  31695. /**
  31696. * Gets or sets first associated factor
  31697. */
  31698. factor1: number;
  31699. /**
  31700. * Gets or sets second associated factor
  31701. */
  31702. factor2?: number;
  31703. /**
  31704. * Will get a number picked randomly between factor1 and factor2.
  31705. * If factor2 is undefined then factor1 will be used
  31706. * @returns the picked number
  31707. */
  31708. getFactor(): number;
  31709. }
  31710. /**
  31711. * @ignore
  31712. * Application error to support additional information when loading a file
  31713. */
  31714. export class LoadFileError extends Error {
  31715. /** defines the optional XHR request */
  31716. request?: XMLHttpRequest | undefined;
  31717. private static _setPrototypeOf;
  31718. /**
  31719. * Creates a new LoadFileError
  31720. * @param message defines the message of the error
  31721. * @param request defines the optional XHR request
  31722. */
  31723. constructor(message: string,
  31724. /** defines the optional XHR request */
  31725. request?: XMLHttpRequest | undefined);
  31726. }
  31727. /**
  31728. * Class used to define a retry strategy when error happens while loading assets
  31729. */
  31730. export class RetryStrategy {
  31731. /**
  31732. * Function used to defines an exponential back off strategy
  31733. * @param maxRetries defines the maximum number of retries (3 by default)
  31734. * @param baseInterval defines the interval between retries
  31735. * @returns the strategy function to use
  31736. */
  31737. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31738. }
  31739. /**
  31740. * File request interface
  31741. */
  31742. export interface IFileRequest {
  31743. /**
  31744. * Raised when the request is complete (success or error).
  31745. */
  31746. onCompleteObservable: Observable<IFileRequest>;
  31747. /**
  31748. * Aborts the request for a file.
  31749. */
  31750. abort: () => void;
  31751. }
  31752. /**
  31753. * Class containing a set of static utilities functions
  31754. */
  31755. export class Tools {
  31756. /**
  31757. * Gets or sets the base URL to use to load assets
  31758. */
  31759. static BaseUrl: string;
  31760. /**
  31761. * Enable/Disable Custom HTTP Request Headers globally.
  31762. * default = false
  31763. * @see CustomRequestHeaders
  31764. */
  31765. static UseCustomRequestHeaders: boolean;
  31766. /**
  31767. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31768. * i.e. when loading files, where the server/service expects an Authorization header.
  31769. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  31770. */
  31771. static CustomRequestHeaders: {
  31772. [key: string]: string;
  31773. };
  31774. /**
  31775. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31776. */
  31777. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31778. /**
  31779. * Default behaviour for cors in the application.
  31780. * It can be a string if the expected behavior is identical in the entire app.
  31781. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31782. */
  31783. static CorsBehavior: string | ((url: string | string[]) => string);
  31784. /**
  31785. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31786. * @ignorenaming
  31787. */
  31788. static UseFallbackTexture: boolean;
  31789. /**
  31790. * Use this object to register external classes like custom textures or material
  31791. * to allow the laoders to instantiate them
  31792. */
  31793. static RegisteredExternalClasses: {
  31794. [key: string]: Object;
  31795. };
  31796. /**
  31797. * Texture content used if a texture cannot loaded
  31798. * @ignorenaming
  31799. */
  31800. static fallbackTexture: string;
  31801. /**
  31802. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31803. * @param u defines the coordinate on X axis
  31804. * @param v defines the coordinate on Y axis
  31805. * @param width defines the width of the source data
  31806. * @param height defines the height of the source data
  31807. * @param pixels defines the source byte array
  31808. * @param color defines the output color
  31809. */
  31810. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31811. /**
  31812. * Interpolates between a and b via alpha
  31813. * @param a The lower value (returned when alpha = 0)
  31814. * @param b The upper value (returned when alpha = 1)
  31815. * @param alpha The interpolation-factor
  31816. * @return The mixed value
  31817. */
  31818. static Mix(a: number, b: number, alpha: number): number;
  31819. /**
  31820. * Tries to instantiate a new object from a given class name
  31821. * @param className defines the class name to instantiate
  31822. * @returns the new object or null if the system was not able to do the instantiation
  31823. */
  31824. static Instantiate(className: string): any;
  31825. /**
  31826. * Provides a slice function that will work even on IE
  31827. * @param data defines the array to slice
  31828. * @param start defines the start of the data (optional)
  31829. * @param end defines the end of the data (optional)
  31830. * @returns the new sliced array
  31831. */
  31832. static Slice<T>(data: T, start?: number, end?: number): T;
  31833. /**
  31834. * Polyfill for setImmediate
  31835. * @param action defines the action to execute after the current execution block
  31836. */
  31837. static SetImmediate(action: () => void): void;
  31838. /**
  31839. * Function indicating if a number is an exponent of 2
  31840. * @param value defines the value to test
  31841. * @returns true if the value is an exponent of 2
  31842. */
  31843. static IsExponentOfTwo(value: number): boolean;
  31844. private static _tmpFloatArray;
  31845. /**
  31846. * Returns the nearest 32-bit single precision float representation of a Number
  31847. * @param value A Number. If the parameter is of a different type, it will get converted
  31848. * to a number or to NaN if it cannot be converted
  31849. * @returns number
  31850. */
  31851. static FloatRound(value: number): number;
  31852. /**
  31853. * Find the next highest power of two.
  31854. * @param x Number to start search from.
  31855. * @return Next highest power of two.
  31856. */
  31857. static CeilingPOT(x: number): number;
  31858. /**
  31859. * Find the next lowest power of two.
  31860. * @param x Number to start search from.
  31861. * @return Next lowest power of two.
  31862. */
  31863. static FloorPOT(x: number): number;
  31864. /**
  31865. * Find the nearest power of two.
  31866. * @param x Number to start search from.
  31867. * @return Next nearest power of two.
  31868. */
  31869. static NearestPOT(x: number): number;
  31870. /**
  31871. * Get the closest exponent of two
  31872. * @param value defines the value to approximate
  31873. * @param max defines the maximum value to return
  31874. * @param mode defines how to define the closest value
  31875. * @returns closest exponent of two of the given value
  31876. */
  31877. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31878. /**
  31879. * Extracts the filename from a path
  31880. * @param path defines the path to use
  31881. * @returns the filename
  31882. */
  31883. static GetFilename(path: string): string;
  31884. /**
  31885. * Extracts the "folder" part of a path (everything before the filename).
  31886. * @param uri The URI to extract the info from
  31887. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31888. * @returns The "folder" part of the path
  31889. */
  31890. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31891. /**
  31892. * Extracts text content from a DOM element hierarchy
  31893. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31894. */
  31895. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31896. /**
  31897. * Convert an angle in radians to degrees
  31898. * @param angle defines the angle to convert
  31899. * @returns the angle in degrees
  31900. */
  31901. static ToDegrees(angle: number): number;
  31902. /**
  31903. * Convert an angle in degrees to radians
  31904. * @param angle defines the angle to convert
  31905. * @returns the angle in radians
  31906. */
  31907. static ToRadians(angle: number): number;
  31908. /**
  31909. * Encode a buffer to a base64 string
  31910. * @param buffer defines the buffer to encode
  31911. * @returns the encoded string
  31912. */
  31913. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31914. /**
  31915. * Extracts minimum and maximum values from a list of indexed positions
  31916. * @param positions defines the positions to use
  31917. * @param indices defines the indices to the positions
  31918. * @param indexStart defines the start index
  31919. * @param indexCount defines the end index
  31920. * @param bias defines bias value to add to the result
  31921. * @return minimum and maximum values
  31922. */
  31923. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31924. minimum: Vector3;
  31925. maximum: Vector3;
  31926. };
  31927. /**
  31928. * Extracts minimum and maximum values from a list of positions
  31929. * @param positions defines the positions to use
  31930. * @param start defines the start index in the positions array
  31931. * @param count defines the number of positions to handle
  31932. * @param bias defines bias value to add to the result
  31933. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31934. * @return minimum and maximum values
  31935. */
  31936. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31937. minimum: Vector3;
  31938. maximum: Vector3;
  31939. };
  31940. /**
  31941. * Returns an array if obj is not an array
  31942. * @param obj defines the object to evaluate as an array
  31943. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31944. * @returns either obj directly if obj is an array or a new array containing obj
  31945. */
  31946. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31947. /**
  31948. * Gets the pointer prefix to use
  31949. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31950. */
  31951. static GetPointerPrefix(): string;
  31952. /**
  31953. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31954. * @param func - the function to be called
  31955. * @param requester - the object that will request the next frame. Falls back to window.
  31956. * @returns frame number
  31957. */
  31958. static QueueNewFrame(func: () => void, requester?: any): number;
  31959. /**
  31960. * Ask the browser to promote the current element to fullscreen rendering mode
  31961. * @param element defines the DOM element to promote
  31962. */
  31963. static RequestFullscreen(element: HTMLElement): void;
  31964. /**
  31965. * Asks the browser to exit fullscreen mode
  31966. */
  31967. static ExitFullscreen(): void;
  31968. /**
  31969. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31970. * @param url define the url we are trying
  31971. * @param element define the dom element where to configure the cors policy
  31972. */
  31973. static SetCorsBehavior(url: string | string[], element: {
  31974. crossOrigin: string | null;
  31975. }): void;
  31976. /**
  31977. * Removes unwanted characters from an url
  31978. * @param url defines the url to clean
  31979. * @returns the cleaned url
  31980. */
  31981. static CleanUrl(url: string): string;
  31982. /**
  31983. * Gets or sets a function used to pre-process url before using them to load assets
  31984. */
  31985. static PreprocessUrl: (url: string) => string;
  31986. /**
  31987. * Loads an image as an HTMLImageElement.
  31988. * @param input url string, ArrayBuffer, or Blob to load
  31989. * @param onLoad callback called when the image successfully loads
  31990. * @param onError callback called when the image fails to load
  31991. * @param offlineProvider offline provider for caching
  31992. * @returns the HTMLImageElement of the loaded image
  31993. */
  31994. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31995. /**
  31996. * Loads a file
  31997. * @param url url string, ArrayBuffer, or Blob to load
  31998. * @param onSuccess callback called when the file successfully loads
  31999. * @param onProgress callback called while file is loading (if the server supports this mode)
  32000. * @param offlineProvider defines the offline provider for caching
  32001. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32002. * @param onError callback called when the file fails to load
  32003. * @returns a file request object
  32004. */
  32005. 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;
  32006. /**
  32007. * Load a script (identified by an url). When the url returns, the
  32008. * content of this file is added into a new script element, attached to the DOM (body element)
  32009. * @param scriptUrl defines the url of the script to laod
  32010. * @param onSuccess defines the callback called when the script is loaded
  32011. * @param onError defines the callback to call if an error occurs
  32012. */
  32013. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32014. /**
  32015. * Loads a file from a blob
  32016. * @param fileToLoad defines the blob to use
  32017. * @param callback defines the callback to call when data is loaded
  32018. * @param progressCallback defines the callback to call during loading process
  32019. * @returns a file request object
  32020. */
  32021. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32022. /**
  32023. * Loads a file
  32024. * @param fileToLoad defines the file to load
  32025. * @param callback defines the callback to call when data is loaded
  32026. * @param progressCallBack defines the callback to call during loading process
  32027. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32028. * @returns a file request object
  32029. */
  32030. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32031. /**
  32032. * Creates a data url from a given string content
  32033. * @param content defines the content to convert
  32034. * @returns the new data url link
  32035. */
  32036. static FileAsURL(content: string): string;
  32037. /**
  32038. * Format the given number to a specific decimal format
  32039. * @param value defines the number to format
  32040. * @param decimals defines the number of decimals to use
  32041. * @returns the formatted string
  32042. */
  32043. static Format(value: number, decimals?: number): string;
  32044. /**
  32045. * Checks if a given vector is inside a specific range
  32046. * @param v defines the vector to test
  32047. * @param min defines the minimum range
  32048. * @param max defines the maximum range
  32049. */
  32050. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32051. /**
  32052. * Tries to copy an object by duplicating every property
  32053. * @param source defines the source object
  32054. * @param destination defines the target object
  32055. * @param doNotCopyList defines a list of properties to avoid
  32056. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32057. */
  32058. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32059. /**
  32060. * Gets a boolean indicating if the given object has no own property
  32061. * @param obj defines the object to test
  32062. * @returns true if object has no own property
  32063. */
  32064. static IsEmpty(obj: any): boolean;
  32065. /**
  32066. * Function used to register events at window level
  32067. * @param events defines the events to register
  32068. */
  32069. static RegisterTopRootEvents(events: {
  32070. name: string;
  32071. handler: Nullable<(e: FocusEvent) => any>;
  32072. }[]): void;
  32073. /**
  32074. * Function used to unregister events from window level
  32075. * @param events defines the events to unregister
  32076. */
  32077. static UnregisterTopRootEvents(events: {
  32078. name: string;
  32079. handler: Nullable<(e: FocusEvent) => any>;
  32080. }[]): void;
  32081. /**
  32082. * Dumps the current bound framebuffer
  32083. * @param width defines the rendering width
  32084. * @param height defines the rendering height
  32085. * @param engine defines the hosting engine
  32086. * @param successCallback defines the callback triggered once the data are available
  32087. * @param mimeType defines the mime type of the result
  32088. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32089. */
  32090. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32091. /**
  32092. * Converts the canvas data to blob.
  32093. * This acts as a polyfill for browsers not supporting the to blob function.
  32094. * @param canvas Defines the canvas to extract the data from
  32095. * @param successCallback Defines the callback triggered once the data are available
  32096. * @param mimeType Defines the mime type of the result
  32097. */
  32098. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32099. /**
  32100. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32101. * @param successCallback defines the callback triggered once the data are available
  32102. * @param mimeType defines the mime type of the result
  32103. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32104. */
  32105. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32106. /**
  32107. * Downloads a blob in the browser
  32108. * @param blob defines the blob to download
  32109. * @param fileName defines the name of the downloaded file
  32110. */
  32111. static Download(blob: Blob, fileName: string): void;
  32112. /**
  32113. * Captures a screenshot of the current rendering
  32114. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32115. * @param engine defines the rendering engine
  32116. * @param camera defines the source camera
  32117. * @param size This parameter can be set to a single number or to an object with the
  32118. * following (optional) properties: precision, width, height. If a single number is passed,
  32119. * it will be used for both width and height. If an object is passed, the screenshot size
  32120. * will be derived from the parameters. The precision property is a multiplier allowing
  32121. * rendering at a higher or lower resolution
  32122. * @param successCallback defines the callback receives a single parameter which contains the
  32123. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32124. * src parameter of an <img> to display it
  32125. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32126. * Check your browser for supported MIME types
  32127. */
  32128. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32129. /**
  32130. * Generates an image screenshot from the specified camera.
  32131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32132. * @param engine The engine to use for rendering
  32133. * @param camera The camera to use for rendering
  32134. * @param size This parameter can be set to a single number or to an object with the
  32135. * following (optional) properties: precision, width, height. If a single number is passed,
  32136. * it will be used for both width and height. If an object is passed, the screenshot size
  32137. * will be derived from the parameters. The precision property is a multiplier allowing
  32138. * rendering at a higher or lower resolution
  32139. * @param successCallback The callback receives a single parameter which contains the
  32140. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32141. * src parameter of an <img> to display it
  32142. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32143. * Check your browser for supported MIME types
  32144. * @param samples Texture samples (default: 1)
  32145. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32146. * @param fileName A name for for the downloaded file.
  32147. */
  32148. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32149. /**
  32150. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32151. * Be aware Math.random() could cause collisions, but:
  32152. * "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"
  32153. * @returns a pseudo random id
  32154. */
  32155. static RandomId(): string;
  32156. /**
  32157. * Test if the given uri is a base64 string
  32158. * @param uri The uri to test
  32159. * @return True if the uri is a base64 string or false otherwise
  32160. */
  32161. static IsBase64(uri: string): boolean;
  32162. /**
  32163. * Decode the given base64 uri.
  32164. * @param uri The uri to decode
  32165. * @return The decoded base64 data.
  32166. */
  32167. static DecodeBase64(uri: string): ArrayBuffer;
  32168. /**
  32169. * No log
  32170. */
  32171. static readonly NoneLogLevel: number;
  32172. /**
  32173. * Only message logs
  32174. */
  32175. static readonly MessageLogLevel: number;
  32176. /**
  32177. * Only warning logs
  32178. */
  32179. static readonly WarningLogLevel: number;
  32180. /**
  32181. * Only error logs
  32182. */
  32183. static readonly ErrorLogLevel: number;
  32184. /**
  32185. * All logs
  32186. */
  32187. static readonly AllLogLevel: number;
  32188. /**
  32189. * Gets a value indicating the number of loading errors
  32190. * @ignorenaming
  32191. */
  32192. static readonly errorsCount: number;
  32193. /**
  32194. * Callback called when a new log is added
  32195. */
  32196. static OnNewCacheEntry: (entry: string) => void;
  32197. /**
  32198. * Log a message to the console
  32199. * @param message defines the message to log
  32200. */
  32201. static Log(message: string): void;
  32202. /**
  32203. * Write a warning message to the console
  32204. * @param message defines the message to log
  32205. */
  32206. static Warn(message: string): void;
  32207. /**
  32208. * Write an error message to the console
  32209. * @param message defines the message to log
  32210. */
  32211. static Error(message: string): void;
  32212. /**
  32213. * Gets current log cache (list of logs)
  32214. */
  32215. static readonly LogCache: string;
  32216. /**
  32217. * Clears the log cache
  32218. */
  32219. static ClearLogCache(): void;
  32220. /**
  32221. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32222. */
  32223. static LogLevels: number;
  32224. /**
  32225. * Checks if the loaded document was accessed via `file:`-Protocol.
  32226. * @returns boolean
  32227. */
  32228. static IsFileURL(): boolean;
  32229. /**
  32230. * Checks if the window object exists
  32231. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32232. */
  32233. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32234. /**
  32235. * No performance log
  32236. */
  32237. static readonly PerformanceNoneLogLevel: number;
  32238. /**
  32239. * Use user marks to log performance
  32240. */
  32241. static readonly PerformanceUserMarkLogLevel: number;
  32242. /**
  32243. * Log performance to the console
  32244. */
  32245. static readonly PerformanceConsoleLogLevel: number;
  32246. private static _performance;
  32247. /**
  32248. * Sets the current performance log level
  32249. */
  32250. static PerformanceLogLevel: number;
  32251. private static _StartPerformanceCounterDisabled;
  32252. private static _EndPerformanceCounterDisabled;
  32253. private static _StartUserMark;
  32254. private static _EndUserMark;
  32255. private static _StartPerformanceConsole;
  32256. private static _EndPerformanceConsole;
  32257. /**
  32258. * Injects the @see CustomRequestHeaders into the given request
  32259. * @param request the request that should be used for injection
  32260. */
  32261. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  32262. /**
  32263. * Starts a performance counter
  32264. */
  32265. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32266. /**
  32267. * Ends a specific performance coutner
  32268. */
  32269. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32270. /**
  32271. * Gets either window.performance.now() if supported or Date.now() else
  32272. */
  32273. static readonly Now: number;
  32274. /**
  32275. * This method will return the name of the class used to create the instance of the given object.
  32276. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32277. * @param object the object to get the class name from
  32278. * @param isType defines if the object is actually a type
  32279. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32280. */
  32281. static GetClassName(object: any, isType?: boolean): string;
  32282. /**
  32283. * Gets the first element of an array satisfying a given predicate
  32284. * @param array defines the array to browse
  32285. * @param predicate defines the predicate to use
  32286. * @returns null if not found or the element
  32287. */
  32288. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32289. /**
  32290. * This method will return the name of the full name of the class, including its owning module (if any).
  32291. * 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).
  32292. * @param object the object to get the class name from
  32293. * @param isType defines if the object is actually a type
  32294. * @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.
  32295. * @ignorenaming
  32296. */
  32297. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32298. /**
  32299. * Returns a promise that resolves after the given amount of time.
  32300. * @param delay Number of milliseconds to delay
  32301. * @returns Promise that resolves after the given amount of time
  32302. */
  32303. static DelayAsync(delay: number): Promise<void>;
  32304. /**
  32305. * Gets the current gradient from an array of IValueGradient
  32306. * @param ratio defines the current ratio to get
  32307. * @param gradients defines the array of IValueGradient
  32308. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32309. */
  32310. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32311. }
  32312. /**
  32313. * This class is used to track a performance counter which is number based.
  32314. * The user has access to many properties which give statistics of different nature.
  32315. *
  32316. * The implementer can track two kinds of Performance Counter: time and count.
  32317. * 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.
  32318. * 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.
  32319. */
  32320. export class PerfCounter {
  32321. /**
  32322. * Gets or sets a global boolean to turn on and off all the counters
  32323. */
  32324. static Enabled: boolean;
  32325. /**
  32326. * Returns the smallest value ever
  32327. */
  32328. readonly min: number;
  32329. /**
  32330. * Returns the biggest value ever
  32331. */
  32332. readonly max: number;
  32333. /**
  32334. * Returns the average value since the performance counter is running
  32335. */
  32336. readonly average: number;
  32337. /**
  32338. * Returns the average value of the last second the counter was monitored
  32339. */
  32340. readonly lastSecAverage: number;
  32341. /**
  32342. * Returns the current value
  32343. */
  32344. readonly current: number;
  32345. /**
  32346. * Gets the accumulated total
  32347. */
  32348. readonly total: number;
  32349. /**
  32350. * Gets the total value count
  32351. */
  32352. readonly count: number;
  32353. /**
  32354. * Creates a new counter
  32355. */
  32356. constructor();
  32357. /**
  32358. * Call this method to start monitoring a new frame.
  32359. * 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.
  32360. */
  32361. fetchNewFrame(): void;
  32362. /**
  32363. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32364. * @param newCount the count value to add to the monitored count
  32365. * @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.
  32366. */
  32367. addCount(newCount: number, fetchResult: boolean): void;
  32368. /**
  32369. * Start monitoring this performance counter
  32370. */
  32371. beginMonitoring(): void;
  32372. /**
  32373. * Compute the time lapsed since the previous beginMonitoring() call.
  32374. * @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
  32375. */
  32376. endMonitoring(newFrame?: boolean): void;
  32377. private _fetchResult;
  32378. private _startMonitoringTime;
  32379. private _min;
  32380. private _max;
  32381. private _average;
  32382. private _current;
  32383. private _totalValueCount;
  32384. private _totalAccumulated;
  32385. private _lastSecAverage;
  32386. private _lastSecAccumulated;
  32387. private _lastSecTime;
  32388. private _lastSecValueCount;
  32389. }
  32390. /**
  32391. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32392. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32393. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32394. * @param name The name of the class, case should be preserved
  32395. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32396. */
  32397. export function className(name: string, module?: string): (target: Object) => void;
  32398. /**
  32399. * An implementation of a loop for asynchronous functions.
  32400. */
  32401. export class AsyncLoop {
  32402. /**
  32403. * Defines the number of iterations for the loop
  32404. */
  32405. iterations: number;
  32406. /**
  32407. * Defines the current index of the loop.
  32408. */
  32409. index: number;
  32410. private _done;
  32411. private _fn;
  32412. private _successCallback;
  32413. /**
  32414. * Constructor.
  32415. * @param iterations the number of iterations.
  32416. * @param func the function to run each iteration
  32417. * @param successCallback the callback that will be called upon succesful execution
  32418. * @param offset starting offset.
  32419. */
  32420. constructor(
  32421. /**
  32422. * Defines the number of iterations for the loop
  32423. */
  32424. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32425. /**
  32426. * Execute the next iteration. Must be called after the last iteration was finished.
  32427. */
  32428. executeNext(): void;
  32429. /**
  32430. * Break the loop and run the success callback.
  32431. */
  32432. breakLoop(): void;
  32433. /**
  32434. * Create and run an async loop.
  32435. * @param iterations the number of iterations.
  32436. * @param fn the function to run each iteration
  32437. * @param successCallback the callback that will be called upon succesful execution
  32438. * @param offset starting offset.
  32439. * @returns the created async loop object
  32440. */
  32441. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32442. /**
  32443. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32444. * @param iterations total number of iterations
  32445. * @param syncedIterations number of synchronous iterations in each async iteration.
  32446. * @param fn the function to call each iteration.
  32447. * @param callback a success call back that will be called when iterating stops.
  32448. * @param breakFunction a break condition (optional)
  32449. * @param timeout timeout settings for the setTimeout function. default - 0.
  32450. * @returns the created async loop object
  32451. */
  32452. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32453. }
  32454. }
  32455. declare module "babylonjs/Animations/animationGroup" {
  32456. import { Animatable } from "babylonjs/Animations/animatable";
  32457. import { Animation } from "babylonjs/Animations/animation";
  32458. import { Scene, IDisposable } from "babylonjs/scene";
  32459. import { Observable } from "babylonjs/Misc/observable";
  32460. import { Nullable } from "babylonjs/types";
  32461. /**
  32462. * This class defines the direct association between an animation and a target
  32463. */
  32464. export class TargetedAnimation {
  32465. /**
  32466. * Animation to perform
  32467. */
  32468. animation: Animation;
  32469. /**
  32470. * Target to animate
  32471. */
  32472. target: any;
  32473. }
  32474. /**
  32475. * Use this class to create coordinated animations on multiple targets
  32476. */
  32477. export class AnimationGroup implements IDisposable {
  32478. /** The name of the animation group */
  32479. name: string;
  32480. private _scene;
  32481. private _targetedAnimations;
  32482. private _animatables;
  32483. private _from;
  32484. private _to;
  32485. private _isStarted;
  32486. private _isPaused;
  32487. private _speedRatio;
  32488. /**
  32489. * Gets or sets the unique id of the node
  32490. */
  32491. uniqueId: number;
  32492. /**
  32493. * This observable will notify when one animation have ended
  32494. */
  32495. onAnimationEndObservable: Observable<TargetedAnimation>;
  32496. /**
  32497. * Observer raised when one animation loops
  32498. */
  32499. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32500. /**
  32501. * This observable will notify when all animations have ended.
  32502. */
  32503. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32504. /**
  32505. * This observable will notify when all animations have paused.
  32506. */
  32507. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32508. /**
  32509. * This observable will notify when all animations are playing.
  32510. */
  32511. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32512. /**
  32513. * Gets the first frame
  32514. */
  32515. readonly from: number;
  32516. /**
  32517. * Gets the last frame
  32518. */
  32519. readonly to: number;
  32520. /**
  32521. * Define if the animations are started
  32522. */
  32523. readonly isStarted: boolean;
  32524. /**
  32525. * Gets a value indicating that the current group is playing
  32526. */
  32527. readonly isPlaying: boolean;
  32528. /**
  32529. * Gets or sets the speed ratio to use for all animations
  32530. */
  32531. /**
  32532. * Gets or sets the speed ratio to use for all animations
  32533. */
  32534. speedRatio: number;
  32535. /**
  32536. * Gets the targeted animations for this animation group
  32537. */
  32538. readonly targetedAnimations: Array<TargetedAnimation>;
  32539. /**
  32540. * returning the list of animatables controlled by this animation group.
  32541. */
  32542. readonly animatables: Array<Animatable>;
  32543. /**
  32544. * Instantiates a new Animation Group.
  32545. * This helps managing several animations at once.
  32546. * @see http://doc.babylonjs.com/how_to/group
  32547. * @param name Defines the name of the group
  32548. * @param scene Defines the scene the group belongs to
  32549. */
  32550. constructor(
  32551. /** The name of the animation group */
  32552. name: string, scene?: Nullable<Scene>);
  32553. /**
  32554. * Add an animation (with its target) in the group
  32555. * @param animation defines the animation we want to add
  32556. * @param target defines the target of the animation
  32557. * @returns the TargetedAnimation object
  32558. */
  32559. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32560. /**
  32561. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32562. * It can add constant keys at begin or end
  32563. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32564. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32565. * @returns the animation group
  32566. */
  32567. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32568. /**
  32569. * Start all animations on given targets
  32570. * @param loop defines if animations must loop
  32571. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32572. * @param from defines the from key (optional)
  32573. * @param to defines the to key (optional)
  32574. * @returns the current animation group
  32575. */
  32576. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32577. /**
  32578. * Pause all animations
  32579. * @returns the animation group
  32580. */
  32581. pause(): AnimationGroup;
  32582. /**
  32583. * Play all animations to initial state
  32584. * This function will start() the animations if they were not started or will restart() them if they were paused
  32585. * @param loop defines if animations must loop
  32586. * @returns the animation group
  32587. */
  32588. play(loop?: boolean): AnimationGroup;
  32589. /**
  32590. * Reset all animations to initial state
  32591. * @returns the animation group
  32592. */
  32593. reset(): AnimationGroup;
  32594. /**
  32595. * Restart animations from key 0
  32596. * @returns the animation group
  32597. */
  32598. restart(): AnimationGroup;
  32599. /**
  32600. * Stop all animations
  32601. * @returns the animation group
  32602. */
  32603. stop(): AnimationGroup;
  32604. /**
  32605. * Set animation weight for all animatables
  32606. * @param weight defines the weight to use
  32607. * @return the animationGroup
  32608. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32609. */
  32610. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32611. /**
  32612. * Synchronize and normalize all animatables with a source animatable
  32613. * @param root defines the root animatable to synchronize with
  32614. * @return the animationGroup
  32615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32616. */
  32617. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32618. /**
  32619. * Goes to a specific frame in this animation group
  32620. * @param frame the frame number to go to
  32621. * @return the animationGroup
  32622. */
  32623. goToFrame(frame: number): AnimationGroup;
  32624. /**
  32625. * Dispose all associated resources
  32626. */
  32627. dispose(): void;
  32628. private _checkAnimationGroupEnded;
  32629. /**
  32630. * Returns a new AnimationGroup object parsed from the source provided.
  32631. * @param parsedAnimationGroup defines the source
  32632. * @param scene defines the scene that will receive the animationGroup
  32633. * @returns a new AnimationGroup
  32634. */
  32635. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32636. /**
  32637. * Returns the string "AnimationGroup"
  32638. * @returns "AnimationGroup"
  32639. */
  32640. getClassName(): string;
  32641. /**
  32642. * Creates a detailled string about the object
  32643. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32644. * @returns a string representing the object
  32645. */
  32646. toString(fullDetails?: boolean): string;
  32647. }
  32648. }
  32649. declare module "babylonjs/Collisions/collisionCoordinator" {
  32650. import { Nullable } from "babylonjs/types";
  32651. import { Scene } from "babylonjs/scene";
  32652. import { Vector3 } from "babylonjs/Maths/math";
  32653. import { Collider } from "babylonjs/Collisions/collider";
  32654. import { Geometry } from "babylonjs/Meshes/geometry";
  32655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32656. /** @hidden */
  32657. export interface ICollisionCoordinator {
  32658. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32659. init(scene: Scene): void;
  32660. destroy(): void;
  32661. onMeshAdded(mesh: AbstractMesh): void;
  32662. onMeshUpdated(mesh: AbstractMesh): void;
  32663. onMeshRemoved(mesh: AbstractMesh): void;
  32664. onGeometryAdded(geometry: Geometry): void;
  32665. onGeometryUpdated(geometry: Geometry): void;
  32666. onGeometryDeleted(geometry: Geometry): void;
  32667. }
  32668. /** @hidden */
  32669. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  32670. private _scene;
  32671. private _scaledPosition;
  32672. private _scaledVelocity;
  32673. private _finalPosition;
  32674. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32675. init(scene: Scene): void;
  32676. destroy(): void;
  32677. onMeshAdded(mesh: AbstractMesh): void;
  32678. onMeshUpdated(mesh: AbstractMesh): void;
  32679. onMeshRemoved(mesh: AbstractMesh): void;
  32680. onGeometryAdded(geometry: Geometry): void;
  32681. onGeometryUpdated(geometry: Geometry): void;
  32682. onGeometryDeleted(geometry: Geometry): void;
  32683. private _collideWithWorld;
  32684. }
  32685. }
  32686. declare module "babylonjs/scene" {
  32687. import { Nullable } from "babylonjs/types";
  32688. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32689. import { Observable } from "babylonjs/Misc/observable";
  32690. import { SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32691. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32692. import { Geometry } from "babylonjs/Meshes/geometry";
  32693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32696. import { Mesh } from "babylonjs/Meshes/mesh";
  32697. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32698. import { Bone } from "babylonjs/Bones/bone";
  32699. import { Skeleton } from "babylonjs/Bones/skeleton";
  32700. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32701. import { Camera } from "babylonjs/Cameras/camera";
  32702. import { AbstractScene } from "babylonjs/abstractScene";
  32703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32705. import { Material } from "babylonjs/Materials/material";
  32706. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32707. import { Effect } from "babylonjs/Materials/effect";
  32708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32709. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32710. import { Animation } from "babylonjs/Animations/animation";
  32711. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  32712. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32713. import { Animatable } from "babylonjs/Animations/animatable";
  32714. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32715. import { Light } from "babylonjs/Lights/light";
  32716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32717. import { Collider } from "babylonjs/Collisions/collider";
  32718. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32719. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32720. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32721. import { ActionManager } from "babylonjs/Actions/actionManager";
  32722. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32723. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32724. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32725. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32726. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32727. import { Engine } from "babylonjs/Engines/engine";
  32728. import { Ray } from "babylonjs/Culling/ray";
  32729. import { Node } from "babylonjs/node";
  32730. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32731. /**
  32732. * Define an interface for all classes that will hold resources
  32733. */
  32734. export interface IDisposable {
  32735. /**
  32736. * Releases all held resources
  32737. */
  32738. dispose(): void;
  32739. }
  32740. /** Interface defining initialization parameters for Scene class */
  32741. export interface SceneOptions {
  32742. /**
  32743. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32744. * It will improve performance when the number of geometries becomes important.
  32745. */
  32746. useGeometryUniqueIdsMap?: boolean;
  32747. /**
  32748. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32749. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32750. */
  32751. useMaterialMeshMap?: boolean;
  32752. /**
  32753. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32754. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32755. */
  32756. useClonedMeshhMap?: boolean;
  32757. }
  32758. /**
  32759. * Represents a scene to be rendered by the engine.
  32760. * @see http://doc.babylonjs.com/features/scene
  32761. */
  32762. export class Scene extends AbstractScene implements IAnimatable {
  32763. private static _uniqueIdCounter;
  32764. /** The fog is deactivated */
  32765. static readonly FOGMODE_NONE: number;
  32766. /** The fog density is following an exponential function */
  32767. static readonly FOGMODE_EXP: number;
  32768. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32769. static readonly FOGMODE_EXP2: number;
  32770. /** The fog density is following a linear function. */
  32771. static readonly FOGMODE_LINEAR: number;
  32772. /**
  32773. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32775. */
  32776. static MinDeltaTime: number;
  32777. /**
  32778. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32780. */
  32781. static MaxDeltaTime: number;
  32782. /**
  32783. * Factory used to create the default material.
  32784. * @param name The name of the material to create
  32785. * @param scene The scene to create the material for
  32786. * @returns The default material
  32787. */
  32788. static DefaultMaterialFactory(scene: Scene): Material;
  32789. /** @hidden */
  32790. readonly _isScene: boolean;
  32791. /**
  32792. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32793. */
  32794. autoClear: boolean;
  32795. /**
  32796. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32797. */
  32798. autoClearDepthAndStencil: boolean;
  32799. /**
  32800. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32801. */
  32802. clearColor: Color4;
  32803. /**
  32804. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32805. */
  32806. ambientColor: Color3;
  32807. /** @hidden */
  32808. _environmentBRDFTexture: BaseTexture;
  32809. /** @hidden */
  32810. protected _environmentTexture: Nullable<BaseTexture>;
  32811. /**
  32812. * Texture used in all pbr material as the reflection texture.
  32813. * As in the majority of the scene they are the same (exception for multi room and so on),
  32814. * this is easier to reference from here than from all the materials.
  32815. */
  32816. /**
  32817. * Texture used in all pbr material as the reflection texture.
  32818. * As in the majority of the scene they are the same (exception for multi room and so on),
  32819. * this is easier to set here than in all the materials.
  32820. */
  32821. environmentTexture: Nullable<BaseTexture>;
  32822. /** @hidden */
  32823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32824. /**
  32825. * Default image processing configuration used either in the rendering
  32826. * Forward main pass or through the imageProcessingPostProcess if present.
  32827. * As in the majority of the scene they are the same (exception for multi camera),
  32828. * this is easier to reference from here than from all the materials and post process.
  32829. *
  32830. * No setter as we it is a shared configuration, you can set the values instead.
  32831. */
  32832. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32833. private _forceWireframe;
  32834. /**
  32835. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32836. */
  32837. forceWireframe: boolean;
  32838. private _forcePointsCloud;
  32839. /**
  32840. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32841. */
  32842. forcePointsCloud: boolean;
  32843. /**
  32844. * Gets or sets the active clipplane 1
  32845. */
  32846. clipPlane: Nullable<Plane>;
  32847. /**
  32848. * Gets or sets the active clipplane 2
  32849. */
  32850. clipPlane2: Nullable<Plane>;
  32851. /**
  32852. * Gets or sets the active clipplane 3
  32853. */
  32854. clipPlane3: Nullable<Plane>;
  32855. /**
  32856. * Gets or sets the active clipplane 4
  32857. */
  32858. clipPlane4: Nullable<Plane>;
  32859. /**
  32860. * Gets or sets a boolean indicating if animations are enabled
  32861. */
  32862. animationsEnabled: boolean;
  32863. private _animationPropertiesOverride;
  32864. /**
  32865. * Gets or sets the animation properties override
  32866. */
  32867. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32868. /**
  32869. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32870. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32871. */
  32872. useConstantAnimationDeltaTime: boolean;
  32873. /**
  32874. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32875. * Please note that it requires to run a ray cast through the scene on every frame
  32876. */
  32877. constantlyUpdateMeshUnderPointer: boolean;
  32878. /**
  32879. * Defines the HTML cursor to use when hovering over interactive elements
  32880. */
  32881. hoverCursor: string;
  32882. /**
  32883. * Defines the HTML default cursor to use (empty by default)
  32884. */
  32885. defaultCursor: string;
  32886. /**
  32887. * This is used to call preventDefault() on pointer down
  32888. * in order to block unwanted artifacts like system double clicks
  32889. */
  32890. preventDefaultOnPointerDown: boolean;
  32891. /**
  32892. * This is used to call preventDefault() on pointer up
  32893. * in order to block unwanted artifacts like system double clicks
  32894. */
  32895. preventDefaultOnPointerUp: boolean;
  32896. /**
  32897. * Gets or sets user defined metadata
  32898. */
  32899. metadata: any;
  32900. /**
  32901. * For internal use only. Please do not use.
  32902. */
  32903. reservedDataStore: any;
  32904. /**
  32905. * Gets the name of the plugin used to load this scene (null by default)
  32906. */
  32907. loadingPluginName: string;
  32908. /**
  32909. * Use this array to add regular expressions used to disable offline support for specific urls
  32910. */
  32911. disableOfflineSupportExceptionRules: RegExp[];
  32912. /**
  32913. * An event triggered when the scene is disposed.
  32914. */
  32915. onDisposeObservable: Observable<Scene>;
  32916. private _onDisposeObserver;
  32917. /** Sets a function to be executed when this scene is disposed. */
  32918. onDispose: () => void;
  32919. /**
  32920. * An event triggered before rendering the scene (right after animations and physics)
  32921. */
  32922. onBeforeRenderObservable: Observable<Scene>;
  32923. private _onBeforeRenderObserver;
  32924. /** Sets a function to be executed before rendering this scene */
  32925. beforeRender: Nullable<() => void>;
  32926. /**
  32927. * An event triggered after rendering the scene
  32928. */
  32929. onAfterRenderObservable: Observable<Scene>;
  32930. private _onAfterRenderObserver;
  32931. /** Sets a function to be executed after rendering this scene */
  32932. afterRender: Nullable<() => void>;
  32933. /**
  32934. * An event triggered before animating the scene
  32935. */
  32936. onBeforeAnimationsObservable: Observable<Scene>;
  32937. /**
  32938. * An event triggered after animations processing
  32939. */
  32940. onAfterAnimationsObservable: Observable<Scene>;
  32941. /**
  32942. * An event triggered before draw calls are ready to be sent
  32943. */
  32944. onBeforeDrawPhaseObservable: Observable<Scene>;
  32945. /**
  32946. * An event triggered after draw calls have been sent
  32947. */
  32948. onAfterDrawPhaseObservable: Observable<Scene>;
  32949. /**
  32950. * An event triggered when the scene is ready
  32951. */
  32952. onReadyObservable: Observable<Scene>;
  32953. /**
  32954. * An event triggered before rendering a camera
  32955. */
  32956. onBeforeCameraRenderObservable: Observable<Camera>;
  32957. private _onBeforeCameraRenderObserver;
  32958. /** Sets a function to be executed before rendering a camera*/
  32959. beforeCameraRender: () => void;
  32960. /**
  32961. * An event triggered after rendering a camera
  32962. */
  32963. onAfterCameraRenderObservable: Observable<Camera>;
  32964. private _onAfterCameraRenderObserver;
  32965. /** Sets a function to be executed after rendering a camera*/
  32966. afterCameraRender: () => void;
  32967. /**
  32968. * An event triggered when active meshes evaluation is about to start
  32969. */
  32970. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32971. /**
  32972. * An event triggered when active meshes evaluation is done
  32973. */
  32974. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32975. /**
  32976. * An event triggered when particles rendering is about to start
  32977. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32978. */
  32979. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32980. /**
  32981. * An event triggered when particles rendering is done
  32982. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32983. */
  32984. onAfterParticlesRenderingObservable: Observable<Scene>;
  32985. /**
  32986. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32987. */
  32988. onDataLoadedObservable: Observable<Scene>;
  32989. /**
  32990. * An event triggered when a camera is created
  32991. */
  32992. onNewCameraAddedObservable: Observable<Camera>;
  32993. /**
  32994. * An event triggered when a camera is removed
  32995. */
  32996. onCameraRemovedObservable: Observable<Camera>;
  32997. /**
  32998. * An event triggered when a light is created
  32999. */
  33000. onNewLightAddedObservable: Observable<Light>;
  33001. /**
  33002. * An event triggered when a light is removed
  33003. */
  33004. onLightRemovedObservable: Observable<Light>;
  33005. /**
  33006. * An event triggered when a geometry is created
  33007. */
  33008. onNewGeometryAddedObservable: Observable<Geometry>;
  33009. /**
  33010. * An event triggered when a geometry is removed
  33011. */
  33012. onGeometryRemovedObservable: Observable<Geometry>;
  33013. /**
  33014. * An event triggered when a transform node is created
  33015. */
  33016. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33017. /**
  33018. * An event triggered when a transform node is removed
  33019. */
  33020. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33021. /**
  33022. * An event triggered when a mesh is created
  33023. */
  33024. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33025. /**
  33026. * An event triggered when a mesh is removed
  33027. */
  33028. onMeshRemovedObservable: Observable<AbstractMesh>;
  33029. /**
  33030. * An event triggered when a material is created
  33031. */
  33032. onNewMaterialAddedObservable: Observable<Material>;
  33033. /**
  33034. * An event triggered when a material is removed
  33035. */
  33036. onMaterialRemovedObservable: Observable<Material>;
  33037. /**
  33038. * An event triggered when a texture is created
  33039. */
  33040. onNewTextureAddedObservable: Observable<BaseTexture>;
  33041. /**
  33042. * An event triggered when a texture is removed
  33043. */
  33044. onTextureRemovedObservable: Observable<BaseTexture>;
  33045. /**
  33046. * An event triggered when render targets are about to be rendered
  33047. * Can happen multiple times per frame.
  33048. */
  33049. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33050. /**
  33051. * An event triggered when render targets were rendered.
  33052. * Can happen multiple times per frame.
  33053. */
  33054. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33055. /**
  33056. * An event triggered before calculating deterministic simulation step
  33057. */
  33058. onBeforeStepObservable: Observable<Scene>;
  33059. /**
  33060. * An event triggered after calculating deterministic simulation step
  33061. */
  33062. onAfterStepObservable: Observable<Scene>;
  33063. /**
  33064. * An event triggered when the activeCamera property is updated
  33065. */
  33066. onActiveCameraChanged: Observable<Scene>;
  33067. /**
  33068. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33069. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33070. * 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)
  33071. */
  33072. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33073. /**
  33074. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33075. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33076. * 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)
  33077. */
  33078. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33079. /**
  33080. * This Observable will when a mesh has been imported into the scene.
  33081. */
  33082. onMeshImportedObservable: Observable<AbstractMesh>;
  33083. private _registeredForLateAnimationBindings;
  33084. /**
  33085. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33086. */
  33087. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33088. /**
  33089. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33090. */
  33091. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33092. /**
  33093. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33094. */
  33095. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33096. private _onPointerMove;
  33097. private _onPointerDown;
  33098. private _onPointerUp;
  33099. /** Callback called when a pointer move is detected */
  33100. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33101. /** Callback called when a pointer down is detected */
  33102. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33103. /** Callback called when a pointer up is detected */
  33104. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33105. /** Callback called when a pointer pick is detected */
  33106. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33107. /**
  33108. * 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).
  33109. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33110. */
  33111. onPrePointerObservable: Observable<PointerInfoPre>;
  33112. /**
  33113. * Observable event triggered each time an input event is received from the rendering canvas
  33114. */
  33115. onPointerObservable: Observable<PointerInfo>;
  33116. /**
  33117. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33118. */
  33119. readonly unTranslatedPointer: Vector2;
  33120. /** The distance in pixel that you have to move to prevent some events */
  33121. static DragMovementThreshold: number;
  33122. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33123. static LongPressDelay: number;
  33124. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33125. static DoubleClickDelay: number;
  33126. /** If you need to check double click without raising a single click at first click, enable this flag */
  33127. static ExclusiveDoubleClickMode: boolean;
  33128. private _initClickEvent;
  33129. private _initActionManager;
  33130. private _delayedSimpleClick;
  33131. private _delayedSimpleClickTimeout;
  33132. private _previousDelayedSimpleClickTimeout;
  33133. private _meshPickProceed;
  33134. private _previousButtonPressed;
  33135. private _currentPickResult;
  33136. private _previousPickResult;
  33137. private _totalPointersPressed;
  33138. private _doubleClickOccured;
  33139. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33140. cameraToUseForPointers: Nullable<Camera>;
  33141. private _pointerX;
  33142. private _pointerY;
  33143. private _unTranslatedPointerX;
  33144. private _unTranslatedPointerY;
  33145. private _startingPointerPosition;
  33146. private _previousStartingPointerPosition;
  33147. private _startingPointerTime;
  33148. private _previousStartingPointerTime;
  33149. private _pointerCaptures;
  33150. private _timeAccumulator;
  33151. private _currentStepId;
  33152. private _currentInternalStep;
  33153. /** @hidden */
  33154. _mirroredCameraPosition: Nullable<Vector3>;
  33155. /**
  33156. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33157. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33158. */
  33159. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33160. /**
  33161. * Observable event triggered each time an keyboard event is received from the hosting window
  33162. */
  33163. onKeyboardObservable: Observable<KeyboardInfo>;
  33164. private _onKeyDown;
  33165. private _onKeyUp;
  33166. private _onCanvasFocusObserver;
  33167. private _onCanvasBlurObserver;
  33168. private _useRightHandedSystem;
  33169. /**
  33170. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33171. */
  33172. useRightHandedSystem: boolean;
  33173. /**
  33174. * Sets the step Id used by deterministic lock step
  33175. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33176. * @param newStepId defines the step Id
  33177. */
  33178. setStepId(newStepId: number): void;
  33179. /**
  33180. * Gets the step Id used by deterministic lock step
  33181. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33182. * @returns the step Id
  33183. */
  33184. getStepId(): number;
  33185. /**
  33186. * Gets the internal step used by deterministic lock step
  33187. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33188. * @returns the internal step
  33189. */
  33190. getInternalStep(): number;
  33191. private _fogEnabled;
  33192. /**
  33193. * Gets or sets a boolean indicating if fog is enabled on this scene
  33194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33195. * (Default is true)
  33196. */
  33197. fogEnabled: boolean;
  33198. private _fogMode;
  33199. /**
  33200. * Gets or sets the fog mode to use
  33201. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33202. * | mode | value |
  33203. * | --- | --- |
  33204. * | FOGMODE_NONE | 0 |
  33205. * | FOGMODE_EXP | 1 |
  33206. * | FOGMODE_EXP2 | 2 |
  33207. * | FOGMODE_LINEAR | 3 |
  33208. */
  33209. fogMode: number;
  33210. /**
  33211. * Gets or sets the fog color to use
  33212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33213. * (Default is Color3(0.2, 0.2, 0.3))
  33214. */
  33215. fogColor: Color3;
  33216. /**
  33217. * Gets or sets the fog density to use
  33218. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33219. * (Default is 0.1)
  33220. */
  33221. fogDensity: number;
  33222. /**
  33223. * Gets or sets the fog start distance to use
  33224. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33225. * (Default is 0)
  33226. */
  33227. fogStart: number;
  33228. /**
  33229. * Gets or sets the fog end distance to use
  33230. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33231. * (Default is 1000)
  33232. */
  33233. fogEnd: number;
  33234. private _shadowsEnabled;
  33235. /**
  33236. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33237. */
  33238. shadowsEnabled: boolean;
  33239. private _lightsEnabled;
  33240. /**
  33241. * Gets or sets a boolean indicating if lights are enabled on this scene
  33242. */
  33243. lightsEnabled: boolean;
  33244. /** All of the active cameras added to this scene. */
  33245. activeCameras: Camera[];
  33246. private _activeCamera;
  33247. /** Gets or sets the current active camera */
  33248. activeCamera: Nullable<Camera>;
  33249. private _defaultMaterial;
  33250. /** The default material used on meshes when no material is affected */
  33251. /** The default material used on meshes when no material is affected */
  33252. defaultMaterial: Material;
  33253. private _texturesEnabled;
  33254. /**
  33255. * Gets or sets a boolean indicating if textures are enabled on this scene
  33256. */
  33257. texturesEnabled: boolean;
  33258. /**
  33259. * Gets or sets a boolean indicating if particles are enabled on this scene
  33260. */
  33261. particlesEnabled: boolean;
  33262. /**
  33263. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33264. */
  33265. spritesEnabled: boolean;
  33266. private _skeletonsEnabled;
  33267. /**
  33268. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33269. */
  33270. skeletonsEnabled: boolean;
  33271. /**
  33272. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33273. */
  33274. lensFlaresEnabled: boolean;
  33275. /**
  33276. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33277. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33278. */
  33279. collisionsEnabled: boolean;
  33280. /** @hidden */
  33281. collisionCoordinator: ICollisionCoordinator;
  33282. /**
  33283. * Defines the gravity applied to this scene (used only for collisions)
  33284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33285. */
  33286. gravity: Vector3;
  33287. /**
  33288. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33289. */
  33290. postProcessesEnabled: boolean;
  33291. /**
  33292. * The list of postprocesses added to the scene
  33293. */
  33294. postProcesses: PostProcess[];
  33295. /**
  33296. * Gets the current postprocess manager
  33297. */
  33298. postProcessManager: PostProcessManager;
  33299. /**
  33300. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33301. */
  33302. renderTargetsEnabled: boolean;
  33303. /**
  33304. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33305. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33306. */
  33307. dumpNextRenderTargets: boolean;
  33308. /**
  33309. * The list of user defined render targets added to the scene
  33310. */
  33311. customRenderTargets: RenderTargetTexture[];
  33312. /**
  33313. * Defines if texture loading must be delayed
  33314. * If true, textures will only be loaded when they need to be rendered
  33315. */
  33316. useDelayedTextureLoading: boolean;
  33317. /**
  33318. * Gets the list of meshes imported to the scene through SceneLoader
  33319. */
  33320. importedMeshesFiles: String[];
  33321. /**
  33322. * Gets or sets a boolean indicating if probes are enabled on this scene
  33323. */
  33324. probesEnabled: boolean;
  33325. /**
  33326. * Gets or sets the current offline provider to use to store scene data
  33327. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33328. */
  33329. offlineProvider: IOfflineProvider;
  33330. /**
  33331. * Gets or sets the action manager associated with the scene
  33332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33333. */
  33334. actionManager: ActionManager;
  33335. private _meshesForIntersections;
  33336. /**
  33337. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33338. */
  33339. proceduralTexturesEnabled: boolean;
  33340. private _engine;
  33341. private _totalVertices;
  33342. /** @hidden */
  33343. _activeIndices: PerfCounter;
  33344. /** @hidden */
  33345. _activeParticles: PerfCounter;
  33346. /** @hidden */
  33347. _activeBones: PerfCounter;
  33348. private _animationRatio;
  33349. private _animationTimeLast;
  33350. private _animationTime;
  33351. /**
  33352. * Gets or sets a general scale for animation speed
  33353. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33354. */
  33355. animationTimeScale: number;
  33356. /** @hidden */
  33357. _cachedMaterial: Nullable<Material>;
  33358. /** @hidden */
  33359. _cachedEffect: Nullable<Effect>;
  33360. /** @hidden */
  33361. _cachedVisibility: Nullable<number>;
  33362. private _renderId;
  33363. private _frameId;
  33364. private _executeWhenReadyTimeoutId;
  33365. private _intermediateRendering;
  33366. private _viewUpdateFlag;
  33367. private _projectionUpdateFlag;
  33368. private _alternateViewUpdateFlag;
  33369. private _alternateProjectionUpdateFlag;
  33370. /** @hidden */
  33371. _toBeDisposed: Nullable<IDisposable>[];
  33372. private _activeRequests;
  33373. private _pendingData;
  33374. private _isDisposed;
  33375. /**
  33376. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33377. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33378. */
  33379. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33380. private _activeMeshes;
  33381. private _processedMaterials;
  33382. private _renderTargets;
  33383. /** @hidden */
  33384. _activeParticleSystems: SmartArray<IParticleSystem>;
  33385. private _activeSkeletons;
  33386. private _softwareSkinnedMeshes;
  33387. private _renderingManager;
  33388. /** @hidden */
  33389. _activeAnimatables: Animatable[];
  33390. private _transformMatrix;
  33391. private _sceneUbo;
  33392. private _alternateSceneUbo;
  33393. private _pickWithRayInverseMatrix;
  33394. private _viewMatrix;
  33395. private _projectionMatrix;
  33396. private _alternateViewMatrix;
  33397. private _alternateProjectionMatrix;
  33398. private _alternateTransformMatrix;
  33399. private _useAlternateCameraConfiguration;
  33400. private _alternateRendering;
  33401. private _wheelEventName;
  33402. /** @hidden */
  33403. _forcedViewPosition: Nullable<Vector3>;
  33404. /** @hidden */
  33405. readonly _isAlternateRenderingEnabled: boolean;
  33406. private _frustumPlanes;
  33407. /**
  33408. * Gets the list of frustum planes (built from the active camera)
  33409. */
  33410. readonly frustumPlanes: Plane[];
  33411. /**
  33412. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33413. * This is useful if there are more lights that the maximum simulteanous authorized
  33414. */
  33415. requireLightSorting: boolean;
  33416. /** @hidden */
  33417. readonly useMaterialMeshMap: boolean;
  33418. /** @hidden */
  33419. readonly useClonedMeshhMap: boolean;
  33420. private _pointerOverMesh;
  33421. private _pickedDownMesh;
  33422. private _pickedUpMesh;
  33423. private _externalData;
  33424. private _uid;
  33425. /**
  33426. * @hidden
  33427. * Backing store of defined scene components.
  33428. */
  33429. _components: ISceneComponent[];
  33430. /**
  33431. * @hidden
  33432. * Backing store of defined scene components.
  33433. */
  33434. _serializableComponents: ISceneSerializableComponent[];
  33435. /**
  33436. * List of components to register on the next registration step.
  33437. */
  33438. private _transientComponents;
  33439. /**
  33440. * Registers the transient components if needed.
  33441. */
  33442. private _registerTransientComponents;
  33443. /**
  33444. * @hidden
  33445. * Add a component to the scene.
  33446. * Note that the ccomponent could be registered on th next frame if this is called after
  33447. * the register component stage.
  33448. * @param component Defines the component to add to the scene
  33449. */
  33450. _addComponent(component: ISceneComponent): void;
  33451. /**
  33452. * @hidden
  33453. * Gets a component from the scene.
  33454. * @param name defines the name of the component to retrieve
  33455. * @returns the component or null if not present
  33456. */
  33457. _getComponent(name: string): Nullable<ISceneComponent>;
  33458. /**
  33459. * @hidden
  33460. * Defines the actions happening before camera updates.
  33461. */
  33462. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33463. /**
  33464. * @hidden
  33465. * Defines the actions happening before clear the canvas.
  33466. */
  33467. _beforeClearStage: Stage<SimpleStageAction>;
  33468. /**
  33469. * @hidden
  33470. * Defines the actions when collecting render targets for the frame.
  33471. */
  33472. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33473. /**
  33474. * @hidden
  33475. * Defines the actions happening for one camera in the frame.
  33476. */
  33477. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33478. /**
  33479. * @hidden
  33480. * Defines the actions happening during the per mesh ready checks.
  33481. */
  33482. _isReadyForMeshStage: Stage<MeshStageAction>;
  33483. /**
  33484. * @hidden
  33485. * Defines the actions happening before evaluate active mesh checks.
  33486. */
  33487. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33488. /**
  33489. * @hidden
  33490. * Defines the actions happening during the evaluate sub mesh checks.
  33491. */
  33492. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33493. /**
  33494. * @hidden
  33495. * Defines the actions happening during the active mesh stage.
  33496. */
  33497. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33498. /**
  33499. * @hidden
  33500. * Defines the actions happening during the per camera render target step.
  33501. */
  33502. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33503. /**
  33504. * @hidden
  33505. * Defines the actions happening just before the active camera is drawing.
  33506. */
  33507. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33508. /**
  33509. * @hidden
  33510. * Defines the actions happening just before a render target is drawing.
  33511. */
  33512. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33513. /**
  33514. * @hidden
  33515. * Defines the actions happening just before a rendering group is drawing.
  33516. */
  33517. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33518. /**
  33519. * @hidden
  33520. * Defines the actions happening just before a mesh is drawing.
  33521. */
  33522. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33523. /**
  33524. * @hidden
  33525. * Defines the actions happening just after a mesh has been drawn.
  33526. */
  33527. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33528. /**
  33529. * @hidden
  33530. * Defines the actions happening just after a rendering group has been drawn.
  33531. */
  33532. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33533. /**
  33534. * @hidden
  33535. * Defines the actions happening just after the active camera has been drawn.
  33536. */
  33537. _afterCameraDrawStage: Stage<CameraStageAction>;
  33538. /**
  33539. * @hidden
  33540. * Defines the actions happening just after a render target has been drawn.
  33541. */
  33542. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33543. /**
  33544. * @hidden
  33545. * Defines the actions happening just after rendering all cameras and computing intersections.
  33546. */
  33547. _afterRenderStage: Stage<SimpleStageAction>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening when a pointer move event happens.
  33551. */
  33552. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening when a pointer down event happens.
  33556. */
  33557. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33558. /**
  33559. * @hidden
  33560. * Defines the actions happening when a pointer up event happens.
  33561. */
  33562. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33563. /**
  33564. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33565. */
  33566. private geometriesByUniqueId;
  33567. /**
  33568. * Creates a new Scene
  33569. * @param engine defines the engine to use to render this scene
  33570. */
  33571. constructor(engine: Engine, options?: SceneOptions);
  33572. private _defaultMeshCandidates;
  33573. /**
  33574. * @hidden
  33575. */
  33576. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33577. private _defaultSubMeshCandidates;
  33578. /**
  33579. * @hidden
  33580. */
  33581. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33582. /**
  33583. * Sets the default candidate providers for the scene.
  33584. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33585. * and getCollidingSubMeshCandidates to their default function
  33586. */
  33587. setDefaultCandidateProviders(): void;
  33588. /**
  33589. * Gets a boolean indicating if collisions are processed on a web worker
  33590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  33591. */
  33592. workerCollisions: boolean;
  33593. /**
  33594. * Gets the mesh that is currently under the pointer
  33595. */
  33596. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33597. /**
  33598. * Gets or sets the current on-screen X position of the pointer
  33599. */
  33600. pointerX: number;
  33601. /**
  33602. * Gets or sets the current on-screen Y position of the pointer
  33603. */
  33604. pointerY: number;
  33605. /**
  33606. * Gets the cached material (ie. the latest rendered one)
  33607. * @returns the cached material
  33608. */
  33609. getCachedMaterial(): Nullable<Material>;
  33610. /**
  33611. * Gets the cached effect (ie. the latest rendered one)
  33612. * @returns the cached effect
  33613. */
  33614. getCachedEffect(): Nullable<Effect>;
  33615. /**
  33616. * Gets the cached visibility state (ie. the latest rendered one)
  33617. * @returns the cached visibility state
  33618. */
  33619. getCachedVisibility(): Nullable<number>;
  33620. /**
  33621. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33622. * @param material defines the current material
  33623. * @param effect defines the current effect
  33624. * @param visibility defines the current visibility state
  33625. * @returns true if one parameter is not cached
  33626. */
  33627. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33628. /**
  33629. * Gets the engine associated with the scene
  33630. * @returns an Engine
  33631. */
  33632. getEngine(): Engine;
  33633. /**
  33634. * Gets the total number of vertices rendered per frame
  33635. * @returns the total number of vertices rendered per frame
  33636. */
  33637. getTotalVertices(): number;
  33638. /**
  33639. * Gets the performance counter for total vertices
  33640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33641. */
  33642. readonly totalVerticesPerfCounter: PerfCounter;
  33643. /**
  33644. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33645. * @returns the total number of active indices rendered per frame
  33646. */
  33647. getActiveIndices(): number;
  33648. /**
  33649. * Gets the performance counter for active indices
  33650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33651. */
  33652. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33653. /**
  33654. * Gets the total number of active particles rendered per frame
  33655. * @returns the total number of active particles rendered per frame
  33656. */
  33657. getActiveParticles(): number;
  33658. /**
  33659. * Gets the performance counter for active particles
  33660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33661. */
  33662. readonly activeParticlesPerfCounter: PerfCounter;
  33663. /**
  33664. * Gets the total number of active bones rendered per frame
  33665. * @returns the total number of active bones rendered per frame
  33666. */
  33667. getActiveBones(): number;
  33668. /**
  33669. * Gets the performance counter for active bones
  33670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33671. */
  33672. readonly activeBonesPerfCounter: PerfCounter;
  33673. /**
  33674. * Gets the array of active meshes
  33675. * @returns an array of AbstractMesh
  33676. */
  33677. getActiveMeshes(): SmartArray<AbstractMesh>;
  33678. /**
  33679. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33680. * @returns a number
  33681. */
  33682. getAnimationRatio(): number;
  33683. /**
  33684. * Gets an unique Id for the current render phase
  33685. * @returns a number
  33686. */
  33687. getRenderId(): number;
  33688. /**
  33689. * Gets an unique Id for the current frame
  33690. * @returns a number
  33691. */
  33692. getFrameId(): number;
  33693. /** Call this function if you want to manually increment the render Id*/
  33694. incrementRenderId(): void;
  33695. private _updatePointerPosition;
  33696. private _createUbo;
  33697. private _createAlternateUbo;
  33698. private _setRayOnPointerInfo;
  33699. /**
  33700. * Use this method to simulate a pointer move on a mesh
  33701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33704. * @returns the current scene
  33705. */
  33706. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33707. private _processPointerMove;
  33708. private _checkPrePointerObservable;
  33709. /**
  33710. * Use this method to simulate a pointer down on a mesh
  33711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33714. * @returns the current scene
  33715. */
  33716. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33717. private _processPointerDown;
  33718. /**
  33719. * Use this method to simulate a pointer up on a mesh
  33720. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33721. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33722. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33723. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33724. * @returns the current scene
  33725. */
  33726. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33727. private _processPointerUp;
  33728. /**
  33729. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33730. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33731. * @returns true if the pointer was captured
  33732. */
  33733. isPointerCaptured(pointerId?: number): boolean;
  33734. /** @hidden */
  33735. _isPointerSwiping(): boolean;
  33736. /**
  33737. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33738. * @param attachUp defines if you want to attach events to pointerup
  33739. * @param attachDown defines if you want to attach events to pointerdown
  33740. * @param attachMove defines if you want to attach events to pointermove
  33741. */
  33742. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33743. /** Detaches all event handlers*/
  33744. detachControl(): void;
  33745. /**
  33746. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33747. * Delay loaded resources are not taking in account
  33748. * @return true if all required resources are ready
  33749. */
  33750. isReady(): boolean;
  33751. /** Resets all cached information relative to material (including effect and visibility) */
  33752. resetCachedMaterial(): void;
  33753. /**
  33754. * Registers a function to be called before every frame render
  33755. * @param func defines the function to register
  33756. */
  33757. registerBeforeRender(func: () => void): void;
  33758. /**
  33759. * Unregisters a function called before every frame render
  33760. * @param func defines the function to unregister
  33761. */
  33762. unregisterBeforeRender(func: () => void): void;
  33763. /**
  33764. * Registers a function to be called after every frame render
  33765. * @param func defines the function to register
  33766. */
  33767. registerAfterRender(func: () => void): void;
  33768. /**
  33769. * Unregisters a function called after every frame render
  33770. * @param func defines the function to unregister
  33771. */
  33772. unregisterAfterRender(func: () => void): void;
  33773. private _executeOnceBeforeRender;
  33774. /**
  33775. * The provided function will run before render once and will be disposed afterwards.
  33776. * A timeout delay can be provided so that the function will be executed in N ms.
  33777. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33778. * @param func The function to be executed.
  33779. * @param timeout optional delay in ms
  33780. */
  33781. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33782. /** @hidden */
  33783. _addPendingData(data: any): void;
  33784. /** @hidden */
  33785. _removePendingData(data: any): void;
  33786. /**
  33787. * Returns the number of items waiting to be loaded
  33788. * @returns the number of items waiting to be loaded
  33789. */
  33790. getWaitingItemsCount(): number;
  33791. /**
  33792. * Returns a boolean indicating if the scene is still loading data
  33793. */
  33794. readonly isLoading: boolean;
  33795. /**
  33796. * Registers a function to be executed when the scene is ready
  33797. * @param {Function} func - the function to be executed
  33798. */
  33799. executeWhenReady(func: () => void): void;
  33800. /**
  33801. * Returns a promise that resolves when the scene is ready
  33802. * @returns A promise that resolves when the scene is ready
  33803. */
  33804. whenReadyAsync(): Promise<void>;
  33805. /** @hidden */
  33806. _checkIsReady(): void;
  33807. /**
  33808. * Will start the animation sequence of a given target
  33809. * @param target defines the target
  33810. * @param from defines from which frame should animation start
  33811. * @param to defines until which frame should animation run.
  33812. * @param weight defines the weight to apply to the animation (1.0 by default)
  33813. * @param loop defines if the animation loops
  33814. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33815. * @param onAnimationEnd defines the function to be executed when the animation ends
  33816. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33817. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33818. * @param onAnimationLoop defines the callback to call when an animation loops
  33819. * @returns the animatable object created for this animation
  33820. */
  33821. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33822. /**
  33823. * Will start the animation sequence of a given target
  33824. * @param target defines the target
  33825. * @param from defines from which frame should animation start
  33826. * @param to defines until which frame should animation run.
  33827. * @param loop defines if the animation loops
  33828. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33829. * @param onAnimationEnd defines the function to be executed when the animation ends
  33830. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33831. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33832. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  33833. * @param onAnimationLoop defines the callback to call when an animation loops
  33834. * @returns the animatable object created for this animation
  33835. */
  33836. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33837. /**
  33838. * Will start the animation sequence of a given target and its hierarchy
  33839. * @param target defines the target
  33840. * @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.
  33841. * @param from defines from which frame should animation start
  33842. * @param to defines until which frame should animation run.
  33843. * @param loop defines if the animation loops
  33844. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33845. * @param onAnimationEnd defines the function to be executed when the animation ends
  33846. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33847. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33848. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33849. * @param onAnimationLoop defines the callback to call when an animation loops
  33850. * @returns the list of created animatables
  33851. */
  33852. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  33853. /**
  33854. * Begin a new animation on a given node
  33855. * @param target defines the target where the animation will take place
  33856. * @param animations defines the list of animations to start
  33857. * @param from defines the initial value
  33858. * @param to defines the final value
  33859. * @param loop defines if you want animation to loop (off by default)
  33860. * @param speedRatio defines the speed ratio to apply to all animations
  33861. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33862. * @param onAnimationLoop defines the callback to call when an animation loops
  33863. * @returns the list of created animatables
  33864. */
  33865. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  33866. /**
  33867. * Begin a new animation on a given node and its hierarchy
  33868. * @param target defines the root node where the animation will take place
  33869. * @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.
  33870. * @param animations defines the list of animations to start
  33871. * @param from defines the initial value
  33872. * @param to defines the final value
  33873. * @param loop defines if you want animation to loop (off by default)
  33874. * @param speedRatio defines the speed ratio to apply to all animations
  33875. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33876. * @param onAnimationLoop defines the callback to call when an animation loops
  33877. * @returns the list of animatables created for all nodes
  33878. */
  33879. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  33880. /**
  33881. * Gets the animatable associated with a specific target
  33882. * @param target defines the target of the animatable
  33883. * @returns the required animatable if found
  33884. */
  33885. getAnimatableByTarget(target: any): Nullable<Animatable>;
  33886. /**
  33887. * Gets all animatables associated with a given target
  33888. * @param target defines the target to look animatables for
  33889. * @returns an array of Animatables
  33890. */
  33891. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  33892. /**
  33893. * Gets all animatable attached to the scene
  33894. */
  33895. readonly animatables: Animatable[];
  33896. /**
  33897. * Will stop the animation of the given target
  33898. * @param target - the target
  33899. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33900. * @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)
  33901. */
  33902. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33903. /**
  33904. * Stops and removes all animations that have been applied to the scene
  33905. */
  33906. stopAllAnimations(): void;
  33907. /**
  33908. * Resets the last animation time frame.
  33909. * Useful to override when animations start running when loading a scene for the first time.
  33910. */
  33911. resetLastAnimationTimeFrame(): void;
  33912. private _animate;
  33913. /** @hidden */
  33914. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  33915. private _processLateAnimationBindingsForMatrices;
  33916. private _processLateAnimationBindingsForQuaternions;
  33917. private _processLateAnimationBindings;
  33918. /** @hidden */
  33919. _switchToAlternateCameraConfiguration(active: boolean): void;
  33920. /**
  33921. * Gets the current view matrix
  33922. * @returns a Matrix
  33923. */
  33924. getViewMatrix(): Matrix;
  33925. /**
  33926. * Gets the current projection matrix
  33927. * @returns a Matrix
  33928. */
  33929. getProjectionMatrix(): Matrix;
  33930. /**
  33931. * Gets the current transform matrix
  33932. * @returns a Matrix made of View * Projection
  33933. */
  33934. getTransformMatrix(): Matrix;
  33935. /**
  33936. * Sets the current transform matrix
  33937. * @param view defines the View matrix to use
  33938. * @param projection defines the Projection matrix to use
  33939. */
  33940. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33941. /** @hidden */
  33942. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33943. /**
  33944. * Gets the uniform buffer used to store scene data
  33945. * @returns a UniformBuffer
  33946. */
  33947. getSceneUniformBuffer(): UniformBuffer;
  33948. /**
  33949. * Gets an unique (relatively to the current scene) Id
  33950. * @returns an unique number for the scene
  33951. */
  33952. getUniqueId(): number;
  33953. /**
  33954. * Add a mesh to the list of scene's meshes
  33955. * @param newMesh defines the mesh to add
  33956. * @param recursive if all child meshes should also be added to the scene
  33957. */
  33958. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33959. /**
  33960. * Remove a mesh for the list of scene's meshes
  33961. * @param toRemove defines the mesh to remove
  33962. * @param recursive if all child meshes should also be removed from the scene
  33963. * @returns the index where the mesh was in the mesh list
  33964. */
  33965. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33966. /**
  33967. * Add a transform node to the list of scene's transform nodes
  33968. * @param newTransformNode defines the transform node to add
  33969. */
  33970. addTransformNode(newTransformNode: TransformNode): void;
  33971. /**
  33972. * Remove a transform node for the list of scene's transform nodes
  33973. * @param toRemove defines the transform node to remove
  33974. * @returns the index where the transform node was in the transform node list
  33975. */
  33976. removeTransformNode(toRemove: TransformNode): number;
  33977. /**
  33978. * Remove a skeleton for the list of scene's skeletons
  33979. * @param toRemove defines the skeleton to remove
  33980. * @returns the index where the skeleton was in the skeleton list
  33981. */
  33982. removeSkeleton(toRemove: Skeleton): number;
  33983. /**
  33984. * Remove a morph target for the list of scene's morph targets
  33985. * @param toRemove defines the morph target to remove
  33986. * @returns the index where the morph target was in the morph target list
  33987. */
  33988. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33989. /**
  33990. * Remove a light for the list of scene's lights
  33991. * @param toRemove defines the light to remove
  33992. * @returns the index where the light was in the light list
  33993. */
  33994. removeLight(toRemove: Light): number;
  33995. /**
  33996. * Remove a camera for the list of scene's cameras
  33997. * @param toRemove defines the camera to remove
  33998. * @returns the index where the camera was in the camera list
  33999. */
  34000. removeCamera(toRemove: Camera): number;
  34001. /**
  34002. * Remove a particle system for the list of scene's particle systems
  34003. * @param toRemove defines the particle system to remove
  34004. * @returns the index where the particle system was in the particle system list
  34005. */
  34006. removeParticleSystem(toRemove: IParticleSystem): number;
  34007. /**
  34008. * Remove a animation for the list of scene's animations
  34009. * @param toRemove defines the animation to remove
  34010. * @returns the index where the animation was in the animation list
  34011. */
  34012. removeAnimation(toRemove: Animation): number;
  34013. /**
  34014. * Removes the given animation group from this scene.
  34015. * @param toRemove The animation group to remove
  34016. * @returns The index of the removed animation group
  34017. */
  34018. removeAnimationGroup(toRemove: AnimationGroup): number;
  34019. /**
  34020. * Removes the given multi-material from this scene.
  34021. * @param toRemove The multi-material to remove
  34022. * @returns The index of the removed multi-material
  34023. */
  34024. removeMultiMaterial(toRemove: MultiMaterial): number;
  34025. /**
  34026. * Removes the given material from this scene.
  34027. * @param toRemove The material to remove
  34028. * @returns The index of the removed material
  34029. */
  34030. removeMaterial(toRemove: Material): number;
  34031. /**
  34032. * Removes the given action manager from this scene.
  34033. * @param toRemove The action manager to remove
  34034. * @returns The index of the removed action manager
  34035. */
  34036. removeActionManager(toRemove: ActionManager): number;
  34037. /**
  34038. * Removes the given texture from this scene.
  34039. * @param toRemove The texture to remove
  34040. * @returns The index of the removed texture
  34041. */
  34042. removeTexture(toRemove: BaseTexture): number;
  34043. /**
  34044. * Adds the given light to this scene
  34045. * @param newLight The light to add
  34046. */
  34047. addLight(newLight: Light): void;
  34048. /**
  34049. * Sorts the list list based on light priorities
  34050. */
  34051. sortLightsByPriority(): void;
  34052. /**
  34053. * Adds the given camera to this scene
  34054. * @param newCamera The camera to add
  34055. */
  34056. addCamera(newCamera: Camera): void;
  34057. /**
  34058. * Adds the given skeleton to this scene
  34059. * @param newSkeleton The skeleton to add
  34060. */
  34061. addSkeleton(newSkeleton: Skeleton): void;
  34062. /**
  34063. * Adds the given particle system to this scene
  34064. * @param newParticleSystem The particle system to add
  34065. */
  34066. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34067. /**
  34068. * Adds the given animation to this scene
  34069. * @param newAnimation The animation to add
  34070. */
  34071. addAnimation(newAnimation: Animation): void;
  34072. /**
  34073. * Adds the given animation group to this scene.
  34074. * @param newAnimationGroup The animation group to add
  34075. */
  34076. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34077. /**
  34078. * Adds the given multi-material to this scene
  34079. * @param newMultiMaterial The multi-material to add
  34080. */
  34081. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34082. /**
  34083. * Adds the given material to this scene
  34084. * @param newMaterial The material to add
  34085. */
  34086. addMaterial(newMaterial: Material): void;
  34087. /**
  34088. * Adds the given morph target to this scene
  34089. * @param newMorphTargetManager The morph target to add
  34090. */
  34091. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34092. /**
  34093. * Adds the given geometry to this scene
  34094. * @param newGeometry The geometry to add
  34095. */
  34096. addGeometry(newGeometry: Geometry): void;
  34097. /**
  34098. * Adds the given action manager to this scene
  34099. * @param newActionManager The action manager to add
  34100. */
  34101. addActionManager(newActionManager: ActionManager): void;
  34102. /**
  34103. * Adds the given texture to this scene.
  34104. * @param newTexture The texture to add
  34105. */
  34106. addTexture(newTexture: BaseTexture): void;
  34107. /**
  34108. * Switch active camera
  34109. * @param newCamera defines the new active camera
  34110. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34111. */
  34112. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34113. /**
  34114. * sets the active camera of the scene using its ID
  34115. * @param id defines the camera's ID
  34116. * @return the new active camera or null if none found.
  34117. */
  34118. setActiveCameraByID(id: string): Nullable<Camera>;
  34119. /**
  34120. * sets the active camera of the scene using its name
  34121. * @param name defines the camera's name
  34122. * @returns the new active camera or null if none found.
  34123. */
  34124. setActiveCameraByName(name: string): Nullable<Camera>;
  34125. /**
  34126. * get an animation group using its name
  34127. * @param name defines the material's name
  34128. * @return the animation group or null if none found.
  34129. */
  34130. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34131. /**
  34132. * get a material using its id
  34133. * @param id defines the material's ID
  34134. * @return the material or null if none found.
  34135. */
  34136. getMaterialByID(id: string): Nullable<Material>;
  34137. /**
  34138. * Gets a material using its name
  34139. * @param name defines the material's name
  34140. * @return the material or null if none found.
  34141. */
  34142. getMaterialByName(name: string): Nullable<Material>;
  34143. /**
  34144. * Gets a camera using its id
  34145. * @param id defines the id to look for
  34146. * @returns the camera or null if not found
  34147. */
  34148. getCameraByID(id: string): Nullable<Camera>;
  34149. /**
  34150. * Gets a camera using its unique id
  34151. * @param uniqueId defines the unique id to look for
  34152. * @returns the camera or null if not found
  34153. */
  34154. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34155. /**
  34156. * Gets a camera using its name
  34157. * @param name defines the camera's name
  34158. * @return the camera or null if none found.
  34159. */
  34160. getCameraByName(name: string): Nullable<Camera>;
  34161. /**
  34162. * Gets a bone using its id
  34163. * @param id defines the bone's id
  34164. * @return the bone or null if not found
  34165. */
  34166. getBoneByID(id: string): Nullable<Bone>;
  34167. /**
  34168. * Gets a bone using its id
  34169. * @param name defines the bone's name
  34170. * @return the bone or null if not found
  34171. */
  34172. getBoneByName(name: string): Nullable<Bone>;
  34173. /**
  34174. * Gets a light node using its name
  34175. * @param name defines the the light's name
  34176. * @return the light or null if none found.
  34177. */
  34178. getLightByName(name: string): Nullable<Light>;
  34179. /**
  34180. * Gets a light node using its id
  34181. * @param id defines the light's id
  34182. * @return the light or null if none found.
  34183. */
  34184. getLightByID(id: string): Nullable<Light>;
  34185. /**
  34186. * Gets a light node using its scene-generated unique ID
  34187. * @param uniqueId defines the light's unique id
  34188. * @return the light or null if none found.
  34189. */
  34190. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34191. /**
  34192. * Gets a particle system by id
  34193. * @param id defines the particle system id
  34194. * @return the corresponding system or null if none found
  34195. */
  34196. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34197. /**
  34198. * Gets a geometry using its ID
  34199. * @param id defines the geometry's id
  34200. * @return the geometry or null if none found.
  34201. */
  34202. getGeometryByID(id: string): Nullable<Geometry>;
  34203. private _getGeometryByUniqueID;
  34204. /**
  34205. * Add a new geometry to this scene
  34206. * @param geometry defines the geometry to be added to the scene.
  34207. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34208. * @return a boolean defining if the geometry was added or not
  34209. */
  34210. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34211. /**
  34212. * Removes an existing geometry
  34213. * @param geometry defines the geometry to be removed from the scene
  34214. * @return a boolean defining if the geometry was removed or not
  34215. */
  34216. removeGeometry(geometry: Geometry): boolean;
  34217. /**
  34218. * Gets the list of geometries attached to the scene
  34219. * @returns an array of Geometry
  34220. */
  34221. getGeometries(): Geometry[];
  34222. /**
  34223. * Gets the first added mesh found of a given ID
  34224. * @param id defines the id to search for
  34225. * @return the mesh found or null if not found at all
  34226. */
  34227. getMeshByID(id: string): Nullable<AbstractMesh>;
  34228. /**
  34229. * Gets a list of meshes using their id
  34230. * @param id defines the id to search for
  34231. * @returns a list of meshes
  34232. */
  34233. getMeshesByID(id: string): Array<AbstractMesh>;
  34234. /**
  34235. * Gets the first added transform node found of a given ID
  34236. * @param id defines the id to search for
  34237. * @return the found transform node or null if not found at all.
  34238. */
  34239. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34240. /**
  34241. * Gets a list of transform nodes using their id
  34242. * @param id defines the id to search for
  34243. * @returns a list of transform nodes
  34244. */
  34245. getTransformNodesByID(id: string): Array<TransformNode>;
  34246. /**
  34247. * Gets a mesh with its auto-generated unique id
  34248. * @param uniqueId defines the unique id to search for
  34249. * @return the found mesh or null if not found at all.
  34250. */
  34251. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34252. /**
  34253. * Gets a the last added mesh using a given id
  34254. * @param id defines the id to search for
  34255. * @return the found mesh or null if not found at all.
  34256. */
  34257. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34258. /**
  34259. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34260. * @param id defines the id to search for
  34261. * @return the found node or null if not found at all
  34262. */
  34263. getLastEntryByID(id: string): Nullable<Node>;
  34264. /**
  34265. * Gets a node (Mesh, Camera, Light) using a given id
  34266. * @param id defines the id to search for
  34267. * @return the found node or null if not found at all
  34268. */
  34269. getNodeByID(id: string): Nullable<Node>;
  34270. /**
  34271. * Gets a node (Mesh, Camera, Light) using a given name
  34272. * @param name defines the name to search for
  34273. * @return the found node or null if not found at all.
  34274. */
  34275. getNodeByName(name: string): Nullable<Node>;
  34276. /**
  34277. * Gets a mesh using a given name
  34278. * @param name defines the name to search for
  34279. * @return the found mesh or null if not found at all.
  34280. */
  34281. getMeshByName(name: string): Nullable<AbstractMesh>;
  34282. /**
  34283. * Gets a transform node using a given name
  34284. * @param name defines the name to search for
  34285. * @return the found transform node or null if not found at all.
  34286. */
  34287. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34288. /**
  34289. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34290. * @param id defines the id to search for
  34291. * @return the found skeleton or null if not found at all.
  34292. */
  34293. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34294. /**
  34295. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34296. * @param id defines the id to search for
  34297. * @return the found skeleton or null if not found at all.
  34298. */
  34299. getSkeletonById(id: string): Nullable<Skeleton>;
  34300. /**
  34301. * Gets a skeleton using a given name
  34302. * @param name defines the name to search for
  34303. * @return the found skeleton or null if not found at all.
  34304. */
  34305. getSkeletonByName(name: string): Nullable<Skeleton>;
  34306. /**
  34307. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34308. * @param id defines the id to search for
  34309. * @return the found morph target manager or null if not found at all.
  34310. */
  34311. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34312. /**
  34313. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34314. * @param id defines the id to search for
  34315. * @return the found morph target or null if not found at all.
  34316. */
  34317. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34318. /**
  34319. * Gets a boolean indicating if the given mesh is active
  34320. * @param mesh defines the mesh to look for
  34321. * @returns true if the mesh is in the active list
  34322. */
  34323. isActiveMesh(mesh: AbstractMesh): boolean;
  34324. /**
  34325. * Return a unique id as a string which can serve as an identifier for the scene
  34326. */
  34327. readonly uid: string;
  34328. /**
  34329. * Add an externaly attached data from its key.
  34330. * This method call will fail and return false, if such key already exists.
  34331. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34332. * @param key the unique key that identifies the data
  34333. * @param data the data object to associate to the key for this Engine instance
  34334. * @return true if no such key were already present and the data was added successfully, false otherwise
  34335. */
  34336. addExternalData<T>(key: string, data: T): boolean;
  34337. /**
  34338. * Get an externaly attached data from its key
  34339. * @param key the unique key that identifies the data
  34340. * @return the associated data, if present (can be null), or undefined if not present
  34341. */
  34342. getExternalData<T>(key: string): Nullable<T>;
  34343. /**
  34344. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34345. * @param key the unique key that identifies the data
  34346. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34347. * @return the associated data, can be null if the factory returned null.
  34348. */
  34349. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34350. /**
  34351. * Remove an externaly attached data from the Engine instance
  34352. * @param key the unique key that identifies the data
  34353. * @return true if the data was successfully removed, false if it doesn't exist
  34354. */
  34355. removeExternalData(key: string): boolean;
  34356. private _evaluateSubMesh;
  34357. /**
  34358. * Clear the processed materials smart array preventing retention point in material dispose.
  34359. */
  34360. freeProcessedMaterials(): void;
  34361. private _preventFreeActiveMeshesAndRenderingGroups;
  34362. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34363. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34364. * when disposing several meshes in a row or a hierarchy of meshes.
  34365. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34366. */
  34367. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34368. /**
  34369. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34370. */
  34371. freeActiveMeshes(): void;
  34372. /**
  34373. * Clear the info related to rendering groups preventing retention points during dispose.
  34374. */
  34375. freeRenderingGroups(): void;
  34376. /** @hidden */
  34377. _isInIntermediateRendering(): boolean;
  34378. /**
  34379. * Lambda returning the list of potentially active meshes.
  34380. */
  34381. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34382. /**
  34383. * Lambda returning the list of potentially active sub meshes.
  34384. */
  34385. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34386. /**
  34387. * Lambda returning the list of potentially intersecting sub meshes.
  34388. */
  34389. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34390. /**
  34391. * Lambda returning the list of potentially colliding sub meshes.
  34392. */
  34393. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34394. private _activeMeshesFrozen;
  34395. /**
  34396. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34397. * @returns the current scene
  34398. */
  34399. freezeActiveMeshes(): Scene;
  34400. /**
  34401. * Use this function to restart evaluating active meshes on every frame
  34402. * @returns the current scene
  34403. */
  34404. unfreezeActiveMeshes(): Scene;
  34405. private _evaluateActiveMeshes;
  34406. private _activeMesh;
  34407. /**
  34408. * Update the transform matrix to update from the current active camera
  34409. * @param force defines a boolean used to force the update even if cache is up to date
  34410. */
  34411. updateTransformMatrix(force?: boolean): void;
  34412. /**
  34413. * 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)
  34414. * @param alternateCamera defines the camera to use
  34415. */
  34416. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  34417. /** @hidden */
  34418. _allowPostProcessClearColor: boolean;
  34419. private _renderForCamera;
  34420. private _processSubCameras;
  34421. private _checkIntersections;
  34422. /** @hidden */
  34423. _advancePhysicsEngineStep(step: number): void;
  34424. /**
  34425. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34426. */
  34427. getDeterministicFrameTime: () => number;
  34428. /**
  34429. * Render the scene
  34430. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34431. */
  34432. render(updateCameras?: boolean): void;
  34433. /**
  34434. * Freeze all materials
  34435. * A frozen material will not be updatable but should be faster to render
  34436. */
  34437. freezeMaterials(): void;
  34438. /**
  34439. * Unfreeze all materials
  34440. * A frozen material will not be updatable but should be faster to render
  34441. */
  34442. unfreezeMaterials(): void;
  34443. /**
  34444. * Releases all held ressources
  34445. */
  34446. dispose(): void;
  34447. /**
  34448. * Gets if the scene is already disposed
  34449. */
  34450. readonly isDisposed: boolean;
  34451. /**
  34452. * Call this function to reduce memory footprint of the scene.
  34453. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34454. */
  34455. clearCachedVertexData(): void;
  34456. /**
  34457. * This function will remove the local cached buffer data from texture.
  34458. * It will save memory but will prevent the texture from being rebuilt
  34459. */
  34460. cleanCachedTextureBuffer(): void;
  34461. /**
  34462. * Get the world extend vectors with an optional filter
  34463. *
  34464. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34465. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34466. */
  34467. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34468. min: Vector3;
  34469. max: Vector3;
  34470. };
  34471. /**
  34472. * Creates a ray that can be used to pick in the scene
  34473. * @param x defines the x coordinate of the origin (on-screen)
  34474. * @param y defines the y coordinate of the origin (on-screen)
  34475. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34476. * @param camera defines the camera to use for the picking
  34477. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34478. * @returns a Ray
  34479. */
  34480. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34481. /**
  34482. * Creates a ray that can be used to pick in the scene
  34483. * @param x defines the x coordinate of the origin (on-screen)
  34484. * @param y defines the y coordinate of the origin (on-screen)
  34485. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34486. * @param result defines the ray where to store the picking ray
  34487. * @param camera defines the camera to use for the picking
  34488. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34489. * @returns the current scene
  34490. */
  34491. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34492. /**
  34493. * Creates a ray that can be used to pick in the scene
  34494. * @param x defines the x coordinate of the origin (on-screen)
  34495. * @param y defines the y coordinate of the origin (on-screen)
  34496. * @param camera defines the camera to use for the picking
  34497. * @returns a Ray
  34498. */
  34499. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34500. /**
  34501. * Creates a ray that can be used to pick in the scene
  34502. * @param x defines the x coordinate of the origin (on-screen)
  34503. * @param y defines the y coordinate of the origin (on-screen)
  34504. * @param result defines the ray where to store the picking ray
  34505. * @param camera defines the camera to use for the picking
  34506. * @returns the current scene
  34507. */
  34508. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34509. private _internalPick;
  34510. private _internalMultiPick;
  34511. private _tempPickingRay;
  34512. /** Launch a ray to try to pick a mesh in the scene
  34513. * @param x position on screen
  34514. * @param y position on screen
  34515. * @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
  34516. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34517. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34518. * @returns a PickingInfo
  34519. */
  34520. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  34521. private _cachedRayForTransform;
  34522. /** Use the given ray to pick a mesh in the scene
  34523. * @param ray The ray to use to pick meshes
  34524. * @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
  34525. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34526. * @returns a PickingInfo
  34527. */
  34528. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34529. /**
  34530. * Launch a ray to try to pick a mesh in the scene
  34531. * @param x X position on screen
  34532. * @param y Y position on screen
  34533. * @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
  34534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34535. * @returns an array of PickingInfo
  34536. */
  34537. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  34538. /**
  34539. * Launch a ray to try to pick a mesh in the scene
  34540. * @param ray Ray to use
  34541. * @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
  34542. * @returns an array of PickingInfo
  34543. */
  34544. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  34545. /**
  34546. * Force the value of meshUnderPointer
  34547. * @param mesh defines the mesh to use
  34548. */
  34549. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34550. /**
  34551. * Gets the mesh under the pointer
  34552. * @returns a Mesh or null if no mesh is under the pointer
  34553. */
  34554. getPointerOverMesh(): Nullable<AbstractMesh>;
  34555. /** @hidden */
  34556. _rebuildGeometries(): void;
  34557. /** @hidden */
  34558. _rebuildTextures(): void;
  34559. private _getByTags;
  34560. /**
  34561. * Get a list of meshes by tags
  34562. * @param tagsQuery defines the tags query to use
  34563. * @param forEach defines a predicate used to filter results
  34564. * @returns an array of Mesh
  34565. */
  34566. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34567. /**
  34568. * Get a list of cameras by tags
  34569. * @param tagsQuery defines the tags query to use
  34570. * @param forEach defines a predicate used to filter results
  34571. * @returns an array of Camera
  34572. */
  34573. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34574. /**
  34575. * Get a list of lights by tags
  34576. * @param tagsQuery defines the tags query to use
  34577. * @param forEach defines a predicate used to filter results
  34578. * @returns an array of Light
  34579. */
  34580. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34581. /**
  34582. * Get a list of materials by tags
  34583. * @param tagsQuery defines the tags query to use
  34584. * @param forEach defines a predicate used to filter results
  34585. * @returns an array of Material
  34586. */
  34587. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34588. /**
  34589. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34590. * This allowed control for front to back rendering or reversly depending of the special needs.
  34591. *
  34592. * @param renderingGroupId The rendering group id corresponding to its index
  34593. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34594. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34595. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34596. */
  34597. 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;
  34598. /**
  34599. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34600. *
  34601. * @param renderingGroupId The rendering group id corresponding to its index
  34602. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34603. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34604. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34605. */
  34606. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34607. /**
  34608. * Gets the current auto clear configuration for one rendering group of the rendering
  34609. * manager.
  34610. * @param index the rendering group index to get the information for
  34611. * @returns The auto clear setup for the requested rendering group
  34612. */
  34613. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34614. private _blockMaterialDirtyMechanism;
  34615. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34616. blockMaterialDirtyMechanism: boolean;
  34617. /**
  34618. * Will flag all materials as dirty to trigger new shader compilation
  34619. * @param flag defines the flag used to specify which material part must be marked as dirty
  34620. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34621. */
  34622. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34623. /** @hidden */
  34624. _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;
  34625. /** @hidden */
  34626. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34627. }
  34628. }
  34629. declare module "babylonjs/assetContainer" {
  34630. import { AbstractScene } from "babylonjs/abstractScene";
  34631. import { Scene } from "babylonjs/scene";
  34632. import { Mesh } from "babylonjs/Meshes/mesh";
  34633. /**
  34634. * Set of assets to keep when moving a scene into an asset container.
  34635. */
  34636. export class KeepAssets extends AbstractScene {
  34637. }
  34638. /**
  34639. * Container with a set of assets that can be added or removed from a scene.
  34640. */
  34641. export class AssetContainer extends AbstractScene {
  34642. /**
  34643. * The scene the AssetContainer belongs to.
  34644. */
  34645. scene: Scene;
  34646. /**
  34647. * Instantiates an AssetContainer.
  34648. * @param scene The scene the AssetContainer belongs to.
  34649. */
  34650. constructor(scene: Scene);
  34651. /**
  34652. * Adds all the assets from the container to the scene.
  34653. */
  34654. addAllToScene(): void;
  34655. /**
  34656. * Removes all the assets in the container from the scene
  34657. */
  34658. removeAllFromScene(): void;
  34659. /**
  34660. * Disposes all the assets in the container
  34661. */
  34662. dispose(): void;
  34663. private _moveAssets;
  34664. /**
  34665. * Removes all the assets contained in the scene and adds them to the container.
  34666. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34667. */
  34668. moveAllFromScene(keepAssets?: KeepAssets): void;
  34669. /**
  34670. * 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.
  34671. * @returns the root mesh
  34672. */
  34673. createRootMesh(): Mesh;
  34674. }
  34675. }
  34676. declare module "babylonjs/abstractScene" {
  34677. import { Scene } from "babylonjs/scene";
  34678. import { Nullable } from "babylonjs/types";
  34679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34680. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34681. import { Geometry } from "babylonjs/Meshes/geometry";
  34682. import { Skeleton } from "babylonjs/Bones/skeleton";
  34683. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34684. import { AssetContainer } from "babylonjs/assetContainer";
  34685. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34686. import { Animation } from "babylonjs/Animations/animation";
  34687. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34689. import { Material } from "babylonjs/Materials/material";
  34690. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34691. import { ActionManager } from "babylonjs/Actions/actionManager";
  34692. import { Camera } from "babylonjs/Cameras/camera";
  34693. import { Light } from "babylonjs/Lights/light";
  34694. import { Node } from "babylonjs/node";
  34695. /**
  34696. * Defines how the parser contract is defined.
  34697. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34698. */
  34699. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34700. /**
  34701. * Defines how the individual parser contract is defined.
  34702. * These parser can parse an individual asset
  34703. */
  34704. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34705. /**
  34706. * Base class of the scene acting as a container for the different elements composing a scene.
  34707. * This class is dynamically extended by the different components of the scene increasing
  34708. * flexibility and reducing coupling
  34709. */
  34710. export abstract class AbstractScene {
  34711. /**
  34712. * Stores the list of available parsers in the application.
  34713. */
  34714. private static _BabylonFileParsers;
  34715. /**
  34716. * Stores the list of available individual parsers in the application.
  34717. */
  34718. private static _IndividualBabylonFileParsers;
  34719. /**
  34720. * Adds a parser in the list of available ones
  34721. * @param name Defines the name of the parser
  34722. * @param parser Defines the parser to add
  34723. */
  34724. static AddParser(name: string, parser: BabylonFileParser): void;
  34725. /**
  34726. * Gets a general parser from the list of avaialble ones
  34727. * @param name Defines the name of the parser
  34728. * @returns the requested parser or null
  34729. */
  34730. static GetParser(name: string): Nullable<BabylonFileParser>;
  34731. /**
  34732. * Adds n individual parser in the list of available ones
  34733. * @param name Defines the name of the parser
  34734. * @param parser Defines the parser to add
  34735. */
  34736. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34737. /**
  34738. * Gets an individual parser from the list of avaialble ones
  34739. * @param name Defines the name of the parser
  34740. * @returns the requested parser or null
  34741. */
  34742. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34743. /**
  34744. * Parser json data and populate both a scene and its associated container object
  34745. * @param jsonData Defines the data to parse
  34746. * @param scene Defines the scene to parse the data for
  34747. * @param container Defines the container attached to the parsing sequence
  34748. * @param rootUrl Defines the root url of the data
  34749. */
  34750. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34751. /**
  34752. * Gets the list of root nodes (ie. nodes with no parent)
  34753. */
  34754. rootNodes: Node[];
  34755. /** All of the cameras added to this scene
  34756. * @see http://doc.babylonjs.com/babylon101/cameras
  34757. */
  34758. cameras: Camera[];
  34759. /**
  34760. * All of the lights added to this scene
  34761. * @see http://doc.babylonjs.com/babylon101/lights
  34762. */
  34763. lights: Light[];
  34764. /**
  34765. * All of the (abstract) meshes added to this scene
  34766. */
  34767. meshes: AbstractMesh[];
  34768. /**
  34769. * The list of skeletons added to the scene
  34770. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34771. */
  34772. skeletons: Skeleton[];
  34773. /**
  34774. * All of the particle systems added to this scene
  34775. * @see http://doc.babylonjs.com/babylon101/particles
  34776. */
  34777. particleSystems: IParticleSystem[];
  34778. /**
  34779. * Gets a list of Animations associated with the scene
  34780. */
  34781. animations: Animation[];
  34782. /**
  34783. * All of the animation groups added to this scene
  34784. * @see http://doc.babylonjs.com/how_to/group
  34785. */
  34786. animationGroups: AnimationGroup[];
  34787. /**
  34788. * All of the multi-materials added to this scene
  34789. * @see http://doc.babylonjs.com/how_to/multi_materials
  34790. */
  34791. multiMaterials: MultiMaterial[];
  34792. /**
  34793. * All of the materials added to this scene
  34794. * In the context of a Scene, it is not supposed to be modified manually.
  34795. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34796. * Note also that the order of the Material wihin the array is not significant and might change.
  34797. * @see http://doc.babylonjs.com/babylon101/materials
  34798. */
  34799. materials: Material[];
  34800. /**
  34801. * The list of morph target managers added to the scene
  34802. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34803. */
  34804. morphTargetManagers: MorphTargetManager[];
  34805. /**
  34806. * The list of geometries used in the scene.
  34807. */
  34808. geometries: Geometry[];
  34809. /**
  34810. * All of the tranform nodes added to this scene
  34811. * In the context of a Scene, it is not supposed to be modified manually.
  34812. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34813. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34814. * @see http://doc.babylonjs.com/how_to/transformnode
  34815. */
  34816. transformNodes: TransformNode[];
  34817. /**
  34818. * ActionManagers available on the scene.
  34819. */
  34820. actionManagers: ActionManager[];
  34821. /**
  34822. * Textures to keep.
  34823. */
  34824. textures: BaseTexture[];
  34825. }
  34826. }
  34827. declare module "babylonjs/Audio/sound" {
  34828. import { Observable } from "babylonjs/Misc/observable";
  34829. import { Vector3 } from "babylonjs/Maths/math";
  34830. import { Nullable } from "babylonjs/types";
  34831. import { Scene } from "babylonjs/scene";
  34832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34833. /**
  34834. * Defines a sound that can be played in the application.
  34835. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34837. */
  34838. export class Sound {
  34839. /**
  34840. * The name of the sound in the scene.
  34841. */
  34842. name: string;
  34843. /**
  34844. * Does the sound autoplay once loaded.
  34845. */
  34846. autoplay: boolean;
  34847. /**
  34848. * Does the sound loop after it finishes playing once.
  34849. */
  34850. loop: boolean;
  34851. /**
  34852. * Does the sound use a custom attenuation curve to simulate the falloff
  34853. * happening when the source gets further away from the camera.
  34854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34855. */
  34856. useCustomAttenuation: boolean;
  34857. /**
  34858. * The sound track id this sound belongs to.
  34859. */
  34860. soundTrackId: number;
  34861. /**
  34862. * Is this sound currently played.
  34863. */
  34864. isPlaying: boolean;
  34865. /**
  34866. * Is this sound currently paused.
  34867. */
  34868. isPaused: boolean;
  34869. /**
  34870. * Does this sound enables spatial sound.
  34871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34872. */
  34873. spatialSound: boolean;
  34874. /**
  34875. * Define the reference distance the sound should be heard perfectly.
  34876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34877. */
  34878. refDistance: number;
  34879. /**
  34880. * Define the roll off factor of spatial sounds.
  34881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34882. */
  34883. rolloffFactor: number;
  34884. /**
  34885. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34887. */
  34888. maxDistance: number;
  34889. /**
  34890. * Define the distance attenuation model the sound will follow.
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34892. */
  34893. distanceModel: string;
  34894. /**
  34895. * @hidden
  34896. * Back Compat
  34897. **/
  34898. onended: () => any;
  34899. /**
  34900. * Observable event when the current playing sound finishes.
  34901. */
  34902. onEndedObservable: Observable<Sound>;
  34903. private _panningModel;
  34904. private _playbackRate;
  34905. private _streaming;
  34906. private _startTime;
  34907. private _startOffset;
  34908. private _position;
  34909. /** @hidden */
  34910. _positionInEmitterSpace: boolean;
  34911. private _localDirection;
  34912. private _volume;
  34913. private _isReadyToPlay;
  34914. private _isDirectional;
  34915. private _readyToPlayCallback;
  34916. private _audioBuffer;
  34917. private _soundSource;
  34918. private _streamingSource;
  34919. private _soundPanner;
  34920. private _soundGain;
  34921. private _inputAudioNode;
  34922. private _outputAudioNode;
  34923. private _coneInnerAngle;
  34924. private _coneOuterAngle;
  34925. private _coneOuterGain;
  34926. private _scene;
  34927. private _connectedTransformNode;
  34928. private _customAttenuationFunction;
  34929. private _registerFunc;
  34930. private _isOutputConnected;
  34931. private _htmlAudioElement;
  34932. private _urlType;
  34933. /** @hidden */
  34934. static _SceneComponentInitialization: (scene: Scene) => void;
  34935. /**
  34936. * Create a sound and attach it to a scene
  34937. * @param name Name of your sound
  34938. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34939. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34940. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34941. */
  34942. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34943. /**
  34944. * Release the sound and its associated resources
  34945. */
  34946. dispose(): void;
  34947. /**
  34948. * Gets if the sounds is ready to be played or not.
  34949. * @returns true if ready, otherwise false
  34950. */
  34951. isReady(): boolean;
  34952. private _soundLoaded;
  34953. /**
  34954. * Sets the data of the sound from an audiobuffer
  34955. * @param audioBuffer The audioBuffer containing the data
  34956. */
  34957. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34958. /**
  34959. * Updates the current sounds options such as maxdistance, loop...
  34960. * @param options A JSON object containing values named as the object properties
  34961. */
  34962. updateOptions(options: any): void;
  34963. private _createSpatialParameters;
  34964. private _updateSpatialParameters;
  34965. /**
  34966. * Switch the panning model to HRTF:
  34967. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34969. */
  34970. switchPanningModelToHRTF(): void;
  34971. /**
  34972. * Switch the panning model to Equal Power:
  34973. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34975. */
  34976. switchPanningModelToEqualPower(): void;
  34977. private _switchPanningModel;
  34978. /**
  34979. * Connect this sound to a sound track audio node like gain...
  34980. * @param soundTrackAudioNode the sound track audio node to connect to
  34981. */
  34982. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34983. /**
  34984. * Transform this sound into a directional source
  34985. * @param coneInnerAngle Size of the inner cone in degree
  34986. * @param coneOuterAngle Size of the outer cone in degree
  34987. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34988. */
  34989. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34990. /**
  34991. * Gets or sets the inner angle for the directional cone.
  34992. */
  34993. /**
  34994. * Gets or sets the inner angle for the directional cone.
  34995. */
  34996. directionalConeInnerAngle: number;
  34997. /**
  34998. * Gets or sets the outer angle for the directional cone.
  34999. */
  35000. /**
  35001. * Gets or sets the outer angle for the directional cone.
  35002. */
  35003. directionalConeOuterAngle: number;
  35004. /**
  35005. * Sets the position of the emitter if spatial sound is enabled
  35006. * @param newPosition Defines the new posisiton
  35007. */
  35008. setPosition(newPosition: Vector3): void;
  35009. /**
  35010. * Sets the local direction of the emitter if spatial sound is enabled
  35011. * @param newLocalDirection Defines the new local direction
  35012. */
  35013. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35014. private _updateDirection;
  35015. /** @hidden */
  35016. updateDistanceFromListener(): void;
  35017. /**
  35018. * Sets a new custom attenuation function for the sound.
  35019. * @param callback Defines the function used for the attenuation
  35020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35021. */
  35022. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35023. /**
  35024. * Play the sound
  35025. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35026. * @param offset (optional) Start the sound setting it at a specific time
  35027. */
  35028. play(time?: number, offset?: number): void;
  35029. private _onended;
  35030. /**
  35031. * Stop the sound
  35032. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35033. */
  35034. stop(time?: number): void;
  35035. /**
  35036. * Put the sound in pause
  35037. */
  35038. pause(): void;
  35039. /**
  35040. * Sets a dedicated volume for this sounds
  35041. * @param newVolume Define the new volume of the sound
  35042. * @param time Define in how long the sound should be at this value
  35043. */
  35044. setVolume(newVolume: number, time?: number): void;
  35045. /**
  35046. * Set the sound play back rate
  35047. * @param newPlaybackRate Define the playback rate the sound should be played at
  35048. */
  35049. setPlaybackRate(newPlaybackRate: number): void;
  35050. /**
  35051. * Gets the volume of the sound.
  35052. * @returns the volume of the sound
  35053. */
  35054. getVolume(): number;
  35055. /**
  35056. * Attach the sound to a dedicated mesh
  35057. * @param transformNode The transform node to connect the sound with
  35058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35059. */
  35060. attachToMesh(transformNode: TransformNode): void;
  35061. /**
  35062. * Detach the sound from the previously attached mesh
  35063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35064. */
  35065. detachFromMesh(): void;
  35066. private _onRegisterAfterWorldMatrixUpdate;
  35067. /**
  35068. * Clone the current sound in the scene.
  35069. * @returns the new sound clone
  35070. */
  35071. clone(): Nullable<Sound>;
  35072. /**
  35073. * Gets the current underlying audio buffer containing the data
  35074. * @returns the audio buffer
  35075. */
  35076. getAudioBuffer(): Nullable<AudioBuffer>;
  35077. /**
  35078. * Serializes the Sound in a JSON representation
  35079. * @returns the JSON representation of the sound
  35080. */
  35081. serialize(): any;
  35082. /**
  35083. * Parse a JSON representation of a sound to innstantiate in a given scene
  35084. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35085. * @param scene Define the scene the new parsed sound should be created in
  35086. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35087. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35088. * @returns the newly parsed sound
  35089. */
  35090. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35091. }
  35092. }
  35093. declare module "babylonjs/Actions/directAudioActions" {
  35094. import { Action } from "babylonjs/Actions/action";
  35095. import { Condition } from "babylonjs/Actions/condition";
  35096. import { Sound } from "babylonjs/Audio/sound";
  35097. /**
  35098. * This defines an action helpful to play a defined sound on a triggered action.
  35099. */
  35100. export class PlaySoundAction extends Action {
  35101. private _sound;
  35102. /**
  35103. * Instantiate the action
  35104. * @param triggerOptions defines the trigger options
  35105. * @param sound defines the sound to play
  35106. * @param condition defines the trigger related conditions
  35107. */
  35108. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35109. /** @hidden */
  35110. _prepare(): void;
  35111. /**
  35112. * Execute the action and play the sound.
  35113. */
  35114. execute(): void;
  35115. /**
  35116. * Serializes the actions and its related information.
  35117. * @param parent defines the object to serialize in
  35118. * @returns the serialized object
  35119. */
  35120. serialize(parent: any): any;
  35121. }
  35122. /**
  35123. * This defines an action helpful to stop a defined sound on a triggered action.
  35124. */
  35125. export class StopSoundAction extends Action {
  35126. private _sound;
  35127. /**
  35128. * Instantiate the action
  35129. * @param triggerOptions defines the trigger options
  35130. * @param sound defines the sound to stop
  35131. * @param condition defines the trigger related conditions
  35132. */
  35133. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35134. /** @hidden */
  35135. _prepare(): void;
  35136. /**
  35137. * Execute the action and stop the sound.
  35138. */
  35139. execute(): void;
  35140. /**
  35141. * Serializes the actions and its related information.
  35142. * @param parent defines the object to serialize in
  35143. * @returns the serialized object
  35144. */
  35145. serialize(parent: any): any;
  35146. }
  35147. }
  35148. declare module "babylonjs/Actions/interpolateValueAction" {
  35149. import { Action } from "babylonjs/Actions/action";
  35150. import { Condition } from "babylonjs/Actions/condition";
  35151. import { Observable } from "babylonjs/Misc/observable";
  35152. /**
  35153. * This defines an action responsible to change the value of a property
  35154. * by interpolating between its current value and the newly set one once triggered.
  35155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35156. */
  35157. export class InterpolateValueAction extends Action {
  35158. /**
  35159. * Defines the path of the property where the value should be interpolated
  35160. */
  35161. propertyPath: string;
  35162. /**
  35163. * Defines the target value at the end of the interpolation.
  35164. */
  35165. value: any;
  35166. /**
  35167. * Defines the time it will take for the property to interpolate to the value.
  35168. */
  35169. duration: number;
  35170. /**
  35171. * Defines if the other scene animations should be stopped when the action has been triggered
  35172. */
  35173. stopOtherAnimations?: boolean;
  35174. /**
  35175. * Defines a callback raised once the interpolation animation has been done.
  35176. */
  35177. onInterpolationDone?: () => void;
  35178. /**
  35179. * Observable triggered once the interpolation animation has been done.
  35180. */
  35181. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35182. private _target;
  35183. private _effectiveTarget;
  35184. private _property;
  35185. /**
  35186. * Instantiate the action
  35187. * @param triggerOptions defines the trigger options
  35188. * @param target defines the object containing the value to interpolate
  35189. * @param propertyPath defines the path to the property in the target object
  35190. * @param value defines the target value at the end of the interpolation
  35191. * @param duration deines the time it will take for the property to interpolate to the value.
  35192. * @param condition defines the trigger related conditions
  35193. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35194. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35195. */
  35196. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35197. /** @hidden */
  35198. _prepare(): void;
  35199. /**
  35200. * Execute the action starts the value interpolation.
  35201. */
  35202. execute(): void;
  35203. /**
  35204. * Serializes the actions and its related information.
  35205. * @param parent defines the object to serialize in
  35206. * @returns the serialized object
  35207. */
  35208. serialize(parent: any): any;
  35209. }
  35210. }
  35211. declare module "babylonjs/Actions/index" {
  35212. export * from "babylonjs/Actions/action";
  35213. export * from "babylonjs/Actions/actionEvent";
  35214. export * from "babylonjs/Actions/actionManager";
  35215. export * from "babylonjs/Actions/condition";
  35216. export * from "babylonjs/Actions/directActions";
  35217. export * from "babylonjs/Actions/directAudioActions";
  35218. export * from "babylonjs/Actions/interpolateValueAction";
  35219. }
  35220. declare module "babylonjs/Animations/index" {
  35221. export * from "babylonjs/Animations/animatable";
  35222. export * from "babylonjs/Animations/animation";
  35223. export * from "babylonjs/Animations/animationGroup";
  35224. export * from "babylonjs/Animations/animationPropertiesOverride";
  35225. export * from "babylonjs/Animations/easing";
  35226. export * from "babylonjs/Animations/runtimeAnimation";
  35227. }
  35228. declare module "babylonjs/Audio/soundTrack" {
  35229. import { Sound } from "babylonjs/Audio/sound";
  35230. import { Analyser } from "babylonjs/Audio/analyser";
  35231. import { Scene } from "babylonjs/scene";
  35232. /**
  35233. * Options allowed during the creation of a sound track.
  35234. */
  35235. export interface ISoundTrackOptions {
  35236. /**
  35237. * The volume the sound track should take during creation
  35238. */
  35239. volume?: number;
  35240. /**
  35241. * Define if the sound track is the main sound track of the scene
  35242. */
  35243. mainTrack?: boolean;
  35244. }
  35245. /**
  35246. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35247. * It will be also used in a future release to apply effects on a specific track.
  35248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35249. */
  35250. export class SoundTrack {
  35251. /**
  35252. * The unique identifier of the sound track in the scene.
  35253. */
  35254. id: number;
  35255. /**
  35256. * The list of sounds included in the sound track.
  35257. */
  35258. soundCollection: Array<Sound>;
  35259. private _outputAudioNode;
  35260. private _scene;
  35261. private _isMainTrack;
  35262. private _connectedAnalyser;
  35263. private _options;
  35264. private _isInitialized;
  35265. /**
  35266. * Creates a new sound track.
  35267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35268. * @param scene Define the scene the sound track belongs to
  35269. * @param options
  35270. */
  35271. constructor(scene: Scene, options?: ISoundTrackOptions);
  35272. private _initializeSoundTrackAudioGraph;
  35273. /**
  35274. * Release the sound track and its associated resources
  35275. */
  35276. dispose(): void;
  35277. /**
  35278. * Adds a sound to this sound track
  35279. * @param sound define the cound to add
  35280. * @ignoreNaming
  35281. */
  35282. AddSound(sound: Sound): void;
  35283. /**
  35284. * Removes a sound to this sound track
  35285. * @param sound define the cound to remove
  35286. * @ignoreNaming
  35287. */
  35288. RemoveSound(sound: Sound): void;
  35289. /**
  35290. * Set a global volume for the full sound track.
  35291. * @param newVolume Define the new volume of the sound track
  35292. */
  35293. setVolume(newVolume: number): void;
  35294. /**
  35295. * Switch the panning model to HRTF:
  35296. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35298. */
  35299. switchPanningModelToHRTF(): void;
  35300. /**
  35301. * Switch the panning model to Equal Power:
  35302. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35304. */
  35305. switchPanningModelToEqualPower(): void;
  35306. /**
  35307. * Connect the sound track to an audio analyser allowing some amazing
  35308. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35310. * @param analyser The analyser to connect to the engine
  35311. */
  35312. connectToAnalyser(analyser: Analyser): void;
  35313. }
  35314. }
  35315. declare module "babylonjs/Audio/audioSceneComponent" {
  35316. import { Sound } from "babylonjs/Audio/sound";
  35317. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35318. import { Nullable } from "babylonjs/types";
  35319. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35320. import { Scene } from "babylonjs/scene";
  35321. import { AbstractScene } from "babylonjs/abstractScene";
  35322. module "babylonjs/abstractScene" {
  35323. interface AbstractScene {
  35324. /**
  35325. * The list of sounds used in the scene.
  35326. */
  35327. sounds: Nullable<Array<Sound>>;
  35328. }
  35329. }
  35330. module "babylonjs/scene" {
  35331. interface Scene {
  35332. /**
  35333. * @hidden
  35334. * Backing field
  35335. */
  35336. _mainSoundTrack: SoundTrack;
  35337. /**
  35338. * The main sound track played by the scene.
  35339. * It cotains your primary collection of sounds.
  35340. */
  35341. mainSoundTrack: SoundTrack;
  35342. /**
  35343. * The list of sound tracks added to the scene
  35344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35345. */
  35346. soundTracks: Nullable<Array<SoundTrack>>;
  35347. /**
  35348. * Gets a sound using a given name
  35349. * @param name defines the name to search for
  35350. * @return the found sound or null if not found at all.
  35351. */
  35352. getSoundByName(name: string): Nullable<Sound>;
  35353. /**
  35354. * Gets or sets if audio support is enabled
  35355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35356. */
  35357. audioEnabled: boolean;
  35358. /**
  35359. * Gets or sets if audio will be output to headphones
  35360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35361. */
  35362. headphone: boolean;
  35363. }
  35364. }
  35365. /**
  35366. * Defines the sound scene component responsible to manage any sounds
  35367. * in a given scene.
  35368. */
  35369. export class AudioSceneComponent implements ISceneSerializableComponent {
  35370. /**
  35371. * The component name helpfull to identify the component in the list of scene components.
  35372. */
  35373. readonly name: string;
  35374. /**
  35375. * The scene the component belongs to.
  35376. */
  35377. scene: Scene;
  35378. private _audioEnabled;
  35379. /**
  35380. * Gets whether audio is enabled or not.
  35381. * Please use related enable/disable method to switch state.
  35382. */
  35383. readonly audioEnabled: boolean;
  35384. private _headphone;
  35385. /**
  35386. * Gets whether audio is outputing to headphone or not.
  35387. * Please use the according Switch methods to change output.
  35388. */
  35389. readonly headphone: boolean;
  35390. /**
  35391. * Creates a new instance of the component for the given scene
  35392. * @param scene Defines the scene to register the component in
  35393. */
  35394. constructor(scene: Scene);
  35395. /**
  35396. * Registers the component in a given scene
  35397. */
  35398. register(): void;
  35399. /**
  35400. * Rebuilds the elements related to this component in case of
  35401. * context lost for instance.
  35402. */
  35403. rebuild(): void;
  35404. /**
  35405. * Serializes the component data to the specified json object
  35406. * @param serializationObject The object to serialize to
  35407. */
  35408. serialize(serializationObject: any): void;
  35409. /**
  35410. * Adds all the element from the container to the scene
  35411. * @param container the container holding the elements
  35412. */
  35413. addFromContainer(container: AbstractScene): void;
  35414. /**
  35415. * Removes all the elements in the container from the scene
  35416. * @param container contains the elements to remove
  35417. */
  35418. removeFromContainer(container: AbstractScene): void;
  35419. /**
  35420. * Disposes the component and the associated ressources.
  35421. */
  35422. dispose(): void;
  35423. /**
  35424. * Disables audio in the associated scene.
  35425. */
  35426. disableAudio(): void;
  35427. /**
  35428. * Enables audio in the associated scene.
  35429. */
  35430. enableAudio(): void;
  35431. /**
  35432. * Switch audio to headphone output.
  35433. */
  35434. switchAudioModeForHeadphones(): void;
  35435. /**
  35436. * Switch audio to normal speakers.
  35437. */
  35438. switchAudioModeForNormalSpeakers(): void;
  35439. private _afterRender;
  35440. }
  35441. }
  35442. declare module "babylonjs/Audio/weightedsound" {
  35443. import { Sound } from "babylonjs/Audio/sound";
  35444. /**
  35445. * Wraps one or more Sound objects and selects one with random weight for playback.
  35446. */
  35447. export class WeightedSound {
  35448. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35449. loop: boolean;
  35450. private _coneInnerAngle;
  35451. private _coneOuterAngle;
  35452. private _volume;
  35453. /** A Sound is currently playing. */
  35454. isPlaying: boolean;
  35455. /** A Sound is currently paused. */
  35456. isPaused: boolean;
  35457. private _sounds;
  35458. private _weights;
  35459. private _currentIndex?;
  35460. /**
  35461. * Creates a new WeightedSound from the list of sounds given.
  35462. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35463. * @param sounds Array of Sounds that will be selected from.
  35464. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35465. */
  35466. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35467. /**
  35468. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35469. */
  35470. /**
  35471. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35472. */
  35473. directionalConeInnerAngle: number;
  35474. /**
  35475. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35476. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35477. */
  35478. /**
  35479. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35480. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35481. */
  35482. directionalConeOuterAngle: number;
  35483. /**
  35484. * Playback volume.
  35485. */
  35486. /**
  35487. * Playback volume.
  35488. */
  35489. volume: number;
  35490. private _onended;
  35491. /**
  35492. * Suspend playback
  35493. */
  35494. pause(): void;
  35495. /**
  35496. * Stop playback
  35497. */
  35498. stop(): void;
  35499. /**
  35500. * Start playback.
  35501. * @param startOffset Position the clip head at a specific time in seconds.
  35502. */
  35503. play(startOffset?: number): void;
  35504. }
  35505. }
  35506. declare module "babylonjs/Audio/index" {
  35507. export * from "babylonjs/Audio/analyser";
  35508. export * from "babylonjs/Audio/audioEngine";
  35509. export * from "babylonjs/Audio/audioSceneComponent";
  35510. export * from "babylonjs/Audio/sound";
  35511. export * from "babylonjs/Audio/soundTrack";
  35512. export * from "babylonjs/Audio/weightedsound";
  35513. }
  35514. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35515. import { Behavior } from "babylonjs/Behaviors/behavior";
  35516. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35517. import { BackEase } from "babylonjs/Animations/easing";
  35518. /**
  35519. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35520. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35521. */
  35522. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35523. /**
  35524. * Gets the name of the behavior.
  35525. */
  35526. readonly name: string;
  35527. /**
  35528. * The easing function used by animations
  35529. */
  35530. static EasingFunction: BackEase;
  35531. /**
  35532. * The easing mode used by animations
  35533. */
  35534. static EasingMode: number;
  35535. /**
  35536. * The duration of the animation, in milliseconds
  35537. */
  35538. transitionDuration: number;
  35539. /**
  35540. * Length of the distance animated by the transition when lower radius is reached
  35541. */
  35542. lowerRadiusTransitionRange: number;
  35543. /**
  35544. * Length of the distance animated by the transition when upper radius is reached
  35545. */
  35546. upperRadiusTransitionRange: number;
  35547. private _autoTransitionRange;
  35548. /**
  35549. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35550. */
  35551. /**
  35552. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35553. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35554. */
  35555. autoTransitionRange: boolean;
  35556. private _attachedCamera;
  35557. private _onAfterCheckInputsObserver;
  35558. private _onMeshTargetChangedObserver;
  35559. /**
  35560. * Initializes the behavior.
  35561. */
  35562. init(): void;
  35563. /**
  35564. * Attaches the behavior to its arc rotate camera.
  35565. * @param camera Defines the camera to attach the behavior to
  35566. */
  35567. attach(camera: ArcRotateCamera): void;
  35568. /**
  35569. * Detaches the behavior from its current arc rotate camera.
  35570. */
  35571. detach(): void;
  35572. private _radiusIsAnimating;
  35573. private _radiusBounceTransition;
  35574. private _animatables;
  35575. private _cachedWheelPrecision;
  35576. /**
  35577. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35578. * @param radiusLimit The limit to check against.
  35579. * @return Bool to indicate if at limit.
  35580. */
  35581. private _isRadiusAtLimit;
  35582. /**
  35583. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35584. * @param radiusDelta The delta by which to animate to. Can be negative.
  35585. */
  35586. private _applyBoundRadiusAnimation;
  35587. /**
  35588. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35589. */
  35590. protected _clearAnimationLocks(): void;
  35591. /**
  35592. * Stops and removes all animations that have been applied to the camera
  35593. */
  35594. stopAllAnimations(): void;
  35595. }
  35596. }
  35597. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35598. import { Behavior } from "babylonjs/Behaviors/behavior";
  35599. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35600. import { ExponentialEase } from "babylonjs/Animations/easing";
  35601. import { Nullable } from "babylonjs/types";
  35602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35603. import { Vector3 } from "babylonjs/Maths/math";
  35604. /**
  35605. * 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.
  35606. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35607. */
  35608. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35609. /**
  35610. * Gets the name of the behavior.
  35611. */
  35612. readonly name: string;
  35613. private _mode;
  35614. private _radiusScale;
  35615. private _positionScale;
  35616. private _defaultElevation;
  35617. private _elevationReturnTime;
  35618. private _elevationReturnWaitTime;
  35619. private _zoomStopsAnimation;
  35620. private _framingTime;
  35621. /**
  35622. * The easing function used by animations
  35623. */
  35624. static EasingFunction: ExponentialEase;
  35625. /**
  35626. * The easing mode used by animations
  35627. */
  35628. static EasingMode: number;
  35629. /**
  35630. * Sets the current mode used by the behavior
  35631. */
  35632. /**
  35633. * Gets current mode used by the behavior.
  35634. */
  35635. mode: number;
  35636. /**
  35637. * Sets the scale applied to the radius (1 by default)
  35638. */
  35639. /**
  35640. * Gets the scale applied to the radius
  35641. */
  35642. radiusScale: number;
  35643. /**
  35644. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35645. */
  35646. /**
  35647. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35648. */
  35649. positionScale: number;
  35650. /**
  35651. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35652. * behaviour is triggered, in radians.
  35653. */
  35654. /**
  35655. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35656. * behaviour is triggered, in radians.
  35657. */
  35658. defaultElevation: number;
  35659. /**
  35660. * Sets the time (in milliseconds) taken to return to the default beta position.
  35661. * Negative value indicates camera should not return to default.
  35662. */
  35663. /**
  35664. * Gets the time (in milliseconds) taken to return to the default beta position.
  35665. * Negative value indicates camera should not return to default.
  35666. */
  35667. elevationReturnTime: number;
  35668. /**
  35669. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35670. */
  35671. /**
  35672. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35673. */
  35674. elevationReturnWaitTime: number;
  35675. /**
  35676. * Sets the flag that indicates if user zooming should stop animation.
  35677. */
  35678. /**
  35679. * Gets the flag that indicates if user zooming should stop animation.
  35680. */
  35681. zoomStopsAnimation: boolean;
  35682. /**
  35683. * Sets the transition time when framing the mesh, in milliseconds
  35684. */
  35685. /**
  35686. * Gets the transition time when framing the mesh, in milliseconds
  35687. */
  35688. framingTime: number;
  35689. /**
  35690. * Define if the behavior should automatically change the configured
  35691. * camera limits and sensibilities.
  35692. */
  35693. autoCorrectCameraLimitsAndSensibility: boolean;
  35694. private _onPrePointerObservableObserver;
  35695. private _onAfterCheckInputsObserver;
  35696. private _onMeshTargetChangedObserver;
  35697. private _attachedCamera;
  35698. private _isPointerDown;
  35699. private _lastInteractionTime;
  35700. /**
  35701. * Initializes the behavior.
  35702. */
  35703. init(): void;
  35704. /**
  35705. * Attaches the behavior to its arc rotate camera.
  35706. * @param camera Defines the camera to attach the behavior to
  35707. */
  35708. attach(camera: ArcRotateCamera): void;
  35709. /**
  35710. * Detaches the behavior from its current arc rotate camera.
  35711. */
  35712. detach(): void;
  35713. private _animatables;
  35714. private _betaIsAnimating;
  35715. private _betaTransition;
  35716. private _radiusTransition;
  35717. private _vectorTransition;
  35718. /**
  35719. * Targets the given mesh and updates zoom level accordingly.
  35720. * @param mesh The mesh to target.
  35721. * @param radius Optional. If a cached radius position already exists, overrides default.
  35722. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35723. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35724. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35725. */
  35726. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35727. /**
  35728. * Targets the given mesh with its children and updates zoom level accordingly.
  35729. * @param mesh The mesh to target.
  35730. * @param radius Optional. If a cached radius position already exists, overrides default.
  35731. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35732. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35733. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35734. */
  35735. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35736. /**
  35737. * Targets the given meshes with their children and updates zoom level accordingly.
  35738. * @param meshes The mesh to target.
  35739. * @param radius Optional. If a cached radius position already exists, overrides default.
  35740. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35741. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35742. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35743. */
  35744. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35745. /**
  35746. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35747. * @param minimumWorld Determines the smaller position of the bounding box extend
  35748. * @param maximumWorld Determines the bigger position of the bounding box extend
  35749. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35750. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35751. */
  35752. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35753. /**
  35754. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35755. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35756. * frustum width.
  35757. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35758. * to fully enclose the mesh in the viewing frustum.
  35759. */
  35760. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35761. /**
  35762. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35763. * is automatically returned to its default position (expected to be above ground plane).
  35764. */
  35765. private _maintainCameraAboveGround;
  35766. /**
  35767. * Returns the frustum slope based on the canvas ratio and camera FOV
  35768. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35769. */
  35770. private _getFrustumSlope;
  35771. /**
  35772. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35773. */
  35774. private _clearAnimationLocks;
  35775. /**
  35776. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35777. */
  35778. private _applyUserInteraction;
  35779. /**
  35780. * Stops and removes all animations that have been applied to the camera
  35781. */
  35782. stopAllAnimations(): void;
  35783. /**
  35784. * Gets a value indicating if the user is moving the camera
  35785. */
  35786. readonly isUserIsMoving: boolean;
  35787. /**
  35788. * The camera can move all the way towards the mesh.
  35789. */
  35790. static IgnoreBoundsSizeMode: number;
  35791. /**
  35792. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35793. */
  35794. static FitFrustumSidesMode: number;
  35795. }
  35796. }
  35797. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35798. import { Nullable } from "babylonjs/types";
  35799. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35800. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35801. /**
  35802. * Manage the pointers inputs to control an arc rotate camera.
  35803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35804. */
  35805. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  35806. /**
  35807. * Defines the camera the input is attached to.
  35808. */
  35809. camera: ArcRotateCamera;
  35810. /**
  35811. * Defines the buttons associated with the input to handle camera move.
  35812. */
  35813. buttons: number[];
  35814. /**
  35815. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35816. */
  35817. angularSensibilityX: number;
  35818. /**
  35819. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35820. */
  35821. angularSensibilityY: number;
  35822. /**
  35823. * Defines the pointer pinch precision or how fast is the camera zooming.
  35824. */
  35825. pinchPrecision: number;
  35826. /**
  35827. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  35828. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35829. */
  35830. pinchDeltaPercentage: number;
  35831. /**
  35832. * Defines the pointer panning sensibility or how fast is the camera moving.
  35833. */
  35834. panningSensibility: number;
  35835. /**
  35836. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35837. */
  35838. multiTouchPanning: boolean;
  35839. /**
  35840. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  35841. */
  35842. multiTouchPanAndZoom: boolean;
  35843. /**
  35844. * Revers pinch action direction.
  35845. */
  35846. pinchInwards: boolean;
  35847. private _isPanClick;
  35848. private _pointerInput;
  35849. private _observer;
  35850. private _onMouseMove;
  35851. private _onGestureStart;
  35852. private _onGesture;
  35853. private _MSGestureHandler;
  35854. private _onLostFocus;
  35855. private _onContextMenu;
  35856. /**
  35857. * Attach the input controls to a specific dom element to get the input from.
  35858. * @param element Defines the element the controls should be listened from
  35859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35860. */
  35861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35862. /**
  35863. * Detach the current controls from the specified dom element.
  35864. * @param element Defines the element to stop listening the inputs from
  35865. */
  35866. detachControl(element: Nullable<HTMLElement>): void;
  35867. /**
  35868. * Gets the class name of the current intput.
  35869. * @returns the class name
  35870. */
  35871. getClassName(): string;
  35872. /**
  35873. * Get the friendly name associated with the input class.
  35874. * @returns the input friendly name
  35875. */
  35876. getSimpleName(): string;
  35877. }
  35878. }
  35879. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35880. import { Nullable } from "babylonjs/types";
  35881. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35883. /**
  35884. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35886. */
  35887. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35888. /**
  35889. * Defines the camera the input is attached to.
  35890. */
  35891. camera: ArcRotateCamera;
  35892. /**
  35893. * Defines the list of key codes associated with the up action (increase alpha)
  35894. */
  35895. keysUp: number[];
  35896. /**
  35897. * Defines the list of key codes associated with the down action (decrease alpha)
  35898. */
  35899. keysDown: number[];
  35900. /**
  35901. * Defines the list of key codes associated with the left action (increase beta)
  35902. */
  35903. keysLeft: number[];
  35904. /**
  35905. * Defines the list of key codes associated with the right action (decrease beta)
  35906. */
  35907. keysRight: number[];
  35908. /**
  35909. * Defines the list of key codes associated with the reset action.
  35910. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35911. */
  35912. keysReset: number[];
  35913. /**
  35914. * Defines the panning sensibility of the inputs.
  35915. * (How fast is the camera paning)
  35916. */
  35917. panningSensibility: number;
  35918. /**
  35919. * Defines the zooming sensibility of the inputs.
  35920. * (How fast is the camera zooming)
  35921. */
  35922. zoomingSensibility: number;
  35923. /**
  35924. * Defines wether maintaining the alt key down switch the movement mode from
  35925. * orientation to zoom.
  35926. */
  35927. useAltToZoom: boolean;
  35928. /**
  35929. * Rotation speed of the camera
  35930. */
  35931. angularSpeed: number;
  35932. private _keys;
  35933. private _ctrlPressed;
  35934. private _altPressed;
  35935. private _onCanvasBlurObserver;
  35936. private _onKeyboardObserver;
  35937. private _engine;
  35938. private _scene;
  35939. /**
  35940. * Attach the input controls to a specific dom element to get the input from.
  35941. * @param element Defines the element the controls should be listened from
  35942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35943. */
  35944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35945. /**
  35946. * Detach the current controls from the specified dom element.
  35947. * @param element Defines the element to stop listening the inputs from
  35948. */
  35949. detachControl(element: Nullable<HTMLElement>): void;
  35950. /**
  35951. * Update the current camera state depending on the inputs that have been used this frame.
  35952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35953. */
  35954. checkInputs(): void;
  35955. /**
  35956. * Gets the class name of the current intput.
  35957. * @returns the class name
  35958. */
  35959. getClassName(): string;
  35960. /**
  35961. * Get the friendly name associated with the input class.
  35962. * @returns the input friendly name
  35963. */
  35964. getSimpleName(): string;
  35965. }
  35966. }
  35967. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35968. import { Nullable } from "babylonjs/types";
  35969. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35970. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35971. /**
  35972. * Manage the mouse wheel inputs to control an arc rotate camera.
  35973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35974. */
  35975. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35976. /**
  35977. * Defines the camera the input is attached to.
  35978. */
  35979. camera: ArcRotateCamera;
  35980. /**
  35981. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35982. */
  35983. wheelPrecision: number;
  35984. /**
  35985. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35986. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35987. */
  35988. wheelDeltaPercentage: number;
  35989. private _wheel;
  35990. private _observer;
  35991. /**
  35992. * Attach the input controls to a specific dom element to get the input from.
  35993. * @param element Defines the element the controls should be listened from
  35994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35995. */
  35996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35997. /**
  35998. * Detach the current controls from the specified dom element.
  35999. * @param element Defines the element to stop listening the inputs from
  36000. */
  36001. detachControl(element: Nullable<HTMLElement>): void;
  36002. /**
  36003. * Gets the class name of the current intput.
  36004. * @returns the class name
  36005. */
  36006. getClassName(): string;
  36007. /**
  36008. * Get the friendly name associated with the input class.
  36009. * @returns the input friendly name
  36010. */
  36011. getSimpleName(): string;
  36012. }
  36013. }
  36014. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36015. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36016. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36017. /**
  36018. * Default Inputs manager for the ArcRotateCamera.
  36019. * It groups all the default supported inputs for ease of use.
  36020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36021. */
  36022. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36023. /**
  36024. * Instantiates a new ArcRotateCameraInputsManager.
  36025. * @param camera Defines the camera the inputs belong to
  36026. */
  36027. constructor(camera: ArcRotateCamera);
  36028. /**
  36029. * Add mouse wheel input support to the input manager.
  36030. * @returns the current input manager
  36031. */
  36032. addMouseWheel(): ArcRotateCameraInputsManager;
  36033. /**
  36034. * Add pointers input support to the input manager.
  36035. * @returns the current input manager
  36036. */
  36037. addPointers(): ArcRotateCameraInputsManager;
  36038. /**
  36039. * Add keyboard input support to the input manager.
  36040. * @returns the current input manager
  36041. */
  36042. addKeyboard(): ArcRotateCameraInputsManager;
  36043. }
  36044. }
  36045. declare module "babylonjs/Cameras/arcRotateCamera" {
  36046. import { Observable } from "babylonjs/Misc/observable";
  36047. import { Nullable } from "babylonjs/types";
  36048. import { Scene } from "babylonjs/scene";
  36049. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36051. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36052. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36053. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36054. import { Collider } from "babylonjs/Collisions/collider";
  36055. import { Camera } from "babylonjs/Cameras/camera";
  36056. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36057. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36058. /**
  36059. * This represents an orbital type of camera.
  36060. *
  36061. * 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.
  36062. * 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.
  36063. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36064. */
  36065. export class ArcRotateCamera extends TargetCamera {
  36066. /**
  36067. * Defines the rotation angle of the camera along the longitudinal axis.
  36068. */
  36069. alpha: number;
  36070. /**
  36071. * Defines the rotation angle of the camera along the latitudinal axis.
  36072. */
  36073. beta: number;
  36074. /**
  36075. * Defines the radius of the camera from it s target point.
  36076. */
  36077. radius: number;
  36078. protected _target: Vector3;
  36079. protected _targetHost: Nullable<AbstractMesh>;
  36080. /**
  36081. * Defines the target point of the camera.
  36082. * The camera looks towards it form the radius distance.
  36083. */
  36084. target: Vector3;
  36085. /**
  36086. * Current inertia value on the longitudinal axis.
  36087. * The bigger this number the longer it will take for the camera to stop.
  36088. */
  36089. inertialAlphaOffset: number;
  36090. /**
  36091. * Current inertia value on the latitudinal axis.
  36092. * The bigger this number the longer it will take for the camera to stop.
  36093. */
  36094. inertialBetaOffset: number;
  36095. /**
  36096. * Current inertia value on the radius axis.
  36097. * The bigger this number the longer it will take for the camera to stop.
  36098. */
  36099. inertialRadiusOffset: number;
  36100. /**
  36101. * Minimum allowed angle on the longitudinal axis.
  36102. * This can help limiting how the Camera is able to move in the scene.
  36103. */
  36104. lowerAlphaLimit: Nullable<number>;
  36105. /**
  36106. * Maximum allowed angle on the longitudinal axis.
  36107. * This can help limiting how the Camera is able to move in the scene.
  36108. */
  36109. upperAlphaLimit: Nullable<number>;
  36110. /**
  36111. * Minimum allowed angle on the latitudinal axis.
  36112. * This can help limiting how the Camera is able to move in the scene.
  36113. */
  36114. lowerBetaLimit: number;
  36115. /**
  36116. * Maximum allowed angle on the latitudinal axis.
  36117. * This can help limiting how the Camera is able to move in the scene.
  36118. */
  36119. upperBetaLimit: number;
  36120. /**
  36121. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36122. * This can help limiting how the Camera is able to move in the scene.
  36123. */
  36124. lowerRadiusLimit: Nullable<number>;
  36125. /**
  36126. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36127. * This can help limiting how the Camera is able to move in the scene.
  36128. */
  36129. upperRadiusLimit: Nullable<number>;
  36130. /**
  36131. * Defines the current inertia value used during panning of the camera along the X axis.
  36132. */
  36133. inertialPanningX: number;
  36134. /**
  36135. * Defines the current inertia value used during panning of the camera along the Y axis.
  36136. */
  36137. inertialPanningY: number;
  36138. /**
  36139. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36140. * Basically if your fingers moves away from more than this distance you will be considered
  36141. * in pinch mode.
  36142. */
  36143. pinchToPanMaxDistance: number;
  36144. /**
  36145. * Defines the maximum distance the camera can pan.
  36146. * This could help keeping the cammera always in your scene.
  36147. */
  36148. panningDistanceLimit: Nullable<number>;
  36149. /**
  36150. * Defines the target of the camera before paning.
  36151. */
  36152. panningOriginTarget: Vector3;
  36153. /**
  36154. * Defines the value of the inertia used during panning.
  36155. * 0 would mean stop inertia and one would mean no decelleration at all.
  36156. */
  36157. panningInertia: number;
  36158. /**
  36159. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36160. */
  36161. angularSensibilityX: number;
  36162. /**
  36163. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36164. */
  36165. angularSensibilityY: number;
  36166. /**
  36167. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36168. */
  36169. pinchPrecision: number;
  36170. /**
  36171. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36172. * It will be used instead of pinchDeltaPrecision if different from 0.
  36173. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36174. */
  36175. pinchDeltaPercentage: number;
  36176. /**
  36177. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36178. */
  36179. panningSensibility: number;
  36180. /**
  36181. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36182. */
  36183. keysUp: number[];
  36184. /**
  36185. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36186. */
  36187. keysDown: number[];
  36188. /**
  36189. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36190. */
  36191. keysLeft: number[];
  36192. /**
  36193. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36194. */
  36195. keysRight: number[];
  36196. /**
  36197. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36198. */
  36199. wheelPrecision: number;
  36200. /**
  36201. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36202. * It will be used instead of pinchDeltaPrecision if different from 0.
  36203. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36204. */
  36205. wheelDeltaPercentage: number;
  36206. /**
  36207. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36208. */
  36209. zoomOnFactor: number;
  36210. /**
  36211. * Defines a screen offset for the camera position.
  36212. */
  36213. targetScreenOffset: Vector2;
  36214. /**
  36215. * Allows the camera to be completely reversed.
  36216. * If false the camera can not arrive upside down.
  36217. */
  36218. allowUpsideDown: boolean;
  36219. /**
  36220. * Define if double tap/click is used to restore the previously saved state of the camera.
  36221. */
  36222. useInputToRestoreState: boolean;
  36223. /** @hidden */
  36224. _viewMatrix: Matrix;
  36225. /** @hidden */
  36226. _useCtrlForPanning: boolean;
  36227. /** @hidden */
  36228. _panningMouseButton: number;
  36229. /**
  36230. * Defines the input associated to the camera.
  36231. */
  36232. inputs: ArcRotateCameraInputsManager;
  36233. /** @hidden */
  36234. _reset: () => void;
  36235. /**
  36236. * Defines the allowed panning axis.
  36237. */
  36238. panningAxis: Vector3;
  36239. protected _localDirection: Vector3;
  36240. protected _transformedDirection: Vector3;
  36241. private _bouncingBehavior;
  36242. /**
  36243. * Gets the bouncing behavior of the camera if it has been enabled.
  36244. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36245. */
  36246. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36247. /**
  36248. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36249. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36250. */
  36251. useBouncingBehavior: boolean;
  36252. private _framingBehavior;
  36253. /**
  36254. * Gets the framing behavior of the camera if it has been enabled.
  36255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36256. */
  36257. readonly framingBehavior: Nullable<FramingBehavior>;
  36258. /**
  36259. * Defines if the framing behavior of the camera is enabled on the camera.
  36260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36261. */
  36262. useFramingBehavior: boolean;
  36263. private _autoRotationBehavior;
  36264. /**
  36265. * Gets the auto rotation behavior of the camera if it has been enabled.
  36266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36267. */
  36268. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36269. /**
  36270. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36272. */
  36273. useAutoRotationBehavior: boolean;
  36274. /**
  36275. * Observable triggered when the mesh target has been changed on the camera.
  36276. */
  36277. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36278. /**
  36279. * Event raised when the camera is colliding with a mesh.
  36280. */
  36281. onCollide: (collidedMesh: AbstractMesh) => void;
  36282. /**
  36283. * Defines whether the camera should check collision with the objects oh the scene.
  36284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36285. */
  36286. checkCollisions: boolean;
  36287. /**
  36288. * Defines the collision radius of the camera.
  36289. * This simulates a sphere around the camera.
  36290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36291. */
  36292. collisionRadius: Vector3;
  36293. protected _collider: Collider;
  36294. protected _previousPosition: Vector3;
  36295. protected _collisionVelocity: Vector3;
  36296. protected _newPosition: Vector3;
  36297. protected _previousAlpha: number;
  36298. protected _previousBeta: number;
  36299. protected _previousRadius: number;
  36300. protected _collisionTriggered: boolean;
  36301. protected _targetBoundingCenter: Nullable<Vector3>;
  36302. private _computationVector;
  36303. private _tempAxisVector;
  36304. private _tempAxisRotationMatrix;
  36305. /**
  36306. * Instantiates a new ArcRotateCamera in a given scene
  36307. * @param name Defines the name of the camera
  36308. * @param alpha Defines the camera rotation along the logitudinal axis
  36309. * @param beta Defines the camera rotation along the latitudinal axis
  36310. * @param radius Defines the camera distance from its target
  36311. * @param target Defines the camera target
  36312. * @param scene Defines the scene the camera belongs to
  36313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36314. */
  36315. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36316. /** @hidden */
  36317. _initCache(): void;
  36318. /** @hidden */
  36319. _updateCache(ignoreParentClass?: boolean): void;
  36320. protected _getTargetPosition(): Vector3;
  36321. private _storedAlpha;
  36322. private _storedBeta;
  36323. private _storedRadius;
  36324. private _storedTarget;
  36325. /**
  36326. * Stores the current state of the camera (alpha, beta, radius and target)
  36327. * @returns the camera itself
  36328. */
  36329. storeState(): Camera;
  36330. /**
  36331. * @hidden
  36332. * Restored camera state. You must call storeState() first
  36333. */
  36334. _restoreStateValues(): boolean;
  36335. /** @hidden */
  36336. _isSynchronizedViewMatrix(): boolean;
  36337. /**
  36338. * Attached controls to the current camera.
  36339. * @param element Defines the element the controls should be listened from
  36340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36341. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36342. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36343. */
  36344. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36345. /**
  36346. * Detach the current controls from the camera.
  36347. * The camera will stop reacting to inputs.
  36348. * @param element Defines the element to stop listening the inputs from
  36349. */
  36350. detachControl(element: HTMLElement): void;
  36351. /** @hidden */
  36352. _checkInputs(): void;
  36353. protected _checkLimits(): void;
  36354. /**
  36355. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  36356. */
  36357. rebuildAnglesAndRadius(): void;
  36358. /**
  36359. * Use a position to define the current camera related information like aplha, beta and radius
  36360. * @param position Defines the position to set the camera at
  36361. */
  36362. setPosition(position: Vector3): void;
  36363. /**
  36364. * Defines the target the camera should look at.
  36365. * This will automatically adapt alpha beta and radius to fit within the new target.
  36366. * @param target Defines the new target as a Vector or a mesh
  36367. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36368. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36369. */
  36370. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36371. /** @hidden */
  36372. _getViewMatrix(): Matrix;
  36373. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36374. /**
  36375. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36376. * @param meshes Defines the mesh to zoom on
  36377. * @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)
  36378. */
  36379. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36380. /**
  36381. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36382. * The target will be changed but the radius
  36383. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36384. * @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)
  36385. */
  36386. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36387. min: Vector3;
  36388. max: Vector3;
  36389. distance: number;
  36390. }, doNotUpdateMaxZ?: boolean): void;
  36391. /**
  36392. * @override
  36393. * Override Camera.createRigCamera
  36394. */
  36395. createRigCamera(name: string, cameraIndex: number): Camera;
  36396. /**
  36397. * @hidden
  36398. * @override
  36399. * Override Camera._updateRigCameras
  36400. */
  36401. _updateRigCameras(): void;
  36402. /**
  36403. * Destroy the camera and release the current resources hold by it.
  36404. */
  36405. dispose(): void;
  36406. /**
  36407. * Gets the current object class name.
  36408. * @return the class name
  36409. */
  36410. getClassName(): string;
  36411. }
  36412. }
  36413. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36414. import { Behavior } from "babylonjs/Behaviors/behavior";
  36415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36416. /**
  36417. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36418. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36419. */
  36420. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36421. /**
  36422. * Gets the name of the behavior.
  36423. */
  36424. readonly name: string;
  36425. private _zoomStopsAnimation;
  36426. private _idleRotationSpeed;
  36427. private _idleRotationWaitTime;
  36428. private _idleRotationSpinupTime;
  36429. /**
  36430. * Sets the flag that indicates if user zooming should stop animation.
  36431. */
  36432. /**
  36433. * Gets the flag that indicates if user zooming should stop animation.
  36434. */
  36435. zoomStopsAnimation: boolean;
  36436. /**
  36437. * Sets the default speed at which the camera rotates around the model.
  36438. */
  36439. /**
  36440. * Gets the default speed at which the camera rotates around the model.
  36441. */
  36442. idleRotationSpeed: number;
  36443. /**
  36444. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36445. */
  36446. /**
  36447. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36448. */
  36449. idleRotationWaitTime: number;
  36450. /**
  36451. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36452. */
  36453. /**
  36454. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36455. */
  36456. idleRotationSpinupTime: number;
  36457. /**
  36458. * Gets a value indicating if the camera is currently rotating because of this behavior
  36459. */
  36460. readonly rotationInProgress: boolean;
  36461. private _onPrePointerObservableObserver;
  36462. private _onAfterCheckInputsObserver;
  36463. private _attachedCamera;
  36464. private _isPointerDown;
  36465. private _lastFrameTime;
  36466. private _lastInteractionTime;
  36467. private _cameraRotationSpeed;
  36468. /**
  36469. * Initializes the behavior.
  36470. */
  36471. init(): void;
  36472. /**
  36473. * Attaches the behavior to its arc rotate camera.
  36474. * @param camera Defines the camera to attach the behavior to
  36475. */
  36476. attach(camera: ArcRotateCamera): void;
  36477. /**
  36478. * Detaches the behavior from its current arc rotate camera.
  36479. */
  36480. detach(): void;
  36481. /**
  36482. * Returns true if user is scrolling.
  36483. * @return true if user is scrolling.
  36484. */
  36485. private _userIsZooming;
  36486. private _lastFrameRadius;
  36487. private _shouldAnimationStopForInteraction;
  36488. /**
  36489. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36490. */
  36491. private _applyUserInteraction;
  36492. private _userIsMoving;
  36493. }
  36494. }
  36495. declare module "babylonjs/Behaviors/Cameras/index" {
  36496. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36497. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36498. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36499. }
  36500. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36501. import { Mesh } from "babylonjs/Meshes/mesh";
  36502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36503. import { Behavior } from "babylonjs/Behaviors/behavior";
  36504. /**
  36505. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36506. */
  36507. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36508. private ui;
  36509. /**
  36510. * The name of the behavior
  36511. */
  36512. name: string;
  36513. /**
  36514. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36515. */
  36516. distanceAwayFromFace: number;
  36517. /**
  36518. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36519. */
  36520. distanceAwayFromBottomOfFace: number;
  36521. private _faceVectors;
  36522. private _target;
  36523. private _scene;
  36524. private _onRenderObserver;
  36525. private _tmpMatrix;
  36526. private _tmpVector;
  36527. /**
  36528. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36529. * @param ui The transform node that should be attched to the mesh
  36530. */
  36531. constructor(ui: TransformNode);
  36532. /**
  36533. * Initializes the behavior
  36534. */
  36535. init(): void;
  36536. private _closestFace;
  36537. private _zeroVector;
  36538. private _lookAtTmpMatrix;
  36539. private _lookAtToRef;
  36540. /**
  36541. * Attaches the AttachToBoxBehavior to the passed in mesh
  36542. * @param target The mesh that the specified node will be attached to
  36543. */
  36544. attach(target: Mesh): void;
  36545. /**
  36546. * Detaches the behavior from the mesh
  36547. */
  36548. detach(): void;
  36549. }
  36550. }
  36551. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36552. import { Behavior } from "babylonjs/Behaviors/behavior";
  36553. import { Mesh } from "babylonjs/Meshes/mesh";
  36554. /**
  36555. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36556. */
  36557. export class FadeInOutBehavior implements Behavior<Mesh> {
  36558. /**
  36559. * Time in milliseconds to delay before fading in (Default: 0)
  36560. */
  36561. delay: number;
  36562. /**
  36563. * Time in milliseconds for the mesh to fade in (Default: 300)
  36564. */
  36565. fadeInTime: number;
  36566. private _millisecondsPerFrame;
  36567. private _hovered;
  36568. private _hoverValue;
  36569. private _ownerNode;
  36570. /**
  36571. * Instatiates the FadeInOutBehavior
  36572. */
  36573. constructor();
  36574. /**
  36575. * The name of the behavior
  36576. */
  36577. readonly name: string;
  36578. /**
  36579. * Initializes the behavior
  36580. */
  36581. init(): void;
  36582. /**
  36583. * Attaches the fade behavior on the passed in mesh
  36584. * @param ownerNode The mesh that will be faded in/out once attached
  36585. */
  36586. attach(ownerNode: Mesh): void;
  36587. /**
  36588. * Detaches the behavior from the mesh
  36589. */
  36590. detach(): void;
  36591. /**
  36592. * Triggers the mesh to begin fading in or out
  36593. * @param value if the object should fade in or out (true to fade in)
  36594. */
  36595. fadeIn(value: boolean): void;
  36596. private _update;
  36597. private _setAllVisibility;
  36598. }
  36599. }
  36600. declare module "babylonjs/Misc/pivotTools" {
  36601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36602. /**
  36603. * Class containing a set of static utilities functions for managing Pivots
  36604. * @hidden
  36605. */
  36606. export class PivotTools {
  36607. private static _PivotCached;
  36608. private static _OldPivotPoint;
  36609. private static _PivotTranslation;
  36610. private static _PivotTmpVector;
  36611. /** @hidden */
  36612. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36613. /** @hidden */
  36614. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36615. }
  36616. }
  36617. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36618. import { Behavior } from "babylonjs/Behaviors/behavior";
  36619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36620. import { Observable } from "babylonjs/Misc/observable";
  36621. import { Vector3 } from "babylonjs/Maths/math";
  36622. import { Ray } from "babylonjs/Culling/ray";
  36623. /**
  36624. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36625. */
  36626. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36627. private static _AnyMouseID;
  36628. private _attachedNode;
  36629. private _dragPlane;
  36630. private _scene;
  36631. private _pointerObserver;
  36632. private _beforeRenderObserver;
  36633. private static _planeScene;
  36634. /**
  36635. * 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)
  36636. */
  36637. maxDragAngle: number;
  36638. /**
  36639. * @hidden
  36640. */
  36641. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36642. /**
  36643. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36644. */
  36645. currentDraggingPointerID: number;
  36646. /**
  36647. * The last position where the pointer hit the drag plane in world space
  36648. */
  36649. lastDragPosition: Vector3;
  36650. /**
  36651. * If the behavior is currently in a dragging state
  36652. */
  36653. dragging: boolean;
  36654. /**
  36655. * 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)
  36656. */
  36657. dragDeltaRatio: number;
  36658. /**
  36659. * If the drag plane orientation should be updated during the dragging (Default: true)
  36660. */
  36661. updateDragPlane: boolean;
  36662. private _debugMode;
  36663. private _moving;
  36664. /**
  36665. * Fires each time the attached mesh is dragged with the pointer
  36666. * * delta between last drag position and current drag position in world space
  36667. * * dragDistance along the drag axis
  36668. * * dragPlaneNormal normal of the current drag plane used during the drag
  36669. * * dragPlanePoint in world space where the drag intersects the drag plane
  36670. */
  36671. onDragObservable: Observable<{
  36672. delta: Vector3;
  36673. dragPlanePoint: Vector3;
  36674. dragPlaneNormal: Vector3;
  36675. dragDistance: number;
  36676. pointerId: number;
  36677. }>;
  36678. /**
  36679. * Fires each time a drag begins (eg. mouse down on mesh)
  36680. */
  36681. onDragStartObservable: Observable<{
  36682. dragPlanePoint: Vector3;
  36683. pointerId: number;
  36684. }>;
  36685. /**
  36686. * Fires each time a drag ends (eg. mouse release after drag)
  36687. */
  36688. onDragEndObservable: Observable<{
  36689. dragPlanePoint: Vector3;
  36690. pointerId: number;
  36691. }>;
  36692. /**
  36693. * If the attached mesh should be moved when dragged
  36694. */
  36695. moveAttached: boolean;
  36696. /**
  36697. * If the drag behavior will react to drag events (Default: true)
  36698. */
  36699. enabled: boolean;
  36700. /**
  36701. * If camera controls should be detached during the drag
  36702. */
  36703. detachCameraControls: boolean;
  36704. /**
  36705. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36706. */
  36707. useObjectOrienationForDragging: boolean;
  36708. private _options;
  36709. /**
  36710. * Creates a pointer drag behavior that can be attached to a mesh
  36711. * @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)
  36712. */
  36713. constructor(options?: {
  36714. dragAxis?: Vector3;
  36715. dragPlaneNormal?: Vector3;
  36716. });
  36717. /**
  36718. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36719. */
  36720. validateDrag: (targetPosition: Vector3) => boolean;
  36721. /**
  36722. * The name of the behavior
  36723. */
  36724. readonly name: string;
  36725. /**
  36726. * Initializes the behavior
  36727. */
  36728. init(): void;
  36729. private _tmpVector;
  36730. private _alternatePickedPoint;
  36731. private _worldDragAxis;
  36732. private _targetPosition;
  36733. private _attachedElement;
  36734. /**
  36735. * Attaches the drag behavior the passed in mesh
  36736. * @param ownerNode The mesh that will be dragged around once attached
  36737. */
  36738. attach(ownerNode: AbstractMesh): void;
  36739. /**
  36740. * Force relase the drag action by code.
  36741. */
  36742. releaseDrag(): void;
  36743. private _startDragRay;
  36744. private _lastPointerRay;
  36745. /**
  36746. * Simulates the start of a pointer drag event on the behavior
  36747. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36748. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36749. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36750. */
  36751. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36752. private _startDrag;
  36753. private _dragDelta;
  36754. private _moveDrag;
  36755. private _pickWithRayOnDragPlane;
  36756. private _pointA;
  36757. private _pointB;
  36758. private _pointC;
  36759. private _lineA;
  36760. private _lineB;
  36761. private _localAxis;
  36762. private _lookAt;
  36763. private _updateDragPlanePosition;
  36764. /**
  36765. * Detaches the behavior from the mesh
  36766. */
  36767. detach(): void;
  36768. }
  36769. }
  36770. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36771. import { Mesh } from "babylonjs/Meshes/mesh";
  36772. import { Behavior } from "babylonjs/Behaviors/behavior";
  36773. /**
  36774. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36775. */
  36776. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36777. private _dragBehaviorA;
  36778. private _dragBehaviorB;
  36779. private _startDistance;
  36780. private _initialScale;
  36781. private _targetScale;
  36782. private _ownerNode;
  36783. private _sceneRenderObserver;
  36784. /**
  36785. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36786. */
  36787. constructor();
  36788. /**
  36789. * The name of the behavior
  36790. */
  36791. readonly name: string;
  36792. /**
  36793. * Initializes the behavior
  36794. */
  36795. init(): void;
  36796. private _getCurrentDistance;
  36797. /**
  36798. * Attaches the scale behavior the passed in mesh
  36799. * @param ownerNode The mesh that will be scaled around once attached
  36800. */
  36801. attach(ownerNode: Mesh): void;
  36802. /**
  36803. * Detaches the behavior from the mesh
  36804. */
  36805. detach(): void;
  36806. }
  36807. }
  36808. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36809. import { Behavior } from "babylonjs/Behaviors/behavior";
  36810. import { Mesh } from "babylonjs/Meshes/mesh";
  36811. import { Observable } from "babylonjs/Misc/observable";
  36812. /**
  36813. * 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
  36814. */
  36815. export class SixDofDragBehavior implements Behavior<Mesh> {
  36816. private static _virtualScene;
  36817. private _ownerNode;
  36818. private _sceneRenderObserver;
  36819. private _scene;
  36820. private _targetPosition;
  36821. private _virtualOriginMesh;
  36822. private _virtualDragMesh;
  36823. private _pointerObserver;
  36824. private _moving;
  36825. private _startingOrientation;
  36826. /**
  36827. * 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)
  36828. */
  36829. private zDragFactor;
  36830. /**
  36831. * If the object should rotate to face the drag origin
  36832. */
  36833. rotateDraggedObject: boolean;
  36834. /**
  36835. * If the behavior is currently in a dragging state
  36836. */
  36837. dragging: boolean;
  36838. /**
  36839. * 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)
  36840. */
  36841. dragDeltaRatio: number;
  36842. /**
  36843. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36844. */
  36845. currentDraggingPointerID: number;
  36846. /**
  36847. * If camera controls should be detached during the drag
  36848. */
  36849. detachCameraControls: boolean;
  36850. /**
  36851. * Fires each time a drag starts
  36852. */
  36853. onDragStartObservable: Observable<{}>;
  36854. /**
  36855. * Fires each time a drag ends (eg. mouse release after drag)
  36856. */
  36857. onDragEndObservable: Observable<{}>;
  36858. /**
  36859. * 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
  36860. */
  36861. constructor();
  36862. /**
  36863. * The name of the behavior
  36864. */
  36865. readonly name: string;
  36866. /**
  36867. * Initializes the behavior
  36868. */
  36869. init(): void;
  36870. /**
  36871. * Attaches the scale behavior the passed in mesh
  36872. * @param ownerNode The mesh that will be scaled around once attached
  36873. */
  36874. attach(ownerNode: Mesh): void;
  36875. /**
  36876. * Detaches the behavior from the mesh
  36877. */
  36878. detach(): void;
  36879. }
  36880. }
  36881. declare module "babylonjs/Behaviors/Meshes/index" {
  36882. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36883. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36884. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36885. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36886. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36887. }
  36888. declare module "babylonjs/Behaviors/index" {
  36889. export * from "babylonjs/Behaviors/behavior";
  36890. export * from "babylonjs/Behaviors/Cameras/index";
  36891. export * from "babylonjs/Behaviors/Meshes/index";
  36892. }
  36893. declare module "babylonjs/Bones/boneIKController" {
  36894. import { Bone } from "babylonjs/Bones/bone";
  36895. import { Vector3 } from "babylonjs/Maths/math";
  36896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36897. import { Nullable } from "babylonjs/types";
  36898. /**
  36899. * Class used to apply inverse kinematics to bones
  36900. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36901. */
  36902. export class BoneIKController {
  36903. private static _tmpVecs;
  36904. private static _tmpQuat;
  36905. private static _tmpMats;
  36906. /**
  36907. * Gets or sets the target mesh
  36908. */
  36909. targetMesh: AbstractMesh;
  36910. /** Gets or sets the mesh used as pole */
  36911. poleTargetMesh: AbstractMesh;
  36912. /**
  36913. * Gets or sets the bone used as pole
  36914. */
  36915. poleTargetBone: Nullable<Bone>;
  36916. /**
  36917. * Gets or sets the target position
  36918. */
  36919. targetPosition: Vector3;
  36920. /**
  36921. * Gets or sets the pole target position
  36922. */
  36923. poleTargetPosition: Vector3;
  36924. /**
  36925. * Gets or sets the pole target local offset
  36926. */
  36927. poleTargetLocalOffset: Vector3;
  36928. /**
  36929. * Gets or sets the pole angle
  36930. */
  36931. poleAngle: number;
  36932. /**
  36933. * Gets or sets the mesh associated with the controller
  36934. */
  36935. mesh: AbstractMesh;
  36936. /**
  36937. * 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)
  36938. */
  36939. slerpAmount: number;
  36940. private _bone1Quat;
  36941. private _bone1Mat;
  36942. private _bone2Ang;
  36943. private _bone1;
  36944. private _bone2;
  36945. private _bone1Length;
  36946. private _bone2Length;
  36947. private _maxAngle;
  36948. private _maxReach;
  36949. private _rightHandedSystem;
  36950. private _bendAxis;
  36951. private _slerping;
  36952. private _adjustRoll;
  36953. /**
  36954. * Gets or sets maximum allowed angle
  36955. */
  36956. maxAngle: number;
  36957. /**
  36958. * Creates a new BoneIKController
  36959. * @param mesh defines the mesh to control
  36960. * @param bone defines the bone to control
  36961. * @param options defines options to set up the controller
  36962. */
  36963. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36964. targetMesh?: AbstractMesh;
  36965. poleTargetMesh?: AbstractMesh;
  36966. poleTargetBone?: Bone;
  36967. poleTargetLocalOffset?: Vector3;
  36968. poleAngle?: number;
  36969. bendAxis?: Vector3;
  36970. maxAngle?: number;
  36971. slerpAmount?: number;
  36972. });
  36973. private _setMaxAngle;
  36974. /**
  36975. * Force the controller to update the bones
  36976. */
  36977. update(): void;
  36978. }
  36979. }
  36980. declare module "babylonjs/Bones/boneLookController" {
  36981. import { Vector3, Space } from "babylonjs/Maths/math";
  36982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36983. import { Bone } from "babylonjs/Bones/bone";
  36984. /**
  36985. * Class used to make a bone look toward a point in space
  36986. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36987. */
  36988. export class BoneLookController {
  36989. private static _tmpVecs;
  36990. private static _tmpQuat;
  36991. private static _tmpMats;
  36992. /**
  36993. * The target Vector3 that the bone will look at
  36994. */
  36995. target: Vector3;
  36996. /**
  36997. * The mesh that the bone is attached to
  36998. */
  36999. mesh: AbstractMesh;
  37000. /**
  37001. * The bone that will be looking to the target
  37002. */
  37003. bone: Bone;
  37004. /**
  37005. * The up axis of the coordinate system that is used when the bone is rotated
  37006. */
  37007. upAxis: Vector3;
  37008. /**
  37009. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37010. */
  37011. upAxisSpace: Space;
  37012. /**
  37013. * Used to make an adjustment to the yaw of the bone
  37014. */
  37015. adjustYaw: number;
  37016. /**
  37017. * Used to make an adjustment to the pitch of the bone
  37018. */
  37019. adjustPitch: number;
  37020. /**
  37021. * Used to make an adjustment to the roll of the bone
  37022. */
  37023. adjustRoll: number;
  37024. /**
  37025. * 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)
  37026. */
  37027. slerpAmount: number;
  37028. private _minYaw;
  37029. private _maxYaw;
  37030. private _minPitch;
  37031. private _maxPitch;
  37032. private _minYawSin;
  37033. private _minYawCos;
  37034. private _maxYawSin;
  37035. private _maxYawCos;
  37036. private _midYawConstraint;
  37037. private _minPitchTan;
  37038. private _maxPitchTan;
  37039. private _boneQuat;
  37040. private _slerping;
  37041. private _transformYawPitch;
  37042. private _transformYawPitchInv;
  37043. private _firstFrameSkipped;
  37044. private _yawRange;
  37045. private _fowardAxis;
  37046. /**
  37047. * Gets or sets the minimum yaw angle that the bone can look to
  37048. */
  37049. minYaw: number;
  37050. /**
  37051. * Gets or sets the maximum yaw angle that the bone can look to
  37052. */
  37053. maxYaw: number;
  37054. /**
  37055. * Gets or sets the minimum pitch angle that the bone can look to
  37056. */
  37057. minPitch: number;
  37058. /**
  37059. * Gets or sets the maximum pitch angle that the bone can look to
  37060. */
  37061. maxPitch: number;
  37062. /**
  37063. * Create a BoneLookController
  37064. * @param mesh the mesh that the bone belongs to
  37065. * @param bone the bone that will be looking to the target
  37066. * @param target the target Vector3 to look at
  37067. * @param settings optional settings:
  37068. * * maxYaw: the maximum angle the bone will yaw to
  37069. * * minYaw: the minimum angle the bone will yaw to
  37070. * * maxPitch: the maximum angle the bone will pitch to
  37071. * * minPitch: the minimum angle the bone will yaw to
  37072. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37073. * * upAxis: the up axis of the coordinate system
  37074. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37075. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37076. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37077. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37078. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37079. * * adjustRoll: used to make an adjustment to the roll of the bone
  37080. **/
  37081. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37082. maxYaw?: number;
  37083. minYaw?: number;
  37084. maxPitch?: number;
  37085. minPitch?: number;
  37086. slerpAmount?: number;
  37087. upAxis?: Vector3;
  37088. upAxisSpace?: Space;
  37089. yawAxis?: Vector3;
  37090. pitchAxis?: Vector3;
  37091. adjustYaw?: number;
  37092. adjustPitch?: number;
  37093. adjustRoll?: number;
  37094. });
  37095. /**
  37096. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37097. */
  37098. update(): void;
  37099. private _getAngleDiff;
  37100. private _getAngleBetween;
  37101. private _isAngleBetween;
  37102. }
  37103. }
  37104. declare module "babylonjs/Bones/index" {
  37105. export * from "babylonjs/Bones/bone";
  37106. export * from "babylonjs/Bones/boneIKController";
  37107. export * from "babylonjs/Bones/boneLookController";
  37108. export * from "babylonjs/Bones/skeleton";
  37109. }
  37110. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37111. import { Nullable } from "babylonjs/types";
  37112. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37114. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37115. /**
  37116. * Manage the gamepad inputs to control an arc rotate camera.
  37117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37118. */
  37119. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37120. /**
  37121. * Defines the camera the input is attached to.
  37122. */
  37123. camera: ArcRotateCamera;
  37124. /**
  37125. * Defines the gamepad the input is gathering event from.
  37126. */
  37127. gamepad: Nullable<Gamepad>;
  37128. /**
  37129. * Defines the gamepad rotation sensiblity.
  37130. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37131. */
  37132. gamepadRotationSensibility: number;
  37133. /**
  37134. * Defines the gamepad move sensiblity.
  37135. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37136. */
  37137. gamepadMoveSensibility: number;
  37138. private _onGamepadConnectedObserver;
  37139. private _onGamepadDisconnectedObserver;
  37140. /**
  37141. * Attach the input controls to a specific dom element to get the input from.
  37142. * @param element Defines the element the controls should be listened from
  37143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37144. */
  37145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37146. /**
  37147. * Detach the current controls from the specified dom element.
  37148. * @param element Defines the element to stop listening the inputs from
  37149. */
  37150. detachControl(element: Nullable<HTMLElement>): void;
  37151. /**
  37152. * Update the current camera state depending on the inputs that have been used this frame.
  37153. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37154. */
  37155. checkInputs(): void;
  37156. /**
  37157. * Gets the class name of the current intput.
  37158. * @returns the class name
  37159. */
  37160. getClassName(): string;
  37161. /**
  37162. * Get the friendly name associated with the input class.
  37163. * @returns the input friendly name
  37164. */
  37165. getSimpleName(): string;
  37166. }
  37167. }
  37168. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37169. import { Nullable } from "babylonjs/types";
  37170. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37171. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37172. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37173. interface ArcRotateCameraInputsManager {
  37174. /**
  37175. * Add orientation input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37179. }
  37180. }
  37181. /**
  37182. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37184. */
  37185. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37186. /**
  37187. * Defines the camera the input is attached to.
  37188. */
  37189. camera: ArcRotateCamera;
  37190. /**
  37191. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37192. */
  37193. alphaCorrection: number;
  37194. /**
  37195. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37196. */
  37197. gammaCorrection: number;
  37198. private _alpha;
  37199. private _gamma;
  37200. private _dirty;
  37201. private _deviceOrientationHandler;
  37202. /**
  37203. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37204. */
  37205. constructor();
  37206. /**
  37207. * Attach the input controls to a specific dom element to get the input from.
  37208. * @param element Defines the element the controls should be listened from
  37209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37210. */
  37211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37212. /** @hidden */
  37213. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37214. /**
  37215. * Update the current camera state depending on the inputs that have been used this frame.
  37216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37217. */
  37218. checkInputs(): void;
  37219. /**
  37220. * Detach the current controls from the specified dom element.
  37221. * @param element Defines the element to stop listening the inputs from
  37222. */
  37223. detachControl(element: Nullable<HTMLElement>): void;
  37224. /**
  37225. * Gets the class name of the current intput.
  37226. * @returns the class name
  37227. */
  37228. getClassName(): string;
  37229. /**
  37230. * Get the friendly name associated with the input class.
  37231. * @returns the input friendly name
  37232. */
  37233. getSimpleName(): string;
  37234. }
  37235. }
  37236. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37237. import { Nullable } from "babylonjs/types";
  37238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37239. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37240. /**
  37241. * Listen to mouse events to control the camera.
  37242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37243. */
  37244. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37245. /**
  37246. * Defines the camera the input is attached to.
  37247. */
  37248. camera: FlyCamera;
  37249. /**
  37250. * Defines if touch is enabled. (Default is true.)
  37251. */
  37252. touchEnabled: boolean;
  37253. /**
  37254. * Defines the buttons associated with the input to handle camera rotation.
  37255. */
  37256. buttons: number[];
  37257. /**
  37258. * Assign buttons for Yaw control.
  37259. */
  37260. buttonsYaw: number[];
  37261. /**
  37262. * Assign buttons for Pitch control.
  37263. */
  37264. buttonsPitch: number[];
  37265. /**
  37266. * Assign buttons for Roll control.
  37267. */
  37268. buttonsRoll: number[];
  37269. /**
  37270. * Detect if any button is being pressed while mouse is moved.
  37271. * -1 = Mouse locked.
  37272. * 0 = Left button.
  37273. * 1 = Middle Button.
  37274. * 2 = Right Button.
  37275. */
  37276. activeButton: number;
  37277. /**
  37278. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37279. * Higher values reduce its sensitivity.
  37280. */
  37281. angularSensibility: number;
  37282. private _mousemoveCallback;
  37283. private _observer;
  37284. private _rollObserver;
  37285. private previousPosition;
  37286. private noPreventDefault;
  37287. private element;
  37288. /**
  37289. * Listen to mouse events to control the camera.
  37290. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37292. */
  37293. constructor(touchEnabled?: boolean);
  37294. /**
  37295. * Attach the mouse control to the HTML DOM element.
  37296. * @param element Defines the element that listens to the input events.
  37297. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37298. */
  37299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37300. /**
  37301. * Detach the current controls from the specified dom element.
  37302. * @param element Defines the element to stop listening the inputs from
  37303. */
  37304. detachControl(element: Nullable<HTMLElement>): void;
  37305. /**
  37306. * Gets the class name of the current input.
  37307. * @returns the class name.
  37308. */
  37309. getClassName(): string;
  37310. /**
  37311. * Get the friendly name associated with the input class.
  37312. * @returns the input's friendly name.
  37313. */
  37314. getSimpleName(): string;
  37315. private _pointerInput;
  37316. private _onMouseMove;
  37317. /**
  37318. * Rotate camera by mouse offset.
  37319. */
  37320. private rotateCamera;
  37321. }
  37322. }
  37323. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37324. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37325. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37326. /**
  37327. * Default Inputs manager for the FlyCamera.
  37328. * It groups all the default supported inputs for ease of use.
  37329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37330. */
  37331. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37332. /**
  37333. * Instantiates a new FlyCameraInputsManager.
  37334. * @param camera Defines the camera the inputs belong to.
  37335. */
  37336. constructor(camera: FlyCamera);
  37337. /**
  37338. * Add keyboard input support to the input manager.
  37339. * @returns the new FlyCameraKeyboardMoveInput().
  37340. */
  37341. addKeyboard(): FlyCameraInputsManager;
  37342. /**
  37343. * Add mouse input support to the input manager.
  37344. * @param touchEnabled Enable touch screen support.
  37345. * @returns the new FlyCameraMouseInput().
  37346. */
  37347. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37348. }
  37349. }
  37350. declare module "babylonjs/Cameras/flyCamera" {
  37351. import { Scene } from "babylonjs/scene";
  37352. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37354. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37355. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37356. /**
  37357. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37358. * such as in a 3D Space Shooter or a Flight Simulator.
  37359. */
  37360. export class FlyCamera extends TargetCamera {
  37361. /**
  37362. * Define the collision ellipsoid of the camera.
  37363. * This is helpful for simulating a camera body, like a player's body.
  37364. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37365. */
  37366. ellipsoid: Vector3;
  37367. /**
  37368. * Define an offset for the position of the ellipsoid around the camera.
  37369. * This can be helpful if the camera is attached away from the player's body center,
  37370. * such as at its head.
  37371. */
  37372. ellipsoidOffset: Vector3;
  37373. /**
  37374. * Enable or disable collisions of the camera with the rest of the scene objects.
  37375. */
  37376. checkCollisions: boolean;
  37377. /**
  37378. * Enable or disable gravity on the camera.
  37379. */
  37380. applyGravity: boolean;
  37381. /**
  37382. * Define the current direction the camera is moving to.
  37383. */
  37384. cameraDirection: Vector3;
  37385. /**
  37386. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37387. * This overrides and empties cameraRotation.
  37388. */
  37389. rotationQuaternion: Quaternion;
  37390. /**
  37391. * Track Roll to maintain the wanted Rolling when looking around.
  37392. */
  37393. _trackRoll: number;
  37394. /**
  37395. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37396. */
  37397. rollCorrect: number;
  37398. /**
  37399. * Mimic a banked turn, Rolling the camera when Yawing.
  37400. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37401. */
  37402. bankedTurn: boolean;
  37403. /**
  37404. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37405. */
  37406. bankedTurnLimit: number;
  37407. /**
  37408. * Value of 0 disables the banked Roll.
  37409. * Value of 1 is equal to the Yaw angle in radians.
  37410. */
  37411. bankedTurnMultiplier: number;
  37412. /**
  37413. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37414. */
  37415. inputs: FlyCameraInputsManager;
  37416. /**
  37417. * Gets the input sensibility for mouse input.
  37418. * Higher values reduce sensitivity.
  37419. */
  37420. /**
  37421. * Sets the input sensibility for a mouse input.
  37422. * Higher values reduce sensitivity.
  37423. */
  37424. angularSensibility: number;
  37425. /**
  37426. * Get the keys for camera movement forward.
  37427. */
  37428. /**
  37429. * Set the keys for camera movement forward.
  37430. */
  37431. keysForward: number[];
  37432. /**
  37433. * Get the keys for camera movement backward.
  37434. */
  37435. keysBackward: number[];
  37436. /**
  37437. * Get the keys for camera movement up.
  37438. */
  37439. /**
  37440. * Set the keys for camera movement up.
  37441. */
  37442. keysUp: number[];
  37443. /**
  37444. * Get the keys for camera movement down.
  37445. */
  37446. /**
  37447. * Set the keys for camera movement down.
  37448. */
  37449. keysDown: number[];
  37450. /**
  37451. * Get the keys for camera movement left.
  37452. */
  37453. /**
  37454. * Set the keys for camera movement left.
  37455. */
  37456. keysLeft: number[];
  37457. /**
  37458. * Set the keys for camera movement right.
  37459. */
  37460. /**
  37461. * Set the keys for camera movement right.
  37462. */
  37463. keysRight: number[];
  37464. /**
  37465. * Event raised when the camera collides with a mesh in the scene.
  37466. */
  37467. onCollide: (collidedMesh: AbstractMesh) => void;
  37468. private _collider;
  37469. private _needMoveForGravity;
  37470. private _oldPosition;
  37471. private _diffPosition;
  37472. private _newPosition;
  37473. /** @hidden */
  37474. _localDirection: Vector3;
  37475. /** @hidden */
  37476. _transformedDirection: Vector3;
  37477. /**
  37478. * Instantiates a FlyCamera.
  37479. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37480. * such as in a 3D Space Shooter or a Flight Simulator.
  37481. * @param name Define the name of the camera in the scene.
  37482. * @param position Define the starting position of the camera in the scene.
  37483. * @param scene Define the scene the camera belongs to.
  37484. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37485. */
  37486. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37487. /**
  37488. * Attach a control to the HTML DOM element.
  37489. * @param element Defines the element that listens to the input events.
  37490. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37491. */
  37492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37493. /**
  37494. * Detach a control from the HTML DOM element.
  37495. * The camera will stop reacting to that input.
  37496. * @param element Defines the element that listens to the input events.
  37497. */
  37498. detachControl(element: HTMLElement): void;
  37499. private _collisionMask;
  37500. /**
  37501. * Get the mask that the camera ignores in collision events.
  37502. */
  37503. /**
  37504. * Set the mask that the camera ignores in collision events.
  37505. */
  37506. collisionMask: number;
  37507. /** @hidden */
  37508. _collideWithWorld(displacement: Vector3): void;
  37509. /** @hidden */
  37510. private _onCollisionPositionChange;
  37511. /** @hidden */
  37512. _checkInputs(): void;
  37513. /** @hidden */
  37514. _decideIfNeedsToMove(): boolean;
  37515. /** @hidden */
  37516. _updatePosition(): void;
  37517. /**
  37518. * Restore the Roll to its target value at the rate specified.
  37519. * @param rate - Higher means slower restoring.
  37520. * @hidden
  37521. */
  37522. restoreRoll(rate: number): void;
  37523. /**
  37524. * Destroy the camera and release the current resources held by it.
  37525. */
  37526. dispose(): void;
  37527. /**
  37528. * Get the current object class name.
  37529. * @returns the class name.
  37530. */
  37531. getClassName(): string;
  37532. }
  37533. }
  37534. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37535. import { Nullable } from "babylonjs/types";
  37536. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37537. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37538. /**
  37539. * Listen to keyboard events to control the camera.
  37540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37541. */
  37542. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37543. /**
  37544. * Defines the camera the input is attached to.
  37545. */
  37546. camera: FlyCamera;
  37547. /**
  37548. * The list of keyboard keys used to control the forward move of the camera.
  37549. */
  37550. keysForward: number[];
  37551. /**
  37552. * The list of keyboard keys used to control the backward move of the camera.
  37553. */
  37554. keysBackward: number[];
  37555. /**
  37556. * The list of keyboard keys used to control the forward move of the camera.
  37557. */
  37558. keysUp: number[];
  37559. /**
  37560. * The list of keyboard keys used to control the backward move of the camera.
  37561. */
  37562. keysDown: number[];
  37563. /**
  37564. * The list of keyboard keys used to control the right strafe move of the camera.
  37565. */
  37566. keysRight: number[];
  37567. /**
  37568. * The list of keyboard keys used to control the left strafe move of the camera.
  37569. */
  37570. keysLeft: number[];
  37571. private _keys;
  37572. private _onCanvasBlurObserver;
  37573. private _onKeyboardObserver;
  37574. private _engine;
  37575. private _scene;
  37576. /**
  37577. * Attach the input controls to a specific dom element to get the input from.
  37578. * @param element Defines the element the controls should be listened from
  37579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37580. */
  37581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37582. /**
  37583. * Detach the current controls from the specified dom element.
  37584. * @param element Defines the element to stop listening the inputs from
  37585. */
  37586. detachControl(element: Nullable<HTMLElement>): void;
  37587. /**
  37588. * Gets the class name of the current intput.
  37589. * @returns the class name
  37590. */
  37591. getClassName(): string;
  37592. /** @hidden */
  37593. _onLostFocus(e: FocusEvent): void;
  37594. /**
  37595. * Get the friendly name associated with the input class.
  37596. * @returns the input friendly name
  37597. */
  37598. getSimpleName(): string;
  37599. /**
  37600. * Update the current camera state depending on the inputs that have been used this frame.
  37601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37602. */
  37603. checkInputs(): void;
  37604. }
  37605. }
  37606. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37607. import { Nullable } from "babylonjs/types";
  37608. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37609. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37610. module "babylonjs/Cameras/freeCameraInputsManager" {
  37611. interface FreeCameraInputsManager {
  37612. /**
  37613. * Add orientation input support to the input manager.
  37614. * @returns the current input manager
  37615. */
  37616. addDeviceOrientation(): FreeCameraInputsManager;
  37617. }
  37618. }
  37619. /**
  37620. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37621. * Screen rotation is taken into account.
  37622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37623. */
  37624. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37625. private _camera;
  37626. private _screenOrientationAngle;
  37627. private _constantTranform;
  37628. private _screenQuaternion;
  37629. private _alpha;
  37630. private _beta;
  37631. private _gamma;
  37632. /**
  37633. * Instantiates a new input
  37634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37635. */
  37636. constructor();
  37637. /**
  37638. * Define the camera controlled by the input.
  37639. */
  37640. camera: FreeCamera;
  37641. /**
  37642. * Attach the input controls to a specific dom element to get the input from.
  37643. * @param element Defines the element the controls should be listened from
  37644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37645. */
  37646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37647. private _orientationChanged;
  37648. private _deviceOrientation;
  37649. /**
  37650. * Detach the current controls from the specified dom element.
  37651. * @param element Defines the element to stop listening the inputs from
  37652. */
  37653. detachControl(element: Nullable<HTMLElement>): void;
  37654. /**
  37655. * Update the current camera state depending on the inputs that have been used this frame.
  37656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37657. */
  37658. checkInputs(): void;
  37659. /**
  37660. * Gets the class name of the current intput.
  37661. * @returns the class name
  37662. */
  37663. getClassName(): string;
  37664. /**
  37665. * Get the friendly name associated with the input class.
  37666. * @returns the input friendly name
  37667. */
  37668. getSimpleName(): string;
  37669. }
  37670. }
  37671. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37672. import { Nullable } from "babylonjs/types";
  37673. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37674. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37675. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37676. /**
  37677. * Manage the gamepad inputs to control a free camera.
  37678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37679. */
  37680. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37681. /**
  37682. * Define the camera the input is attached to.
  37683. */
  37684. camera: FreeCamera;
  37685. /**
  37686. * Define the Gamepad controlling the input
  37687. */
  37688. gamepad: Nullable<Gamepad>;
  37689. /**
  37690. * Defines the gamepad rotation sensiblity.
  37691. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37692. */
  37693. gamepadAngularSensibility: number;
  37694. /**
  37695. * Defines the gamepad move sensiblity.
  37696. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37697. */
  37698. gamepadMoveSensibility: number;
  37699. private _onGamepadConnectedObserver;
  37700. private _onGamepadDisconnectedObserver;
  37701. private _cameraTransform;
  37702. private _deltaTransform;
  37703. private _vector3;
  37704. private _vector2;
  37705. /**
  37706. * Attach the input controls to a specific dom element to get the input from.
  37707. * @param element Defines the element the controls should be listened from
  37708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37709. */
  37710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37711. /**
  37712. * Detach the current controls from the specified dom element.
  37713. * @param element Defines the element to stop listening the inputs from
  37714. */
  37715. detachControl(element: Nullable<HTMLElement>): void;
  37716. /**
  37717. * Update the current camera state depending on the inputs that have been used this frame.
  37718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37719. */
  37720. checkInputs(): void;
  37721. /**
  37722. * Gets the class name of the current intput.
  37723. * @returns the class name
  37724. */
  37725. getClassName(): string;
  37726. /**
  37727. * Get the friendly name associated with the input class.
  37728. * @returns the input friendly name
  37729. */
  37730. getSimpleName(): string;
  37731. }
  37732. }
  37733. declare module "babylonjs/Misc/virtualJoystick" {
  37734. import { Nullable } from "babylonjs/types";
  37735. import { Vector3 } from "babylonjs/Maths/math";
  37736. /**
  37737. * Defines the potential axis of a Joystick
  37738. */
  37739. export enum JoystickAxis {
  37740. /** X axis */
  37741. X = 0,
  37742. /** Y axis */
  37743. Y = 1,
  37744. /** Z axis */
  37745. Z = 2
  37746. }
  37747. /**
  37748. * Class used to define virtual joystick (used in touch mode)
  37749. */
  37750. export class VirtualJoystick {
  37751. /**
  37752. * Gets or sets a boolean indicating that left and right values must be inverted
  37753. */
  37754. reverseLeftRight: boolean;
  37755. /**
  37756. * Gets or sets a boolean indicating that up and down values must be inverted
  37757. */
  37758. reverseUpDown: boolean;
  37759. /**
  37760. * Gets the offset value for the position (ie. the change of the position value)
  37761. */
  37762. deltaPosition: Vector3;
  37763. /**
  37764. * Gets a boolean indicating if the virtual joystick was pressed
  37765. */
  37766. pressed: boolean;
  37767. /**
  37768. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37769. */
  37770. static Canvas: Nullable<HTMLCanvasElement>;
  37771. private static _globalJoystickIndex;
  37772. private static vjCanvasContext;
  37773. private static vjCanvasWidth;
  37774. private static vjCanvasHeight;
  37775. private static halfWidth;
  37776. private _action;
  37777. private _axisTargetedByLeftAndRight;
  37778. private _axisTargetedByUpAndDown;
  37779. private _joystickSensibility;
  37780. private _inversedSensibility;
  37781. private _joystickPointerID;
  37782. private _joystickColor;
  37783. private _joystickPointerPos;
  37784. private _joystickPreviousPointerPos;
  37785. private _joystickPointerStartPos;
  37786. private _deltaJoystickVector;
  37787. private _leftJoystick;
  37788. private _touches;
  37789. private _onPointerDownHandlerRef;
  37790. private _onPointerMoveHandlerRef;
  37791. private _onPointerUpHandlerRef;
  37792. private _onResize;
  37793. /**
  37794. * Creates a new virtual joystick
  37795. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37796. */
  37797. constructor(leftJoystick?: boolean);
  37798. /**
  37799. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37800. * @param newJoystickSensibility defines the new sensibility
  37801. */
  37802. setJoystickSensibility(newJoystickSensibility: number): void;
  37803. private _onPointerDown;
  37804. private _onPointerMove;
  37805. private _onPointerUp;
  37806. /**
  37807. * Change the color of the virtual joystick
  37808. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37809. */
  37810. setJoystickColor(newColor: string): void;
  37811. /**
  37812. * Defines a callback to call when the joystick is touched
  37813. * @param action defines the callback
  37814. */
  37815. setActionOnTouch(action: () => any): void;
  37816. /**
  37817. * Defines which axis you'd like to control for left & right
  37818. * @param axis defines the axis to use
  37819. */
  37820. setAxisForLeftRight(axis: JoystickAxis): void;
  37821. /**
  37822. * Defines which axis you'd like to control for up & down
  37823. * @param axis defines the axis to use
  37824. */
  37825. setAxisForUpDown(axis: JoystickAxis): void;
  37826. private _drawVirtualJoystick;
  37827. /**
  37828. * Release internal HTML canvas
  37829. */
  37830. releaseCanvas(): void;
  37831. }
  37832. }
  37833. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37834. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37835. import { Nullable } from "babylonjs/types";
  37836. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37837. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37838. module "babylonjs/Cameras/freeCameraInputsManager" {
  37839. interface FreeCameraInputsManager {
  37840. /**
  37841. * Add virtual joystick input support to the input manager.
  37842. * @returns the current input manager
  37843. */
  37844. addVirtualJoystick(): FreeCameraInputsManager;
  37845. }
  37846. }
  37847. /**
  37848. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37850. */
  37851. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37852. /**
  37853. * Defines the camera the input is attached to.
  37854. */
  37855. camera: FreeCamera;
  37856. private _leftjoystick;
  37857. private _rightjoystick;
  37858. /**
  37859. * Gets the left stick of the virtual joystick.
  37860. * @returns The virtual Joystick
  37861. */
  37862. getLeftJoystick(): VirtualJoystick;
  37863. /**
  37864. * Gets the right stick of the virtual joystick.
  37865. * @returns The virtual Joystick
  37866. */
  37867. getRightJoystick(): VirtualJoystick;
  37868. /**
  37869. * Update the current camera state depending on the inputs that have been used this frame.
  37870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37871. */
  37872. checkInputs(): void;
  37873. /**
  37874. * Attach the input controls to a specific dom element to get the input from.
  37875. * @param element Defines the element the controls should be listened from
  37876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37877. */
  37878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37879. /**
  37880. * Detach the current controls from the specified dom element.
  37881. * @param element Defines the element to stop listening the inputs from
  37882. */
  37883. detachControl(element: Nullable<HTMLElement>): void;
  37884. /**
  37885. * Gets the class name of the current intput.
  37886. * @returns the class name
  37887. */
  37888. getClassName(): string;
  37889. /**
  37890. * Get the friendly name associated with the input class.
  37891. * @returns the input friendly name
  37892. */
  37893. getSimpleName(): string;
  37894. }
  37895. }
  37896. declare module "babylonjs/Cameras/Inputs/index" {
  37897. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37898. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37899. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37900. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37901. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37902. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37903. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37904. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37905. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37906. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37907. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37908. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37909. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37910. }
  37911. declare module "babylonjs/Cameras/touchCamera" {
  37912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37913. import { Scene } from "babylonjs/scene";
  37914. import { Vector3 } from "babylonjs/Maths/math";
  37915. /**
  37916. * This represents a FPS type of camera controlled by touch.
  37917. * This is like a universal camera minus the Gamepad controls.
  37918. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37919. */
  37920. export class TouchCamera extends FreeCamera {
  37921. /**
  37922. * Defines the touch sensibility for rotation.
  37923. * The higher the faster.
  37924. */
  37925. touchAngularSensibility: number;
  37926. /**
  37927. * Defines the touch sensibility for move.
  37928. * The higher the faster.
  37929. */
  37930. touchMoveSensibility: number;
  37931. /**
  37932. * Instantiates a new touch camera.
  37933. * This represents a FPS type of camera controlled by touch.
  37934. * This is like a universal camera minus the Gamepad controls.
  37935. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37936. * @param name Define the name of the camera in the scene
  37937. * @param position Define the start position of the camera in the scene
  37938. * @param scene Define the scene the camera belongs to
  37939. */
  37940. constructor(name: string, position: Vector3, scene: Scene);
  37941. /**
  37942. * Gets the current object class name.
  37943. * @return the class name
  37944. */
  37945. getClassName(): string;
  37946. /** @hidden */
  37947. _setupInputs(): void;
  37948. }
  37949. }
  37950. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37952. import { Scene } from "babylonjs/scene";
  37953. import { Vector3, Axis } from "babylonjs/Maths/math";
  37954. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37955. /**
  37956. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37957. * being tilted forward or back and left or right.
  37958. */
  37959. export class DeviceOrientationCamera extends FreeCamera {
  37960. private _initialQuaternion;
  37961. private _quaternionCache;
  37962. /**
  37963. * Creates a new device orientation camera
  37964. * @param name The name of the camera
  37965. * @param position The start position camera
  37966. * @param scene The scene the camera belongs to
  37967. */
  37968. constructor(name: string, position: Vector3, scene: Scene);
  37969. /**
  37970. * Gets the current instance class name ("DeviceOrientationCamera").
  37971. * This helps avoiding instanceof at run time.
  37972. * @returns the class name
  37973. */
  37974. getClassName(): string;
  37975. /**
  37976. * @hidden
  37977. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37978. */
  37979. _checkInputs(): void;
  37980. /**
  37981. * Reset the camera to its default orientation on the specified axis only.
  37982. * @param axis The axis to reset
  37983. */
  37984. resetToCurrentRotation(axis?: Axis): void;
  37985. }
  37986. }
  37987. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37988. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37989. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37990. import { Nullable } from "babylonjs/types";
  37991. /**
  37992. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37994. */
  37995. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37996. /**
  37997. * Defines the camera the input is attached to.
  37998. */
  37999. camera: FollowCamera;
  38000. /**
  38001. * Defines the list of key codes associated with the up action (increase heightOffset)
  38002. */
  38003. keysUp: number[];
  38004. /**
  38005. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38006. */
  38007. keysDown: number[];
  38008. /**
  38009. * Defines the list of key codes associated with the left action (increase rotation)
  38010. */
  38011. keysLeft: number[];
  38012. /**
  38013. * Defines the list of key codes associated with the right action (decrease rotation)
  38014. */
  38015. keysRight: number[];
  38016. /**
  38017. * Defines the rate of change of heightOffset.
  38018. */
  38019. heightSensibility: number;
  38020. /**
  38021. * Defines the rate of change of rotationOffset.
  38022. */
  38023. rotationSensibility: number;
  38024. /**
  38025. * Defines the rate of change of radius.
  38026. */
  38027. radiusSensibility: number;
  38028. /**
  38029. * Defines the minimum heightOffset value.
  38030. */
  38031. minHeightOffset: number;
  38032. /**
  38033. * Defines the minimum radius value.
  38034. */
  38035. minRadius: number;
  38036. private _keys;
  38037. private _altPressed;
  38038. private _onCanvasBlurObserver;
  38039. private _onKeyboardObserver;
  38040. private _engine;
  38041. private _scene;
  38042. /**
  38043. * Attach the input controls to a specific dom element to get the input from.
  38044. * @param element Defines the element the controls should be listened from
  38045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38046. */
  38047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38048. /**
  38049. * Detach the current controls from the specified dom element.
  38050. * @param element Defines the element to stop listening the inputs from
  38051. */
  38052. detachControl(element: Nullable<HTMLElement>): void;
  38053. /**
  38054. * Update the current camera state depending on the inputs that have been used this frame.
  38055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38056. */
  38057. checkInputs(): void;
  38058. /**
  38059. * Gets the class name of the current intput.
  38060. * @returns the class name
  38061. */
  38062. getClassName(): string;
  38063. /**
  38064. * Get the friendly name associated with the input class.
  38065. * @returns the input friendly name
  38066. */
  38067. getSimpleName(): string;
  38068. }
  38069. }
  38070. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38071. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38072. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38073. /**
  38074. * Default Inputs manager for the FollowCamera.
  38075. * It groups all the default supported inputs for ease of use.
  38076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38077. */
  38078. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38079. /**
  38080. * Instantiates a new FollowCameraInputsManager.
  38081. * @param camera Defines the camera the inputs belong to
  38082. */
  38083. constructor(camera: FollowCamera);
  38084. /**
  38085. * Add keyboard input support to the input manager.
  38086. * @returns the current input manager
  38087. */
  38088. addKeyboard(): FollowCameraInputsManager;
  38089. /**
  38090. * Add mouse wheel input support to the input manager.
  38091. * @returns the current input manager
  38092. */
  38093. addMouseWheel(): FollowCameraInputsManager;
  38094. /**
  38095. * Add pointers input support to the input manager.
  38096. * @returns the current input manager
  38097. */
  38098. addPointers(): FollowCameraInputsManager;
  38099. /**
  38100. * Add orientation input support to the input manager.
  38101. * @returns the current input manager
  38102. */
  38103. addVRDeviceOrientation(): FollowCameraInputsManager;
  38104. }
  38105. }
  38106. declare module "babylonjs/Cameras/followCamera" {
  38107. import { Nullable } from "babylonjs/types";
  38108. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38109. import { Scene } from "babylonjs/scene";
  38110. import { Vector3 } from "babylonjs/Maths/math";
  38111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38112. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38113. /**
  38114. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38115. * an arc rotate version arcFollowCamera are available.
  38116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38117. */
  38118. export class FollowCamera extends TargetCamera {
  38119. /**
  38120. * Distance the follow camera should follow an object at
  38121. */
  38122. radius: number;
  38123. /**
  38124. * Define a rotation offset between the camera and the object it follows
  38125. */
  38126. rotationOffset: number;
  38127. /**
  38128. * Define a height offset between the camera and the object it follows.
  38129. * It can help following an object from the top (like a car chaing a plane)
  38130. */
  38131. heightOffset: number;
  38132. /**
  38133. * Define how fast the camera can accelerate to follow it s target.
  38134. */
  38135. cameraAcceleration: number;
  38136. /**
  38137. * Define the speed limit of the camera following an object.
  38138. */
  38139. maxCameraSpeed: number;
  38140. /**
  38141. * Define the target of the camera.
  38142. */
  38143. lockedTarget: Nullable<AbstractMesh>;
  38144. /**
  38145. * Defines the input associated with the camera.
  38146. */
  38147. inputs: FollowCameraInputsManager;
  38148. /**
  38149. * Instantiates the follow camera.
  38150. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38151. * @param name Define the name of the camera in the scene
  38152. * @param position Define the position of the camera
  38153. * @param scene Define the scene the camera belong to
  38154. * @param lockedTarget Define the target of the camera
  38155. */
  38156. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38157. private _follow;
  38158. /**
  38159. * Attached controls to the current camera.
  38160. * @param element Defines the element the controls should be listened from
  38161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38162. */
  38163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38164. /**
  38165. * Detach the current controls from the camera.
  38166. * The camera will stop reacting to inputs.
  38167. * @param element Defines the element to stop listening the inputs from
  38168. */
  38169. detachControl(element: HTMLElement): void;
  38170. /** @hidden */
  38171. _checkInputs(): void;
  38172. /**
  38173. * Gets the camera class name.
  38174. * @returns the class name
  38175. */
  38176. getClassName(): string;
  38177. }
  38178. /**
  38179. * Arc Rotate version of the follow camera.
  38180. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38181. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38182. */
  38183. export class ArcFollowCamera extends TargetCamera {
  38184. /** The longitudinal angle of the camera */
  38185. alpha: number;
  38186. /** The latitudinal angle of the camera */
  38187. beta: number;
  38188. /** The radius of the camera from its target */
  38189. radius: number;
  38190. /** Define the camera target (the messh it should follow) */
  38191. target: Nullable<AbstractMesh>;
  38192. private _cartesianCoordinates;
  38193. /**
  38194. * Instantiates a new ArcFollowCamera
  38195. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38196. * @param name Define the name of the camera
  38197. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38198. * @param beta Define the rotation angle of the camera around the elevation axis
  38199. * @param radius Define the radius of the camera from its target point
  38200. * @param target Define the target of the camera
  38201. * @param scene Define the scene the camera belongs to
  38202. */
  38203. constructor(name: string,
  38204. /** The longitudinal angle of the camera */
  38205. alpha: number,
  38206. /** The latitudinal angle of the camera */
  38207. beta: number,
  38208. /** The radius of the camera from its target */
  38209. radius: number,
  38210. /** Define the camera target (the messh it should follow) */
  38211. target: Nullable<AbstractMesh>, scene: Scene);
  38212. private _follow;
  38213. /** @hidden */
  38214. _checkInputs(): void;
  38215. /**
  38216. * Returns the class name of the object.
  38217. * It is mostly used internally for serialization purposes.
  38218. */
  38219. getClassName(): string;
  38220. }
  38221. }
  38222. declare module "babylonjs/Cameras/universalCamera" {
  38223. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38224. import { Scene } from "babylonjs/scene";
  38225. import { Vector3 } from "babylonjs/Maths/math";
  38226. /**
  38227. * 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,
  38228. * which still works and will still be found in many Playgrounds.
  38229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38230. */
  38231. export class UniversalCamera extends TouchCamera {
  38232. /**
  38233. * Defines the gamepad rotation sensiblity.
  38234. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38235. */
  38236. gamepadAngularSensibility: number;
  38237. /**
  38238. * Defines the gamepad move sensiblity.
  38239. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38240. */
  38241. gamepadMoveSensibility: number;
  38242. /**
  38243. * 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,
  38244. * which still works and will still be found in many Playgrounds.
  38245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38246. * @param name Define the name of the camera in the scene
  38247. * @param position Define the start position of the camera in the scene
  38248. * @param scene Define the scene the camera belongs to
  38249. */
  38250. constructor(name: string, position: Vector3, scene: Scene);
  38251. /**
  38252. * Gets the current object class name.
  38253. * @return the class name
  38254. */
  38255. getClassName(): string;
  38256. }
  38257. }
  38258. declare module "babylonjs/Cameras/gamepadCamera" {
  38259. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38260. import { Scene } from "babylonjs/scene";
  38261. import { Vector3 } from "babylonjs/Maths/math";
  38262. /**
  38263. * This represents a FPS type of camera. This is only here for back compat purpose.
  38264. * Please use the UniversalCamera instead as both are identical.
  38265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38266. */
  38267. export class GamepadCamera extends UniversalCamera {
  38268. /**
  38269. * Instantiates a new Gamepad Camera
  38270. * This represents a FPS type of camera. This is only here for back compat purpose.
  38271. * Please use the UniversalCamera instead as both are identical.
  38272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38273. * @param name Define the name of the camera in the scene
  38274. * @param position Define the start position of the camera in the scene
  38275. * @param scene Define the scene the camera belongs to
  38276. */
  38277. constructor(name: string, position: Vector3, scene: Scene);
  38278. /**
  38279. * Gets the current object class name.
  38280. * @return the class name
  38281. */
  38282. getClassName(): string;
  38283. }
  38284. }
  38285. declare module "babylonjs/Shaders/pass.fragment" {
  38286. /** @hidden */
  38287. export var passPixelShader: {
  38288. name: string;
  38289. shader: string;
  38290. };
  38291. }
  38292. declare module "babylonjs/Shaders/passCube.fragment" {
  38293. /** @hidden */
  38294. export var passCubePixelShader: {
  38295. name: string;
  38296. shader: string;
  38297. };
  38298. }
  38299. declare module "babylonjs/PostProcesses/passPostProcess" {
  38300. import { Nullable } from "babylonjs/types";
  38301. import { Camera } from "babylonjs/Cameras/camera";
  38302. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38303. import { Engine } from "babylonjs/Engines/engine";
  38304. import "babylonjs/Shaders/pass.fragment";
  38305. import "babylonjs/Shaders/passCube.fragment";
  38306. /**
  38307. * PassPostProcess which produces an output the same as it's input
  38308. */
  38309. export class PassPostProcess extends PostProcess {
  38310. /**
  38311. * Creates the PassPostProcess
  38312. * @param name The name of the effect.
  38313. * @param options The required width/height ratio to downsize to before computing the render pass.
  38314. * @param camera The camera to apply the render pass to.
  38315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38316. * @param engine The engine which the post process will be applied. (default: current engine)
  38317. * @param reusable If the post process can be reused on the same frame. (default: false)
  38318. * @param textureType The type of texture to be used when performing the post processing.
  38319. * @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)
  38320. */
  38321. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38322. }
  38323. /**
  38324. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38325. */
  38326. export class PassCubePostProcess extends PostProcess {
  38327. private _face;
  38328. /**
  38329. * Gets or sets the cube face to display.
  38330. * * 0 is +X
  38331. * * 1 is -X
  38332. * * 2 is +Y
  38333. * * 3 is -Y
  38334. * * 4 is +Z
  38335. * * 5 is -Z
  38336. */
  38337. face: number;
  38338. /**
  38339. * Creates the PassCubePostProcess
  38340. * @param name The name of the effect.
  38341. * @param options The required width/height ratio to downsize to before computing the render pass.
  38342. * @param camera The camera to apply the render pass to.
  38343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38344. * @param engine The engine which the post process will be applied. (default: current engine)
  38345. * @param reusable If the post process can be reused on the same frame. (default: false)
  38346. * @param textureType The type of texture to be used when performing the post processing.
  38347. * @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)
  38348. */
  38349. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38350. }
  38351. }
  38352. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38353. /** @hidden */
  38354. export var anaglyphPixelShader: {
  38355. name: string;
  38356. shader: string;
  38357. };
  38358. }
  38359. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38360. import { Engine } from "babylonjs/Engines/engine";
  38361. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38362. import { Camera } from "babylonjs/Cameras/camera";
  38363. import "babylonjs/Shaders/anaglyph.fragment";
  38364. /**
  38365. * Postprocess used to generate anaglyphic rendering
  38366. */
  38367. export class AnaglyphPostProcess extends PostProcess {
  38368. private _passedProcess;
  38369. /**
  38370. * Creates a new AnaglyphPostProcess
  38371. * @param name defines postprocess name
  38372. * @param options defines creation options or target ratio scale
  38373. * @param rigCameras defines cameras using this postprocess
  38374. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38375. * @param engine defines hosting engine
  38376. * @param reusable defines if the postprocess will be reused multiple times per frame
  38377. */
  38378. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38379. }
  38380. }
  38381. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38382. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38383. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38384. import { Scene } from "babylonjs/scene";
  38385. import { Vector3 } from "babylonjs/Maths/math";
  38386. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38387. /**
  38388. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38390. */
  38391. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38392. /**
  38393. * Creates a new AnaglyphArcRotateCamera
  38394. * @param name defines camera name
  38395. * @param alpha defines alpha angle (in radians)
  38396. * @param beta defines beta angle (in radians)
  38397. * @param radius defines radius
  38398. * @param target defines camera target
  38399. * @param interaxialDistance defines distance between each color axis
  38400. * @param scene defines the hosting scene
  38401. */
  38402. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38403. /**
  38404. * Gets camera class name
  38405. * @returns AnaglyphArcRotateCamera
  38406. */
  38407. getClassName(): string;
  38408. }
  38409. }
  38410. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38411. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38412. import { Scene } from "babylonjs/scene";
  38413. import { Vector3 } from "babylonjs/Maths/math";
  38414. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38415. /**
  38416. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38417. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38418. */
  38419. export class AnaglyphFreeCamera extends FreeCamera {
  38420. /**
  38421. * Creates a new AnaglyphFreeCamera
  38422. * @param name defines camera name
  38423. * @param position defines initial position
  38424. * @param interaxialDistance defines distance between each color axis
  38425. * @param scene defines the hosting scene
  38426. */
  38427. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38428. /**
  38429. * Gets camera class name
  38430. * @returns AnaglyphFreeCamera
  38431. */
  38432. getClassName(): string;
  38433. }
  38434. }
  38435. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38436. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38437. import { Scene } from "babylonjs/scene";
  38438. import { Vector3 } from "babylonjs/Maths/math";
  38439. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38440. /**
  38441. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38442. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38443. */
  38444. export class AnaglyphGamepadCamera extends GamepadCamera {
  38445. /**
  38446. * Creates a new AnaglyphGamepadCamera
  38447. * @param name defines camera name
  38448. * @param position defines initial position
  38449. * @param interaxialDistance defines distance between each color axis
  38450. * @param scene defines the hosting scene
  38451. */
  38452. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38453. /**
  38454. * Gets camera class name
  38455. * @returns AnaglyphGamepadCamera
  38456. */
  38457. getClassName(): string;
  38458. }
  38459. }
  38460. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38461. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38462. import { Scene } from "babylonjs/scene";
  38463. import { Vector3 } from "babylonjs/Maths/math";
  38464. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38465. /**
  38466. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38467. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38468. */
  38469. export class AnaglyphUniversalCamera extends UniversalCamera {
  38470. /**
  38471. * Creates a new AnaglyphUniversalCamera
  38472. * @param name defines camera name
  38473. * @param position defines initial position
  38474. * @param interaxialDistance defines distance between each color axis
  38475. * @param scene defines the hosting scene
  38476. */
  38477. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38478. /**
  38479. * Gets camera class name
  38480. * @returns AnaglyphUniversalCamera
  38481. */
  38482. getClassName(): string;
  38483. }
  38484. }
  38485. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38486. /** @hidden */
  38487. export var stereoscopicInterlacePixelShader: {
  38488. name: string;
  38489. shader: string;
  38490. };
  38491. }
  38492. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38493. import { Camera } from "babylonjs/Cameras/camera";
  38494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38495. import { Engine } from "babylonjs/Engines/engine";
  38496. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38497. /**
  38498. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38499. */
  38500. export class StereoscopicInterlacePostProcess extends PostProcess {
  38501. private _stepSize;
  38502. private _passedProcess;
  38503. /**
  38504. * Initializes a StereoscopicInterlacePostProcess
  38505. * @param name The name of the effect.
  38506. * @param rigCameras The rig cameras to be appled to the post process
  38507. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38509. * @param engine The engine which the post process will be applied. (default: current engine)
  38510. * @param reusable If the post process can be reused on the same frame. (default: false)
  38511. */
  38512. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38513. }
  38514. }
  38515. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38516. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38517. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38518. import { Scene } from "babylonjs/scene";
  38519. import { Vector3 } from "babylonjs/Maths/math";
  38520. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38521. /**
  38522. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38523. * @see http://doc.babylonjs.com/features/cameras
  38524. */
  38525. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38526. /**
  38527. * Creates a new StereoscopicArcRotateCamera
  38528. * @param name defines camera name
  38529. * @param alpha defines alpha angle (in radians)
  38530. * @param beta defines beta angle (in radians)
  38531. * @param radius defines radius
  38532. * @param target defines camera target
  38533. * @param interaxialDistance defines distance between each color axis
  38534. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38535. * @param scene defines the hosting scene
  38536. */
  38537. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38538. /**
  38539. * Gets camera class name
  38540. * @returns StereoscopicArcRotateCamera
  38541. */
  38542. getClassName(): string;
  38543. }
  38544. }
  38545. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38546. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38547. import { Scene } from "babylonjs/scene";
  38548. import { Vector3 } from "babylonjs/Maths/math";
  38549. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38550. /**
  38551. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38552. * @see http://doc.babylonjs.com/features/cameras
  38553. */
  38554. export class StereoscopicFreeCamera extends FreeCamera {
  38555. /**
  38556. * Creates a new StereoscopicFreeCamera
  38557. * @param name defines camera name
  38558. * @param position defines initial position
  38559. * @param interaxialDistance defines distance between each color axis
  38560. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38561. * @param scene defines the hosting scene
  38562. */
  38563. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38564. /**
  38565. * Gets camera class name
  38566. * @returns StereoscopicFreeCamera
  38567. */
  38568. getClassName(): string;
  38569. }
  38570. }
  38571. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38572. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38573. import { Scene } from "babylonjs/scene";
  38574. import { Vector3 } from "babylonjs/Maths/math";
  38575. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38576. /**
  38577. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38578. * @see http://doc.babylonjs.com/features/cameras
  38579. */
  38580. export class StereoscopicGamepadCamera extends GamepadCamera {
  38581. /**
  38582. * Creates a new StereoscopicGamepadCamera
  38583. * @param name defines camera name
  38584. * @param position defines initial position
  38585. * @param interaxialDistance defines distance between each color axis
  38586. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38587. * @param scene defines the hosting scene
  38588. */
  38589. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38590. /**
  38591. * Gets camera class name
  38592. * @returns StereoscopicGamepadCamera
  38593. */
  38594. getClassName(): string;
  38595. }
  38596. }
  38597. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38598. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38599. import { Scene } from "babylonjs/scene";
  38600. import { Vector3 } from "babylonjs/Maths/math";
  38601. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38602. /**
  38603. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38604. * @see http://doc.babylonjs.com/features/cameras
  38605. */
  38606. export class StereoscopicUniversalCamera extends UniversalCamera {
  38607. /**
  38608. * Creates a new StereoscopicUniversalCamera
  38609. * @param name defines camera name
  38610. * @param position defines initial position
  38611. * @param interaxialDistance defines distance between each color axis
  38612. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38613. * @param scene defines the hosting scene
  38614. */
  38615. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38616. /**
  38617. * Gets camera class name
  38618. * @returns StereoscopicUniversalCamera
  38619. */
  38620. getClassName(): string;
  38621. }
  38622. }
  38623. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38624. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38625. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38626. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38627. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38628. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38629. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38630. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38631. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38632. }
  38633. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38634. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38635. import { Scene } from "babylonjs/scene";
  38636. import { Vector3 } from "babylonjs/Maths/math";
  38637. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38638. /**
  38639. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38640. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38641. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38642. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38643. */
  38644. export class VirtualJoysticksCamera extends FreeCamera {
  38645. /**
  38646. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38647. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38648. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38649. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38650. * @param name Define the name of the camera in the scene
  38651. * @param position Define the start position of the camera in the scene
  38652. * @param scene Define the scene the camera belongs to
  38653. */
  38654. constructor(name: string, position: Vector3, scene: Scene);
  38655. /**
  38656. * Gets the current object class name.
  38657. * @return the class name
  38658. */
  38659. getClassName(): string;
  38660. }
  38661. }
  38662. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38663. import { Matrix } from "babylonjs/Maths/math";
  38664. /**
  38665. * This represents all the required metrics to create a VR camera.
  38666. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38667. */
  38668. export class VRCameraMetrics {
  38669. /**
  38670. * Define the horizontal resolution off the screen.
  38671. */
  38672. hResolution: number;
  38673. /**
  38674. * Define the vertical resolution off the screen.
  38675. */
  38676. vResolution: number;
  38677. /**
  38678. * Define the horizontal screen size.
  38679. */
  38680. hScreenSize: number;
  38681. /**
  38682. * Define the vertical screen size.
  38683. */
  38684. vScreenSize: number;
  38685. /**
  38686. * Define the vertical screen center position.
  38687. */
  38688. vScreenCenter: number;
  38689. /**
  38690. * Define the distance of the eyes to the screen.
  38691. */
  38692. eyeToScreenDistance: number;
  38693. /**
  38694. * Define the distance between both lenses
  38695. */
  38696. lensSeparationDistance: number;
  38697. /**
  38698. * Define the distance between both viewer's eyes.
  38699. */
  38700. interpupillaryDistance: number;
  38701. /**
  38702. * Define the distortion factor of the VR postprocess.
  38703. * Please, touch with care.
  38704. */
  38705. distortionK: number[];
  38706. /**
  38707. * Define the chromatic aberration correction factors for the VR post process.
  38708. */
  38709. chromaAbCorrection: number[];
  38710. /**
  38711. * Define the scale factor of the post process.
  38712. * The smaller the better but the slower.
  38713. */
  38714. postProcessScaleFactor: number;
  38715. /**
  38716. * Define an offset for the lens center.
  38717. */
  38718. lensCenterOffset: number;
  38719. /**
  38720. * Define if the current vr camera should compensate the distortion of the lense or not.
  38721. */
  38722. compensateDistortion: boolean;
  38723. /**
  38724. * Gets the rendering aspect ratio based on the provided resolutions.
  38725. */
  38726. readonly aspectRatio: number;
  38727. /**
  38728. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38729. */
  38730. readonly aspectRatioFov: number;
  38731. /**
  38732. * @hidden
  38733. */
  38734. readonly leftHMatrix: Matrix;
  38735. /**
  38736. * @hidden
  38737. */
  38738. readonly rightHMatrix: Matrix;
  38739. /**
  38740. * @hidden
  38741. */
  38742. readonly leftPreViewMatrix: Matrix;
  38743. /**
  38744. * @hidden
  38745. */
  38746. readonly rightPreViewMatrix: Matrix;
  38747. /**
  38748. * Get the default VRMetrics based on the most generic setup.
  38749. * @returns the default vr metrics
  38750. */
  38751. static GetDefault(): VRCameraMetrics;
  38752. }
  38753. }
  38754. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38755. /** @hidden */
  38756. export var vrDistortionCorrectionPixelShader: {
  38757. name: string;
  38758. shader: string;
  38759. };
  38760. }
  38761. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38762. import { Camera } from "babylonjs/Cameras/camera";
  38763. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38765. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38766. /**
  38767. * VRDistortionCorrectionPostProcess used for mobile VR
  38768. */
  38769. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38770. private _isRightEye;
  38771. private _distortionFactors;
  38772. private _postProcessScaleFactor;
  38773. private _lensCenterOffset;
  38774. private _scaleIn;
  38775. private _scaleFactor;
  38776. private _lensCenter;
  38777. /**
  38778. * Initializes the VRDistortionCorrectionPostProcess
  38779. * @param name The name of the effect.
  38780. * @param camera The camera to apply the render pass to.
  38781. * @param isRightEye If this is for the right eye distortion
  38782. * @param vrMetrics All the required metrics for the VR camera
  38783. */
  38784. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38785. }
  38786. }
  38787. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38788. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38789. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38790. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38791. import { Scene } from "babylonjs/scene";
  38792. import { Vector3 } from "babylonjs/Maths/math";
  38793. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38794. import "babylonjs/Cameras/RigModes/vrRigMode";
  38795. /**
  38796. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38797. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38798. */
  38799. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38800. /**
  38801. * Creates a new VRDeviceOrientationArcRotateCamera
  38802. * @param name defines camera name
  38803. * @param alpha defines the camera rotation along the logitudinal axis
  38804. * @param beta defines the camera rotation along the latitudinal axis
  38805. * @param radius defines the camera distance from its target
  38806. * @param target defines the camera target
  38807. * @param scene defines the scene the camera belongs to
  38808. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38809. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38810. */
  38811. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38812. /**
  38813. * Gets camera class name
  38814. * @returns VRDeviceOrientationArcRotateCamera
  38815. */
  38816. getClassName(): string;
  38817. }
  38818. }
  38819. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38820. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38821. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38822. import { Scene } from "babylonjs/scene";
  38823. import { Vector3 } from "babylonjs/Maths/math";
  38824. import "babylonjs/Cameras/RigModes/vrRigMode";
  38825. /**
  38826. * Camera used to simulate VR rendering (based on FreeCamera)
  38827. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38828. */
  38829. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38830. /**
  38831. * Creates a new VRDeviceOrientationFreeCamera
  38832. * @param name defines camera name
  38833. * @param position defines the start position of the camera
  38834. * @param scene defines the scene the camera belongs to
  38835. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38836. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38837. */
  38838. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38839. /**
  38840. * Gets camera class name
  38841. * @returns VRDeviceOrientationFreeCamera
  38842. */
  38843. getClassName(): string;
  38844. }
  38845. }
  38846. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38847. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38848. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38849. import { Scene } from "babylonjs/scene";
  38850. import { Vector3 } from "babylonjs/Maths/math";
  38851. /**
  38852. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38853. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38854. */
  38855. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38856. /**
  38857. * Creates a new VRDeviceOrientationGamepadCamera
  38858. * @param name defines camera name
  38859. * @param position defines the start position of the camera
  38860. * @param scene defines the scene the camera belongs to
  38861. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38862. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38863. */
  38864. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38865. /**
  38866. * Gets camera class name
  38867. * @returns VRDeviceOrientationGamepadCamera
  38868. */
  38869. getClassName(): string;
  38870. }
  38871. }
  38872. declare module "babylonjs/Gamepads/xboxGamepad" {
  38873. import { Observable } from "babylonjs/Misc/observable";
  38874. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38875. /**
  38876. * Defines supported buttons for XBox360 compatible gamepads
  38877. */
  38878. export enum Xbox360Button {
  38879. /** A */
  38880. A = 0,
  38881. /** B */
  38882. B = 1,
  38883. /** X */
  38884. X = 2,
  38885. /** Y */
  38886. Y = 3,
  38887. /** Start */
  38888. Start = 4,
  38889. /** Back */
  38890. Back = 5,
  38891. /** Left button */
  38892. LB = 6,
  38893. /** Right button */
  38894. RB = 7,
  38895. /** Left stick */
  38896. LeftStick = 8,
  38897. /** Right stick */
  38898. RightStick = 9
  38899. }
  38900. /** Defines values for XBox360 DPad */
  38901. export enum Xbox360Dpad {
  38902. /** Up */
  38903. Up = 0,
  38904. /** Down */
  38905. Down = 1,
  38906. /** Left */
  38907. Left = 2,
  38908. /** Right */
  38909. Right = 3
  38910. }
  38911. /**
  38912. * Defines a XBox360 gamepad
  38913. */
  38914. export class Xbox360Pad extends Gamepad {
  38915. private _leftTrigger;
  38916. private _rightTrigger;
  38917. private _onlefttriggerchanged;
  38918. private _onrighttriggerchanged;
  38919. private _onbuttondown;
  38920. private _onbuttonup;
  38921. private _ondpaddown;
  38922. private _ondpadup;
  38923. /** Observable raised when a button is pressed */
  38924. onButtonDownObservable: Observable<Xbox360Button>;
  38925. /** Observable raised when a button is released */
  38926. onButtonUpObservable: Observable<Xbox360Button>;
  38927. /** Observable raised when a pad is pressed */
  38928. onPadDownObservable: Observable<Xbox360Dpad>;
  38929. /** Observable raised when a pad is released */
  38930. onPadUpObservable: Observable<Xbox360Dpad>;
  38931. private _buttonA;
  38932. private _buttonB;
  38933. private _buttonX;
  38934. private _buttonY;
  38935. private _buttonBack;
  38936. private _buttonStart;
  38937. private _buttonLB;
  38938. private _buttonRB;
  38939. private _buttonLeftStick;
  38940. private _buttonRightStick;
  38941. private _dPadUp;
  38942. private _dPadDown;
  38943. private _dPadLeft;
  38944. private _dPadRight;
  38945. private _isXboxOnePad;
  38946. /**
  38947. * Creates a new XBox360 gamepad object
  38948. * @param id defines the id of this gamepad
  38949. * @param index defines its index
  38950. * @param gamepad defines the internal HTML gamepad object
  38951. * @param xboxOne defines if it is a XBox One gamepad
  38952. */
  38953. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38954. /**
  38955. * Defines the callback to call when left trigger is pressed
  38956. * @param callback defines the callback to use
  38957. */
  38958. onlefttriggerchanged(callback: (value: number) => void): void;
  38959. /**
  38960. * Defines the callback to call when right trigger is pressed
  38961. * @param callback defines the callback to use
  38962. */
  38963. onrighttriggerchanged(callback: (value: number) => void): void;
  38964. /**
  38965. * Gets the left trigger value
  38966. */
  38967. /**
  38968. * Sets the left trigger value
  38969. */
  38970. leftTrigger: number;
  38971. /**
  38972. * Gets the right trigger value
  38973. */
  38974. /**
  38975. * Sets the right trigger value
  38976. */
  38977. rightTrigger: number;
  38978. /**
  38979. * Defines the callback to call when a button is pressed
  38980. * @param callback defines the callback to use
  38981. */
  38982. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38983. /**
  38984. * Defines the callback to call when a button is released
  38985. * @param callback defines the callback to use
  38986. */
  38987. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38988. /**
  38989. * Defines the callback to call when a pad is pressed
  38990. * @param callback defines the callback to use
  38991. */
  38992. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38993. /**
  38994. * Defines the callback to call when a pad is released
  38995. * @param callback defines the callback to use
  38996. */
  38997. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38998. private _setButtonValue;
  38999. private _setDPadValue;
  39000. /**
  39001. * Gets the value of the `A` button
  39002. */
  39003. /**
  39004. * Sets the value of the `A` button
  39005. */
  39006. buttonA: number;
  39007. /**
  39008. * Gets the value of the `B` button
  39009. */
  39010. /**
  39011. * Sets the value of the `B` button
  39012. */
  39013. buttonB: number;
  39014. /**
  39015. * Gets the value of the `X` button
  39016. */
  39017. /**
  39018. * Sets the value of the `X` button
  39019. */
  39020. buttonX: number;
  39021. /**
  39022. * Gets the value of the `Y` button
  39023. */
  39024. /**
  39025. * Sets the value of the `Y` button
  39026. */
  39027. buttonY: number;
  39028. /**
  39029. * Gets the value of the `Start` button
  39030. */
  39031. /**
  39032. * Sets the value of the `Start` button
  39033. */
  39034. buttonStart: number;
  39035. /**
  39036. * Gets the value of the `Back` button
  39037. */
  39038. /**
  39039. * Sets the value of the `Back` button
  39040. */
  39041. buttonBack: number;
  39042. /**
  39043. * Gets the value of the `Left` button
  39044. */
  39045. /**
  39046. * Sets the value of the `Left` button
  39047. */
  39048. buttonLB: number;
  39049. /**
  39050. * Gets the value of the `Right` button
  39051. */
  39052. /**
  39053. * Sets the value of the `Right` button
  39054. */
  39055. buttonRB: number;
  39056. /**
  39057. * Gets the value of the Left joystick
  39058. */
  39059. /**
  39060. * Sets the value of the Left joystick
  39061. */
  39062. buttonLeftStick: number;
  39063. /**
  39064. * Gets the value of the Right joystick
  39065. */
  39066. /**
  39067. * Sets the value of the Right joystick
  39068. */
  39069. buttonRightStick: number;
  39070. /**
  39071. * Gets the value of D-pad up
  39072. */
  39073. /**
  39074. * Sets the value of D-pad up
  39075. */
  39076. dPadUp: number;
  39077. /**
  39078. * Gets the value of D-pad down
  39079. */
  39080. /**
  39081. * Sets the value of D-pad down
  39082. */
  39083. dPadDown: number;
  39084. /**
  39085. * Gets the value of D-pad left
  39086. */
  39087. /**
  39088. * Sets the value of D-pad left
  39089. */
  39090. dPadLeft: number;
  39091. /**
  39092. * Gets the value of D-pad right
  39093. */
  39094. /**
  39095. * Sets the value of D-pad right
  39096. */
  39097. dPadRight: number;
  39098. /**
  39099. * Force the gamepad to synchronize with device values
  39100. */
  39101. update(): void;
  39102. /**
  39103. * Disposes the gamepad
  39104. */
  39105. dispose(): void;
  39106. }
  39107. }
  39108. declare module "babylonjs/Materials/pushMaterial" {
  39109. import { Nullable } from "babylonjs/types";
  39110. import { Scene } from "babylonjs/scene";
  39111. import { Matrix } from "babylonjs/Maths/math";
  39112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39113. import { Mesh } from "babylonjs/Meshes/mesh";
  39114. import { Material } from "babylonjs/Materials/material";
  39115. import { Effect } from "babylonjs/Materials/effect";
  39116. /**
  39117. * Base class of materials working in push mode in babylon JS
  39118. * @hidden
  39119. */
  39120. export class PushMaterial extends Material {
  39121. protected _activeEffect: Effect;
  39122. protected _normalMatrix: Matrix;
  39123. /**
  39124. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39125. * This means that the material can keep using a previous shader while a new one is being compiled.
  39126. * This is mostly used when shader parallel compilation is supported (true by default)
  39127. */
  39128. allowShaderHotSwapping: boolean;
  39129. constructor(name: string, scene: Scene);
  39130. getEffect(): Effect;
  39131. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39132. /**
  39133. * Binds the given world matrix to the active effect
  39134. *
  39135. * @param world the matrix to bind
  39136. */
  39137. bindOnlyWorldMatrix(world: Matrix): void;
  39138. /**
  39139. * Binds the given normal matrix to the active effect
  39140. *
  39141. * @param normalMatrix the matrix to bind
  39142. */
  39143. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39144. bind(world: Matrix, mesh?: Mesh): void;
  39145. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39146. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39147. }
  39148. }
  39149. declare module "babylonjs/Materials/materialFlags" {
  39150. /**
  39151. * This groups all the flags used to control the materials channel.
  39152. */
  39153. export class MaterialFlags {
  39154. private static _DiffuseTextureEnabled;
  39155. /**
  39156. * Are diffuse textures enabled in the application.
  39157. */
  39158. static DiffuseTextureEnabled: boolean;
  39159. private static _AmbientTextureEnabled;
  39160. /**
  39161. * Are ambient textures enabled in the application.
  39162. */
  39163. static AmbientTextureEnabled: boolean;
  39164. private static _OpacityTextureEnabled;
  39165. /**
  39166. * Are opacity textures enabled in the application.
  39167. */
  39168. static OpacityTextureEnabled: boolean;
  39169. private static _ReflectionTextureEnabled;
  39170. /**
  39171. * Are reflection textures enabled in the application.
  39172. */
  39173. static ReflectionTextureEnabled: boolean;
  39174. private static _EmissiveTextureEnabled;
  39175. /**
  39176. * Are emissive textures enabled in the application.
  39177. */
  39178. static EmissiveTextureEnabled: boolean;
  39179. private static _SpecularTextureEnabled;
  39180. /**
  39181. * Are specular textures enabled in the application.
  39182. */
  39183. static SpecularTextureEnabled: boolean;
  39184. private static _BumpTextureEnabled;
  39185. /**
  39186. * Are bump textures enabled in the application.
  39187. */
  39188. static BumpTextureEnabled: boolean;
  39189. private static _LightmapTextureEnabled;
  39190. /**
  39191. * Are lightmap textures enabled in the application.
  39192. */
  39193. static LightmapTextureEnabled: boolean;
  39194. private static _RefractionTextureEnabled;
  39195. /**
  39196. * Are refraction textures enabled in the application.
  39197. */
  39198. static RefractionTextureEnabled: boolean;
  39199. private static _ColorGradingTextureEnabled;
  39200. /**
  39201. * Are color grading textures enabled in the application.
  39202. */
  39203. static ColorGradingTextureEnabled: boolean;
  39204. private static _FresnelEnabled;
  39205. /**
  39206. * Are fresnels enabled in the application.
  39207. */
  39208. static FresnelEnabled: boolean;
  39209. }
  39210. }
  39211. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39212. /** @hidden */
  39213. export var defaultFragmentDeclaration: {
  39214. name: string;
  39215. shader: string;
  39216. };
  39217. }
  39218. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39219. /** @hidden */
  39220. export var defaultUboDeclaration: {
  39221. name: string;
  39222. shader: string;
  39223. };
  39224. }
  39225. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39226. /** @hidden */
  39227. export var lightFragmentDeclaration: {
  39228. name: string;
  39229. shader: string;
  39230. };
  39231. }
  39232. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39233. /** @hidden */
  39234. export var lightUboDeclaration: {
  39235. name: string;
  39236. shader: string;
  39237. };
  39238. }
  39239. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39240. /** @hidden */
  39241. export var lightsFragmentFunctions: {
  39242. name: string;
  39243. shader: string;
  39244. };
  39245. }
  39246. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39247. /** @hidden */
  39248. export var shadowsFragmentFunctions: {
  39249. name: string;
  39250. shader: string;
  39251. };
  39252. }
  39253. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39254. /** @hidden */
  39255. export var fresnelFunction: {
  39256. name: string;
  39257. shader: string;
  39258. };
  39259. }
  39260. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39261. /** @hidden */
  39262. export var reflectionFunction: {
  39263. name: string;
  39264. shader: string;
  39265. };
  39266. }
  39267. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39268. /** @hidden */
  39269. export var bumpFragmentFunctions: {
  39270. name: string;
  39271. shader: string;
  39272. };
  39273. }
  39274. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39275. /** @hidden */
  39276. export var logDepthDeclaration: {
  39277. name: string;
  39278. shader: string;
  39279. };
  39280. }
  39281. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39282. /** @hidden */
  39283. export var bumpFragment: {
  39284. name: string;
  39285. shader: string;
  39286. };
  39287. }
  39288. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39289. /** @hidden */
  39290. export var depthPrePass: {
  39291. name: string;
  39292. shader: string;
  39293. };
  39294. }
  39295. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39296. /** @hidden */
  39297. export var lightFragment: {
  39298. name: string;
  39299. shader: string;
  39300. };
  39301. }
  39302. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39303. /** @hidden */
  39304. export var logDepthFragment: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module "babylonjs/Shaders/default.fragment" {
  39310. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39311. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39312. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39315. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39316. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39317. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39318. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39319. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39320. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39321. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39322. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39323. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39324. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39326. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39327. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39328. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39329. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39330. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39331. /** @hidden */
  39332. export var defaultPixelShader: {
  39333. name: string;
  39334. shader: string;
  39335. };
  39336. }
  39337. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39338. /** @hidden */
  39339. export var defaultVertexDeclaration: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39345. /** @hidden */
  39346. export var bumpVertexDeclaration: {
  39347. name: string;
  39348. shader: string;
  39349. };
  39350. }
  39351. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39352. /** @hidden */
  39353. export var bumpVertex: {
  39354. name: string;
  39355. shader: string;
  39356. };
  39357. }
  39358. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39359. /** @hidden */
  39360. export var fogVertex: {
  39361. name: string;
  39362. shader: string;
  39363. };
  39364. }
  39365. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39366. /** @hidden */
  39367. export var shadowsVertex: {
  39368. name: string;
  39369. shader: string;
  39370. };
  39371. }
  39372. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39373. /** @hidden */
  39374. export var pointCloudVertex: {
  39375. name: string;
  39376. shader: string;
  39377. };
  39378. }
  39379. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39380. /** @hidden */
  39381. export var logDepthVertex: {
  39382. name: string;
  39383. shader: string;
  39384. };
  39385. }
  39386. declare module "babylonjs/Shaders/default.vertex" {
  39387. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39388. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39390. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39391. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39392. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39393. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39394. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39395. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39396. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39399. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39403. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39405. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39406. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39407. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39408. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39409. /** @hidden */
  39410. export var defaultVertexShader: {
  39411. name: string;
  39412. shader: string;
  39413. };
  39414. }
  39415. declare module "babylonjs/Materials/standardMaterial" {
  39416. import { SmartArray } from "babylonjs/Misc/smartArray";
  39417. import { IAnimatable } from "babylonjs/Misc/tools";
  39418. import { Nullable } from "babylonjs/types";
  39419. import { Scene } from "babylonjs/scene";
  39420. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39423. import { Mesh } from "babylonjs/Meshes/mesh";
  39424. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39425. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39426. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39427. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39428. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39431. import "babylonjs/Shaders/default.fragment";
  39432. import "babylonjs/Shaders/default.vertex";
  39433. /** @hidden */
  39434. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39435. MAINUV1: boolean;
  39436. MAINUV2: boolean;
  39437. DIFFUSE: boolean;
  39438. DIFFUSEDIRECTUV: number;
  39439. AMBIENT: boolean;
  39440. AMBIENTDIRECTUV: number;
  39441. OPACITY: boolean;
  39442. OPACITYDIRECTUV: number;
  39443. OPACITYRGB: boolean;
  39444. REFLECTION: boolean;
  39445. EMISSIVE: boolean;
  39446. EMISSIVEDIRECTUV: number;
  39447. SPECULAR: boolean;
  39448. SPECULARDIRECTUV: number;
  39449. BUMP: boolean;
  39450. BUMPDIRECTUV: number;
  39451. PARALLAX: boolean;
  39452. PARALLAXOCCLUSION: boolean;
  39453. SPECULAROVERALPHA: boolean;
  39454. CLIPPLANE: boolean;
  39455. CLIPPLANE2: boolean;
  39456. CLIPPLANE3: boolean;
  39457. CLIPPLANE4: boolean;
  39458. ALPHATEST: boolean;
  39459. DEPTHPREPASS: boolean;
  39460. ALPHAFROMDIFFUSE: boolean;
  39461. POINTSIZE: boolean;
  39462. FOG: boolean;
  39463. SPECULARTERM: boolean;
  39464. DIFFUSEFRESNEL: boolean;
  39465. OPACITYFRESNEL: boolean;
  39466. REFLECTIONFRESNEL: boolean;
  39467. REFRACTIONFRESNEL: boolean;
  39468. EMISSIVEFRESNEL: boolean;
  39469. FRESNEL: boolean;
  39470. NORMAL: boolean;
  39471. UV1: boolean;
  39472. UV2: boolean;
  39473. VERTEXCOLOR: boolean;
  39474. VERTEXALPHA: boolean;
  39475. NUM_BONE_INFLUENCERS: number;
  39476. BonesPerMesh: number;
  39477. BONETEXTURE: boolean;
  39478. INSTANCES: boolean;
  39479. GLOSSINESS: boolean;
  39480. ROUGHNESS: boolean;
  39481. EMISSIVEASILLUMINATION: boolean;
  39482. LINKEMISSIVEWITHDIFFUSE: boolean;
  39483. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39484. LIGHTMAP: boolean;
  39485. LIGHTMAPDIRECTUV: number;
  39486. OBJECTSPACE_NORMALMAP: boolean;
  39487. USELIGHTMAPASSHADOWMAP: boolean;
  39488. REFLECTIONMAP_3D: boolean;
  39489. REFLECTIONMAP_SPHERICAL: boolean;
  39490. REFLECTIONMAP_PLANAR: boolean;
  39491. REFLECTIONMAP_CUBIC: boolean;
  39492. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39493. REFLECTIONMAP_PROJECTION: boolean;
  39494. REFLECTIONMAP_SKYBOX: boolean;
  39495. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39496. REFLECTIONMAP_EXPLICIT: boolean;
  39497. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39498. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39499. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39500. INVERTCUBICMAP: boolean;
  39501. LOGARITHMICDEPTH: boolean;
  39502. REFRACTION: boolean;
  39503. REFRACTIONMAP_3D: boolean;
  39504. REFLECTIONOVERALPHA: boolean;
  39505. TWOSIDEDLIGHTING: boolean;
  39506. SHADOWFLOAT: boolean;
  39507. MORPHTARGETS: boolean;
  39508. MORPHTARGETS_NORMAL: boolean;
  39509. MORPHTARGETS_TANGENT: boolean;
  39510. NUM_MORPH_INFLUENCERS: number;
  39511. NONUNIFORMSCALING: boolean;
  39512. PREMULTIPLYALPHA: boolean;
  39513. IMAGEPROCESSING: boolean;
  39514. VIGNETTE: boolean;
  39515. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39516. VIGNETTEBLENDMODEOPAQUE: boolean;
  39517. TONEMAPPING: boolean;
  39518. TONEMAPPING_ACES: boolean;
  39519. CONTRAST: boolean;
  39520. COLORCURVES: boolean;
  39521. COLORGRADING: boolean;
  39522. COLORGRADING3D: boolean;
  39523. SAMPLER3DGREENDEPTH: boolean;
  39524. SAMPLER3DBGRMAP: boolean;
  39525. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39526. /**
  39527. * If the reflection texture on this material is in linear color space
  39528. * @hidden
  39529. */
  39530. IS_REFLECTION_LINEAR: boolean;
  39531. /**
  39532. * If the refraction texture on this material is in linear color space
  39533. * @hidden
  39534. */
  39535. IS_REFRACTION_LINEAR: boolean;
  39536. EXPOSURE: boolean;
  39537. constructor();
  39538. setReflectionMode(modeToEnable: string): void;
  39539. }
  39540. /**
  39541. * This is the default material used in Babylon. It is the best trade off between quality
  39542. * and performances.
  39543. * @see http://doc.babylonjs.com/babylon101/materials
  39544. */
  39545. export class StandardMaterial extends PushMaterial {
  39546. private _diffuseTexture;
  39547. /**
  39548. * The basic texture of the material as viewed under a light.
  39549. */
  39550. diffuseTexture: Nullable<BaseTexture>;
  39551. private _ambientTexture;
  39552. /**
  39553. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39554. */
  39555. ambientTexture: Nullable<BaseTexture>;
  39556. private _opacityTexture;
  39557. /**
  39558. * Define the transparency of the material from a texture.
  39559. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39560. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39561. */
  39562. opacityTexture: Nullable<BaseTexture>;
  39563. private _reflectionTexture;
  39564. /**
  39565. * Define the texture used to display the reflection.
  39566. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39567. */
  39568. reflectionTexture: Nullable<BaseTexture>;
  39569. private _emissiveTexture;
  39570. /**
  39571. * Define texture of the material as if self lit.
  39572. * This will be mixed in the final result even in the absence of light.
  39573. */
  39574. emissiveTexture: Nullable<BaseTexture>;
  39575. private _specularTexture;
  39576. /**
  39577. * Define how the color and intensity of the highlight given by the light in the material.
  39578. */
  39579. specularTexture: Nullable<BaseTexture>;
  39580. private _bumpTexture;
  39581. /**
  39582. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39583. * 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.
  39584. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39585. */
  39586. bumpTexture: Nullable<BaseTexture>;
  39587. private _lightmapTexture;
  39588. /**
  39589. * Complex lighting can be computationally expensive to compute at runtime.
  39590. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39591. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39592. */
  39593. lightmapTexture: Nullable<BaseTexture>;
  39594. private _refractionTexture;
  39595. /**
  39596. * Define the texture used to display the refraction.
  39597. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39598. */
  39599. refractionTexture: Nullable<BaseTexture>;
  39600. /**
  39601. * The color of the material lit by the environmental background lighting.
  39602. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39603. */
  39604. ambientColor: Color3;
  39605. /**
  39606. * The basic color of the material as viewed under a light.
  39607. */
  39608. diffuseColor: Color3;
  39609. /**
  39610. * Define how the color and intensity of the highlight given by the light in the material.
  39611. */
  39612. specularColor: Color3;
  39613. /**
  39614. * Define the color of the material as if self lit.
  39615. * This will be mixed in the final result even in the absence of light.
  39616. */
  39617. emissiveColor: Color3;
  39618. /**
  39619. * Defines how sharp are the highlights in the material.
  39620. * The bigger the value the sharper giving a more glossy feeling to the result.
  39621. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39622. */
  39623. specularPower: number;
  39624. private _useAlphaFromDiffuseTexture;
  39625. /**
  39626. * Does the transparency come from the diffuse texture alpha channel.
  39627. */
  39628. useAlphaFromDiffuseTexture: boolean;
  39629. private _useEmissiveAsIllumination;
  39630. /**
  39631. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39632. */
  39633. useEmissiveAsIllumination: boolean;
  39634. private _linkEmissiveWithDiffuse;
  39635. /**
  39636. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39637. * the emissive level when the final color is close to one.
  39638. */
  39639. linkEmissiveWithDiffuse: boolean;
  39640. private _useSpecularOverAlpha;
  39641. /**
  39642. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39643. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39644. */
  39645. useSpecularOverAlpha: boolean;
  39646. private _useReflectionOverAlpha;
  39647. /**
  39648. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39649. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39650. */
  39651. useReflectionOverAlpha: boolean;
  39652. private _disableLighting;
  39653. /**
  39654. * Does lights from the scene impacts this material.
  39655. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39656. */
  39657. disableLighting: boolean;
  39658. private _useObjectSpaceNormalMap;
  39659. /**
  39660. * Allows using an object space normal map (instead of tangent space).
  39661. */
  39662. useObjectSpaceNormalMap: boolean;
  39663. private _useParallax;
  39664. /**
  39665. * Is parallax enabled or not.
  39666. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39667. */
  39668. useParallax: boolean;
  39669. private _useParallaxOcclusion;
  39670. /**
  39671. * Is parallax occlusion enabled or not.
  39672. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39673. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39674. */
  39675. useParallaxOcclusion: boolean;
  39676. /**
  39677. * 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.
  39678. */
  39679. parallaxScaleBias: number;
  39680. private _roughness;
  39681. /**
  39682. * Helps to define how blurry the reflections should appears in the material.
  39683. */
  39684. roughness: number;
  39685. /**
  39686. * In case of refraction, define the value of the indice of refraction.
  39687. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39688. */
  39689. indexOfRefraction: number;
  39690. /**
  39691. * Invert the refraction texture alongside the y axis.
  39692. * It can be useful with procedural textures or probe for instance.
  39693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39694. */
  39695. invertRefractionY: boolean;
  39696. /**
  39697. * Defines the alpha limits in alpha test mode.
  39698. */
  39699. alphaCutOff: number;
  39700. private _useLightmapAsShadowmap;
  39701. /**
  39702. * In case of light mapping, define whether the map contains light or shadow informations.
  39703. */
  39704. useLightmapAsShadowmap: boolean;
  39705. private _diffuseFresnelParameters;
  39706. /**
  39707. * Define the diffuse fresnel parameters of the material.
  39708. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39709. */
  39710. diffuseFresnelParameters: FresnelParameters;
  39711. private _opacityFresnelParameters;
  39712. /**
  39713. * Define the opacity fresnel parameters of the material.
  39714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39715. */
  39716. opacityFresnelParameters: FresnelParameters;
  39717. private _reflectionFresnelParameters;
  39718. /**
  39719. * Define the reflection fresnel parameters of the material.
  39720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39721. */
  39722. reflectionFresnelParameters: FresnelParameters;
  39723. private _refractionFresnelParameters;
  39724. /**
  39725. * Define the refraction fresnel parameters of the material.
  39726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39727. */
  39728. refractionFresnelParameters: FresnelParameters;
  39729. private _emissiveFresnelParameters;
  39730. /**
  39731. * Define the emissive fresnel parameters of the material.
  39732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39733. */
  39734. emissiveFresnelParameters: FresnelParameters;
  39735. private _useReflectionFresnelFromSpecular;
  39736. /**
  39737. * If true automatically deducts the fresnels values from the material specularity.
  39738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39739. */
  39740. useReflectionFresnelFromSpecular: boolean;
  39741. private _useGlossinessFromSpecularMapAlpha;
  39742. /**
  39743. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39744. */
  39745. useGlossinessFromSpecularMapAlpha: boolean;
  39746. private _maxSimultaneousLights;
  39747. /**
  39748. * Defines the maximum number of lights that can be used in the material
  39749. */
  39750. maxSimultaneousLights: number;
  39751. private _invertNormalMapX;
  39752. /**
  39753. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39754. */
  39755. invertNormalMapX: boolean;
  39756. private _invertNormalMapY;
  39757. /**
  39758. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39759. */
  39760. invertNormalMapY: boolean;
  39761. private _twoSidedLighting;
  39762. /**
  39763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39764. */
  39765. twoSidedLighting: boolean;
  39766. /**
  39767. * Default configuration related to image processing available in the standard Material.
  39768. */
  39769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39770. /**
  39771. * Gets the image processing configuration used either in this material.
  39772. */
  39773. /**
  39774. * Sets the Default image processing configuration used either in the this material.
  39775. *
  39776. * If sets to null, the scene one is in use.
  39777. */
  39778. imageProcessingConfiguration: ImageProcessingConfiguration;
  39779. /**
  39780. * Keep track of the image processing observer to allow dispose and replace.
  39781. */
  39782. private _imageProcessingObserver;
  39783. /**
  39784. * Attaches a new image processing configuration to the Standard Material.
  39785. * @param configuration
  39786. */
  39787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39788. /**
  39789. * Gets wether the color curves effect is enabled.
  39790. */
  39791. /**
  39792. * Sets wether the color curves effect is enabled.
  39793. */
  39794. cameraColorCurvesEnabled: boolean;
  39795. /**
  39796. * Gets wether the color grading effect is enabled.
  39797. */
  39798. /**
  39799. * Gets wether the color grading effect is enabled.
  39800. */
  39801. cameraColorGradingEnabled: boolean;
  39802. /**
  39803. * Gets wether tonemapping is enabled or not.
  39804. */
  39805. /**
  39806. * Sets wether tonemapping is enabled or not
  39807. */
  39808. cameraToneMappingEnabled: boolean;
  39809. /**
  39810. * The camera exposure used on this material.
  39811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39812. * This corresponds to a photographic exposure.
  39813. */
  39814. /**
  39815. * The camera exposure used on this material.
  39816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39817. * This corresponds to a photographic exposure.
  39818. */
  39819. cameraExposure: number;
  39820. /**
  39821. * Gets The camera contrast used on this material.
  39822. */
  39823. /**
  39824. * Sets The camera contrast used on this material.
  39825. */
  39826. cameraContrast: number;
  39827. /**
  39828. * Gets the Color Grading 2D Lookup Texture.
  39829. */
  39830. /**
  39831. * Sets the Color Grading 2D Lookup Texture.
  39832. */
  39833. cameraColorGradingTexture: Nullable<BaseTexture>;
  39834. /**
  39835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39837. * 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;
  39838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39839. */
  39840. /**
  39841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39843. * 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;
  39844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39845. */
  39846. cameraColorCurves: Nullable<ColorCurves>;
  39847. /**
  39848. * Custom callback helping to override the default shader used in the material.
  39849. */
  39850. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39851. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39852. protected _worldViewProjectionMatrix: Matrix;
  39853. protected _globalAmbientColor: Color3;
  39854. protected _useLogarithmicDepth: boolean;
  39855. /**
  39856. * Instantiates a new standard material.
  39857. * This is the default material used in Babylon. It is the best trade off between quality
  39858. * and performances.
  39859. * @see http://doc.babylonjs.com/babylon101/materials
  39860. * @param name Define the name of the material in the scene
  39861. * @param scene Define the scene the material belong to
  39862. */
  39863. constructor(name: string, scene: Scene);
  39864. /**
  39865. * Gets a boolean indicating that current material needs to register RTT
  39866. */
  39867. readonly hasRenderTargetTextures: boolean;
  39868. /**
  39869. * Gets the current class name of the material e.g. "StandardMaterial"
  39870. * Mainly use in serialization.
  39871. * @returns the class name
  39872. */
  39873. getClassName(): string;
  39874. /**
  39875. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39876. * You can try switching to logarithmic depth.
  39877. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39878. */
  39879. useLogarithmicDepth: boolean;
  39880. /**
  39881. * Specifies if the material will require alpha blending
  39882. * @returns a boolean specifying if alpha blending is needed
  39883. */
  39884. needAlphaBlending(): boolean;
  39885. /**
  39886. * Specifies if this material should be rendered in alpha test mode
  39887. * @returns a boolean specifying if an alpha test is needed.
  39888. */
  39889. needAlphaTesting(): boolean;
  39890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39891. /**
  39892. * Get the texture used for alpha test purpose.
  39893. * @returns the diffuse texture in case of the standard material.
  39894. */
  39895. getAlphaTestTexture(): Nullable<BaseTexture>;
  39896. /**
  39897. * Get if the submesh is ready to be used and all its information available.
  39898. * Child classes can use it to update shaders
  39899. * @param mesh defines the mesh to check
  39900. * @param subMesh defines which submesh to check
  39901. * @param useInstances specifies that instances should be used
  39902. * @returns a boolean indicating that the submesh is ready or not
  39903. */
  39904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39905. /**
  39906. * Builds the material UBO layouts.
  39907. * Used internally during the effect preparation.
  39908. */
  39909. buildUniformLayout(): void;
  39910. /**
  39911. * Unbinds the material from the mesh
  39912. */
  39913. unbind(): void;
  39914. /**
  39915. * Binds the submesh to this material by preparing the effect and shader to draw
  39916. * @param world defines the world transformation matrix
  39917. * @param mesh defines the mesh containing the submesh
  39918. * @param subMesh defines the submesh to bind the material to
  39919. */
  39920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39921. /**
  39922. * Get the list of animatables in the material.
  39923. * @returns the list of animatables object used in the material
  39924. */
  39925. getAnimatables(): IAnimatable[];
  39926. /**
  39927. * Gets the active textures from the material
  39928. * @returns an array of textures
  39929. */
  39930. getActiveTextures(): BaseTexture[];
  39931. /**
  39932. * Specifies if the material uses a texture
  39933. * @param texture defines the texture to check against the material
  39934. * @returns a boolean specifying if the material uses the texture
  39935. */
  39936. hasTexture(texture: BaseTexture): boolean;
  39937. /**
  39938. * Disposes the material
  39939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39941. */
  39942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39943. /**
  39944. * Makes a duplicate of the material, and gives it a new name
  39945. * @param name defines the new name for the duplicated material
  39946. * @returns the cloned material
  39947. */
  39948. clone(name: string): StandardMaterial;
  39949. /**
  39950. * Serializes this material in a JSON representation
  39951. * @returns the serialized material object
  39952. */
  39953. serialize(): any;
  39954. /**
  39955. * Creates a standard material from parsed material data
  39956. * @param source defines the JSON representation of the material
  39957. * @param scene defines the hosting scene
  39958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39959. * @returns a new standard material
  39960. */
  39961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39962. /**
  39963. * Are diffuse textures enabled in the application.
  39964. */
  39965. static DiffuseTextureEnabled: boolean;
  39966. /**
  39967. * Are ambient textures enabled in the application.
  39968. */
  39969. static AmbientTextureEnabled: boolean;
  39970. /**
  39971. * Are opacity textures enabled in the application.
  39972. */
  39973. static OpacityTextureEnabled: boolean;
  39974. /**
  39975. * Are reflection textures enabled in the application.
  39976. */
  39977. static ReflectionTextureEnabled: boolean;
  39978. /**
  39979. * Are emissive textures enabled in the application.
  39980. */
  39981. static EmissiveTextureEnabled: boolean;
  39982. /**
  39983. * Are specular textures enabled in the application.
  39984. */
  39985. static SpecularTextureEnabled: boolean;
  39986. /**
  39987. * Are bump textures enabled in the application.
  39988. */
  39989. static BumpTextureEnabled: boolean;
  39990. /**
  39991. * Are lightmap textures enabled in the application.
  39992. */
  39993. static LightmapTextureEnabled: boolean;
  39994. /**
  39995. * Are refraction textures enabled in the application.
  39996. */
  39997. static RefractionTextureEnabled: boolean;
  39998. /**
  39999. * Are color grading textures enabled in the application.
  40000. */
  40001. static ColorGradingTextureEnabled: boolean;
  40002. /**
  40003. * Are fresnels enabled in the application.
  40004. */
  40005. static FresnelEnabled: boolean;
  40006. }
  40007. }
  40008. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40009. import { Scene } from "babylonjs/scene";
  40010. import { Texture } from "babylonjs/Materials/Textures/texture";
  40011. /**
  40012. * A class extending Texture allowing drawing on a texture
  40013. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40014. */
  40015. export class DynamicTexture extends Texture {
  40016. private _generateMipMaps;
  40017. private _canvas;
  40018. private _context;
  40019. private _engine;
  40020. /**
  40021. * Creates a DynamicTexture
  40022. * @param name defines the name of the texture
  40023. * @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
  40024. * @param scene defines the scene where you want the texture
  40025. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40026. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40027. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40028. */
  40029. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40030. /**
  40031. * Get the current class name of the texture useful for serialization or dynamic coding.
  40032. * @returns "DynamicTexture"
  40033. */
  40034. getClassName(): string;
  40035. /**
  40036. * Gets the current state of canRescale
  40037. */
  40038. readonly canRescale: boolean;
  40039. private _recreate;
  40040. /**
  40041. * Scales the texture
  40042. * @param ratio the scale factor to apply to both width and height
  40043. */
  40044. scale(ratio: number): void;
  40045. /**
  40046. * Resizes the texture
  40047. * @param width the new width
  40048. * @param height the new height
  40049. */
  40050. scaleTo(width: number, height: number): void;
  40051. /**
  40052. * Gets the context of the canvas used by the texture
  40053. * @returns the canvas context of the dynamic texture
  40054. */
  40055. getContext(): CanvasRenderingContext2D;
  40056. /**
  40057. * Clears the texture
  40058. */
  40059. clear(): void;
  40060. /**
  40061. * Updates the texture
  40062. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40063. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40064. */
  40065. update(invertY?: boolean, premulAlpha?: boolean): void;
  40066. /**
  40067. * Draws text onto the texture
  40068. * @param text defines the text to be drawn
  40069. * @param x defines the placement of the text from the left
  40070. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40071. * @param font defines the font to be used with font-style, font-size, font-name
  40072. * @param color defines the color used for the text
  40073. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40074. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40075. * @param update defines whether texture is immediately update (default is true)
  40076. */
  40077. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40078. /**
  40079. * Clones the texture
  40080. * @returns the clone of the texture.
  40081. */
  40082. clone(): DynamicTexture;
  40083. /**
  40084. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40085. * @returns a serialized dynamic texture object
  40086. */
  40087. serialize(): any;
  40088. /** @hidden */
  40089. _rebuild(): void;
  40090. }
  40091. }
  40092. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40093. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40095. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40096. /** @hidden */
  40097. export var imageProcessingPixelShader: {
  40098. name: string;
  40099. shader: string;
  40100. };
  40101. }
  40102. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40103. import { Nullable } from "babylonjs/types";
  40104. import { Color4 } from "babylonjs/Maths/math";
  40105. import { Camera } from "babylonjs/Cameras/camera";
  40106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40107. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40108. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40110. import { Engine } from "babylonjs/Engines/engine";
  40111. import "babylonjs/Shaders/imageProcessing.fragment";
  40112. import "babylonjs/Shaders/postprocess.vertex";
  40113. /**
  40114. * ImageProcessingPostProcess
  40115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40116. */
  40117. export class ImageProcessingPostProcess extends PostProcess {
  40118. /**
  40119. * Default configuration related to image processing available in the PBR Material.
  40120. */
  40121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40122. /**
  40123. * Gets the image processing configuration used either in this material.
  40124. */
  40125. /**
  40126. * Sets the Default image processing configuration used either in the this material.
  40127. *
  40128. * If sets to null, the scene one is in use.
  40129. */
  40130. imageProcessingConfiguration: ImageProcessingConfiguration;
  40131. /**
  40132. * Keep track of the image processing observer to allow dispose and replace.
  40133. */
  40134. private _imageProcessingObserver;
  40135. /**
  40136. * Attaches a new image processing configuration to the PBR Material.
  40137. * @param configuration
  40138. */
  40139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40140. /**
  40141. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40142. */
  40143. /**
  40144. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40145. */
  40146. colorCurves: Nullable<ColorCurves>;
  40147. /**
  40148. * Gets wether the color curves effect is enabled.
  40149. */
  40150. /**
  40151. * Sets wether the color curves effect is enabled.
  40152. */
  40153. colorCurvesEnabled: boolean;
  40154. /**
  40155. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40156. */
  40157. /**
  40158. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40159. */
  40160. colorGradingTexture: Nullable<BaseTexture>;
  40161. /**
  40162. * Gets wether the color grading effect is enabled.
  40163. */
  40164. /**
  40165. * Gets wether the color grading effect is enabled.
  40166. */
  40167. colorGradingEnabled: boolean;
  40168. /**
  40169. * Gets exposure used in the effect.
  40170. */
  40171. /**
  40172. * Sets exposure used in the effect.
  40173. */
  40174. exposure: number;
  40175. /**
  40176. * Gets wether tonemapping is enabled or not.
  40177. */
  40178. /**
  40179. * Sets wether tonemapping is enabled or not
  40180. */
  40181. toneMappingEnabled: boolean;
  40182. /**
  40183. * Gets contrast used in the effect.
  40184. */
  40185. /**
  40186. * Sets contrast used in the effect.
  40187. */
  40188. contrast: number;
  40189. /**
  40190. * Gets Vignette stretch size.
  40191. */
  40192. /**
  40193. * Sets Vignette stretch size.
  40194. */
  40195. vignetteStretch: number;
  40196. /**
  40197. * Gets Vignette centre X Offset.
  40198. */
  40199. /**
  40200. * Sets Vignette centre X Offset.
  40201. */
  40202. vignetteCentreX: number;
  40203. /**
  40204. * Gets Vignette centre Y Offset.
  40205. */
  40206. /**
  40207. * Sets Vignette centre Y Offset.
  40208. */
  40209. vignetteCentreY: number;
  40210. /**
  40211. * Gets Vignette weight or intensity of the vignette effect.
  40212. */
  40213. /**
  40214. * Sets Vignette weight or intensity of the vignette effect.
  40215. */
  40216. vignetteWeight: number;
  40217. /**
  40218. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40219. * if vignetteEnabled is set to true.
  40220. */
  40221. /**
  40222. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40223. * if vignetteEnabled is set to true.
  40224. */
  40225. vignetteColor: Color4;
  40226. /**
  40227. * Gets Camera field of view used by the Vignette effect.
  40228. */
  40229. /**
  40230. * Sets Camera field of view used by the Vignette effect.
  40231. */
  40232. vignetteCameraFov: number;
  40233. /**
  40234. * Gets the vignette blend mode allowing different kind of effect.
  40235. */
  40236. /**
  40237. * Sets the vignette blend mode allowing different kind of effect.
  40238. */
  40239. vignetteBlendMode: number;
  40240. /**
  40241. * Gets wether the vignette effect is enabled.
  40242. */
  40243. /**
  40244. * Sets wether the vignette effect is enabled.
  40245. */
  40246. vignetteEnabled: boolean;
  40247. private _fromLinearSpace;
  40248. /**
  40249. * Gets wether the input of the processing is in Gamma or Linear Space.
  40250. */
  40251. /**
  40252. * Sets wether the input of the processing is in Gamma or Linear Space.
  40253. */
  40254. fromLinearSpace: boolean;
  40255. /**
  40256. * Defines cache preventing GC.
  40257. */
  40258. private _defines;
  40259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40260. /**
  40261. * "ImageProcessingPostProcess"
  40262. * @returns "ImageProcessingPostProcess"
  40263. */
  40264. getClassName(): string;
  40265. protected _updateParameters(): void;
  40266. dispose(camera?: Camera): void;
  40267. }
  40268. }
  40269. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40270. import { Observable } from "babylonjs/Misc/observable";
  40271. import { Nullable } from "babylonjs/types";
  40272. import { Camera } from "babylonjs/Cameras/camera";
  40273. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40274. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40275. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40276. import { Scene } from "babylonjs/scene";
  40277. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40278. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40280. import { Mesh } from "babylonjs/Meshes/mesh";
  40281. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40282. /**
  40283. * Options to modify the vr teleportation behavior.
  40284. */
  40285. export interface VRTeleportationOptions {
  40286. /**
  40287. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40288. */
  40289. floorMeshName?: string;
  40290. /**
  40291. * A list of meshes to be used as the teleportation floor. (default: empty)
  40292. */
  40293. floorMeshes?: Mesh[];
  40294. }
  40295. /**
  40296. * Options to modify the vr experience helper's behavior.
  40297. */
  40298. export interface VRExperienceHelperOptions extends WebVROptions {
  40299. /**
  40300. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40301. */
  40302. createDeviceOrientationCamera?: boolean;
  40303. /**
  40304. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40305. */
  40306. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40307. /**
  40308. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40309. */
  40310. laserToggle?: boolean;
  40311. /**
  40312. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40313. */
  40314. floorMeshes?: Mesh[];
  40315. }
  40316. /**
  40317. * Helps to quickly add VR support to an existing scene.
  40318. * See http://doc.babylonjs.com/how_to/webvr_helper
  40319. */
  40320. export class VRExperienceHelper {
  40321. /** Options to modify the vr experience helper's behavior. */
  40322. webVROptions: VRExperienceHelperOptions;
  40323. private _scene;
  40324. private _position;
  40325. private _btnVR;
  40326. private _btnVRDisplayed;
  40327. private _webVRsupported;
  40328. private _webVRready;
  40329. private _webVRrequesting;
  40330. private _webVRpresenting;
  40331. private _hasEnteredVR;
  40332. private _fullscreenVRpresenting;
  40333. private _canvas;
  40334. private _webVRCamera;
  40335. private _vrDeviceOrientationCamera;
  40336. private _deviceOrientationCamera;
  40337. private _existingCamera;
  40338. private _onKeyDown;
  40339. private _onVrDisplayPresentChange;
  40340. private _onVRDisplayChanged;
  40341. private _onVRRequestPresentStart;
  40342. private _onVRRequestPresentComplete;
  40343. /**
  40344. * Observable raised when entering VR.
  40345. */
  40346. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40347. /**
  40348. * Observable raised when exiting VR.
  40349. */
  40350. onExitingVRObservable: Observable<VRExperienceHelper>;
  40351. /**
  40352. * Observable raised when controller mesh is loaded.
  40353. */
  40354. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40355. /** Return this.onEnteringVRObservable
  40356. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40357. */
  40358. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40359. /** Return this.onExitingVRObservable
  40360. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40361. */
  40362. readonly onExitingVR: Observable<VRExperienceHelper>;
  40363. /** Return this.onControllerMeshLoadedObservable
  40364. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40365. */
  40366. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40367. private _rayLength;
  40368. private _useCustomVRButton;
  40369. private _teleportationRequested;
  40370. private _teleportActive;
  40371. private _floorMeshName;
  40372. private _floorMeshesCollection;
  40373. private _rotationAllowed;
  40374. private _teleportBackwardsVector;
  40375. private _teleportationTarget;
  40376. private _isDefaultTeleportationTarget;
  40377. private _postProcessMove;
  40378. private _teleportationFillColor;
  40379. private _teleportationBorderColor;
  40380. private _rotationAngle;
  40381. private _haloCenter;
  40382. private _cameraGazer;
  40383. private _padSensibilityUp;
  40384. private _padSensibilityDown;
  40385. private _leftController;
  40386. private _rightController;
  40387. /**
  40388. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40389. */
  40390. onNewMeshSelected: Observable<AbstractMesh>;
  40391. /**
  40392. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40393. */
  40394. onNewMeshPicked: Observable<PickingInfo>;
  40395. private _circleEase;
  40396. /**
  40397. * Observable raised before camera teleportation
  40398. */
  40399. onBeforeCameraTeleport: Observable<Vector3>;
  40400. /**
  40401. * Observable raised after camera teleportation
  40402. */
  40403. onAfterCameraTeleport: Observable<Vector3>;
  40404. /**
  40405. * Observable raised when current selected mesh gets unselected
  40406. */
  40407. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40408. private _raySelectionPredicate;
  40409. /**
  40410. * To be optionaly changed by user to define custom ray selection
  40411. */
  40412. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40413. /**
  40414. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40415. */
  40416. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40417. /**
  40418. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40419. */
  40420. teleportationEnabled: boolean;
  40421. private _defaultHeight;
  40422. private _teleportationInitialized;
  40423. private _interactionsEnabled;
  40424. private _interactionsRequested;
  40425. private _displayGaze;
  40426. private _displayLaserPointer;
  40427. /**
  40428. * The mesh used to display where the user is going to teleport.
  40429. */
  40430. /**
  40431. * Sets the mesh to be used to display where the user is going to teleport.
  40432. */
  40433. teleportationTarget: Mesh;
  40434. /**
  40435. * 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
  40436. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40437. * See http://doc.babylonjs.com/resources/baking_transformations
  40438. */
  40439. gazeTrackerMesh: Mesh;
  40440. /**
  40441. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40442. */
  40443. updateGazeTrackerScale: boolean;
  40444. /**
  40445. * If the gaze trackers color should be updated when selecting meshes
  40446. */
  40447. updateGazeTrackerColor: boolean;
  40448. /**
  40449. * The gaze tracking mesh corresponding to the left controller
  40450. */
  40451. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40452. /**
  40453. * The gaze tracking mesh corresponding to the right controller
  40454. */
  40455. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40456. /**
  40457. * If the ray of the gaze should be displayed.
  40458. */
  40459. /**
  40460. * Sets if the ray of the gaze should be displayed.
  40461. */
  40462. displayGaze: boolean;
  40463. /**
  40464. * If the ray of the LaserPointer should be displayed.
  40465. */
  40466. /**
  40467. * Sets if the ray of the LaserPointer should be displayed.
  40468. */
  40469. displayLaserPointer: boolean;
  40470. /**
  40471. * The deviceOrientationCamera used as the camera when not in VR.
  40472. */
  40473. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40474. /**
  40475. * Based on the current WebVR support, returns the current VR camera used.
  40476. */
  40477. readonly currentVRCamera: Nullable<Camera>;
  40478. /**
  40479. * The webVRCamera which is used when in VR.
  40480. */
  40481. readonly webVRCamera: WebVRFreeCamera;
  40482. /**
  40483. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40484. */
  40485. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40486. private readonly _teleportationRequestInitiated;
  40487. /**
  40488. * Instantiates a VRExperienceHelper.
  40489. * Helps to quickly add VR support to an existing scene.
  40490. * @param scene The scene the VRExperienceHelper belongs to.
  40491. * @param webVROptions Options to modify the vr experience helper's behavior.
  40492. */
  40493. constructor(scene: Scene,
  40494. /** Options to modify the vr experience helper's behavior. */
  40495. webVROptions?: VRExperienceHelperOptions);
  40496. private _onDefaultMeshLoaded;
  40497. private _onResize;
  40498. private _onFullscreenChange;
  40499. /**
  40500. * Gets a value indicating if we are currently in VR mode.
  40501. */
  40502. readonly isInVRMode: boolean;
  40503. private onVrDisplayPresentChange;
  40504. private onVRDisplayChanged;
  40505. private moveButtonToBottomRight;
  40506. private displayVRButton;
  40507. private updateButtonVisibility;
  40508. private _cachedAngularSensibility;
  40509. /**
  40510. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40511. * Otherwise, will use the fullscreen API.
  40512. */
  40513. enterVR(): void;
  40514. /**
  40515. * Attempt to exit VR, or fullscreen.
  40516. */
  40517. exitVR(): void;
  40518. /**
  40519. * The position of the vr experience helper.
  40520. */
  40521. /**
  40522. * Sets the position of the vr experience helper.
  40523. */
  40524. position: Vector3;
  40525. /**
  40526. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40527. */
  40528. enableInteractions(): void;
  40529. private readonly _noControllerIsActive;
  40530. private beforeRender;
  40531. private _isTeleportationFloor;
  40532. /**
  40533. * Adds a floor mesh to be used for teleportation.
  40534. * @param floorMesh the mesh to be used for teleportation.
  40535. */
  40536. addFloorMesh(floorMesh: Mesh): void;
  40537. /**
  40538. * Removes a floor mesh from being used for teleportation.
  40539. * @param floorMesh the mesh to be removed.
  40540. */
  40541. removeFloorMesh(floorMesh: Mesh): void;
  40542. /**
  40543. * Enables interactions and teleportation using the VR controllers and gaze.
  40544. * @param vrTeleportationOptions options to modify teleportation behavior.
  40545. */
  40546. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40547. private _onNewGamepadConnected;
  40548. private _tryEnableInteractionOnController;
  40549. private _onNewGamepadDisconnected;
  40550. private _enableInteractionOnController;
  40551. private _checkTeleportWithRay;
  40552. private _checkRotate;
  40553. private _checkTeleportBackwards;
  40554. private _enableTeleportationOnController;
  40555. private _createTeleportationCircles;
  40556. private _displayTeleportationTarget;
  40557. private _hideTeleportationTarget;
  40558. private _rotateCamera;
  40559. private _moveTeleportationSelectorTo;
  40560. private _workingVector;
  40561. private _workingQuaternion;
  40562. private _workingMatrix;
  40563. /**
  40564. * Teleports the users feet to the desired location
  40565. * @param location The location where the user's feet should be placed
  40566. */
  40567. teleportCamera(location: Vector3): void;
  40568. private _convertNormalToDirectionOfRay;
  40569. private _castRayAndSelectObject;
  40570. private _notifySelectedMeshUnselected;
  40571. /**
  40572. * Sets the color of the laser ray from the vr controllers.
  40573. * @param color new color for the ray.
  40574. */
  40575. changeLaserColor(color: Color3): void;
  40576. /**
  40577. * Sets the color of the ray from the vr headsets gaze.
  40578. * @param color new color for the ray.
  40579. */
  40580. changeGazeColor(color: Color3): void;
  40581. /**
  40582. * Exits VR and disposes of the vr experience helper
  40583. */
  40584. dispose(): void;
  40585. /**
  40586. * Gets the name of the VRExperienceHelper class
  40587. * @returns "VRExperienceHelper"
  40588. */
  40589. getClassName(): string;
  40590. }
  40591. }
  40592. declare module "babylonjs/Cameras/VR/index" {
  40593. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40594. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40595. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40596. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40597. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40598. export * from "babylonjs/Cameras/VR/webVRCamera";
  40599. }
  40600. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40601. import { Observable } from "babylonjs/Misc/observable";
  40602. import { Nullable } from "babylonjs/types";
  40603. import { IDisposable, Scene } from "babylonjs/scene";
  40604. import { Vector3 } from "babylonjs/Maths/math";
  40605. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40606. import { Ray } from "babylonjs/Culling/ray";
  40607. /**
  40608. * Manages an XRSession
  40609. * @see https://doc.babylonjs.com/how_to/webxr
  40610. */
  40611. export class WebXRSessionManager implements IDisposable {
  40612. private scene;
  40613. /**
  40614. * Fires every time a new xrFrame arrives which can be used to update the camera
  40615. */
  40616. onXRFrameObservable: Observable<any>;
  40617. /**
  40618. * Fires when the xr session is ended either by the device or manually done
  40619. */
  40620. onXRSessionEnded: Observable<any>;
  40621. /** @hidden */
  40622. _xrSession: XRSession;
  40623. /** @hidden */
  40624. _frameOfReference: XRFrameOfReference;
  40625. /** @hidden */
  40626. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40627. /** @hidden */
  40628. _currentXRFrame: Nullable<XRFrame>;
  40629. private _xrNavigator;
  40630. private _xrDevice;
  40631. private _tmpMatrix;
  40632. /**
  40633. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40634. * @param scene The scene which the session should be created for
  40635. */
  40636. constructor(scene: Scene);
  40637. /**
  40638. * Initializes the manager
  40639. * After initialization enterXR can be called to start an XR session
  40640. * @returns Promise which resolves after it is initialized
  40641. */
  40642. initializeAsync(): Promise<void>;
  40643. /**
  40644. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40645. * @param sessionCreationOptions xr options to create the session with
  40646. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40647. * @returns Promise which resolves after it enters XR
  40648. */
  40649. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40650. /**
  40651. * Stops the xrSession and restores the renderloop
  40652. * @returns Promise which resolves after it exits XR
  40653. */
  40654. exitXRAsync(): Promise<void>;
  40655. /**
  40656. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40657. * @param ray ray to cast into the environment
  40658. * @returns Promise which resolves with a collision point in the environment if it exists
  40659. */
  40660. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40661. /**
  40662. * Checks if a session would be supported for the creation options specified
  40663. * @param options creation options to check if they are supported
  40664. * @returns true if supported
  40665. */
  40666. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40667. /**
  40668. * @hidden
  40669. * Converts the render layer of xrSession to a render target
  40670. * @param session session to create render target for
  40671. * @param scene scene the new render target should be created for
  40672. */
  40673. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40674. /**
  40675. * Disposes of the session manager
  40676. */
  40677. dispose(): void;
  40678. }
  40679. }
  40680. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40681. import { Scene } from "babylonjs/scene";
  40682. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40683. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40684. /**
  40685. * WebXR Camera which holds the views for the xrSession
  40686. * @see https://doc.babylonjs.com/how_to/webxr
  40687. */
  40688. export class WebXRCamera extends FreeCamera {
  40689. private static _TmpMatrix;
  40690. /**
  40691. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40692. * @param name the name of the camera
  40693. * @param scene the scene to add the camera to
  40694. */
  40695. constructor(name: string, scene: Scene);
  40696. private _updateNumberOfRigCameras;
  40697. /** @hidden */
  40698. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40699. /**
  40700. * Updates the cameras position from the current pose information of the XR session
  40701. * @param xrSessionManager the session containing pose information
  40702. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40703. */
  40704. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40705. }
  40706. }
  40707. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40708. import { Nullable } from "babylonjs/types";
  40709. import { Observable } from "babylonjs/Misc/observable";
  40710. import { IDisposable, Scene } from "babylonjs/scene";
  40711. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40713. import { Ray } from "babylonjs/Culling/ray";
  40714. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40715. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40716. /**
  40717. * States of the webXR experience
  40718. */
  40719. export enum WebXRState {
  40720. /**
  40721. * Transitioning to being in XR mode
  40722. */
  40723. ENTERING_XR = 0,
  40724. /**
  40725. * Transitioning to non XR mode
  40726. */
  40727. EXITING_XR = 1,
  40728. /**
  40729. * In XR mode and presenting
  40730. */
  40731. IN_XR = 2,
  40732. /**
  40733. * Not entered XR mode
  40734. */
  40735. NOT_IN_XR = 3
  40736. }
  40737. /**
  40738. * Helper class used to enable XR
  40739. * @see https://doc.babylonjs.com/how_to/webxr
  40740. */
  40741. export class WebXRExperienceHelper implements IDisposable {
  40742. private scene;
  40743. /**
  40744. * 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
  40745. */
  40746. container: AbstractMesh;
  40747. /**
  40748. * Camera used to render xr content
  40749. */
  40750. camera: WebXRCamera;
  40751. /**
  40752. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40753. */
  40754. state: WebXRState;
  40755. private _setState;
  40756. private static _TmpVector;
  40757. /**
  40758. * Fires when the state of the experience helper has changed
  40759. */
  40760. onStateChangedObservable: Observable<WebXRState>;
  40761. /** @hidden */
  40762. _sessionManager: WebXRSessionManager;
  40763. private _nonVRCamera;
  40764. private _originalSceneAutoClear;
  40765. private _supported;
  40766. /**
  40767. * Creates the experience helper
  40768. * @param scene the scene to attach the experience helper to
  40769. * @returns a promise for the experience helper
  40770. */
  40771. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40772. /**
  40773. * Creates a WebXRExperienceHelper
  40774. * @param scene The scene the helper should be created in
  40775. */
  40776. private constructor();
  40777. /**
  40778. * Exits XR mode and returns the scene to its original state
  40779. * @returns promise that resolves after xr mode has exited
  40780. */
  40781. exitXRAsync(): Promise<void>;
  40782. /**
  40783. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40784. * @param sessionCreationOptions options for the XR session
  40785. * @param frameOfReference frame of reference of the XR session
  40786. * @returns promise that resolves after xr mode has entered
  40787. */
  40788. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40789. /**
  40790. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40791. * @param ray ray to cast into the environment
  40792. * @returns Promise which resolves with a collision point in the environment if it exists
  40793. */
  40794. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40795. /**
  40796. * Updates the global position of the camera by moving the camera's container
  40797. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40798. * @param position The desired global position of the camera
  40799. */
  40800. setPositionOfCameraUsingContainer(position: Vector3): void;
  40801. /**
  40802. * Rotates the xr camera by rotating the camera's container around the camera's position
  40803. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40804. * @param rotation the desired quaternion rotation to apply to the camera
  40805. */
  40806. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40807. /**
  40808. * Checks if the creation options are supported by the xr session
  40809. * @param options creation options
  40810. * @returns true if supported
  40811. */
  40812. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40813. /**
  40814. * Disposes of the experience helper
  40815. */
  40816. dispose(): void;
  40817. }
  40818. }
  40819. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40820. import { Nullable } from "babylonjs/types";
  40821. import { Observable } from "babylonjs/Misc/observable";
  40822. import { IDisposable, Scene } from "babylonjs/scene";
  40823. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40824. /**
  40825. * Button which can be used to enter a different mode of XR
  40826. */
  40827. export class WebXREnterExitUIButton {
  40828. /** button element */
  40829. element: HTMLElement;
  40830. /** XR initialization options for the button */
  40831. initializationOptions: XRSessionCreationOptions;
  40832. /**
  40833. * Creates a WebXREnterExitUIButton
  40834. * @param element button element
  40835. * @param initializationOptions XR initialization options for the button
  40836. */
  40837. constructor(
  40838. /** button element */
  40839. element: HTMLElement,
  40840. /** XR initialization options for the button */
  40841. initializationOptions: XRSessionCreationOptions);
  40842. /**
  40843. * Overwritable function which can be used to update the button's visuals when the state changes
  40844. * @param activeButton the current active button in the UI
  40845. */
  40846. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40847. }
  40848. /**
  40849. * Options to create the webXR UI
  40850. */
  40851. export class WebXREnterExitUIOptions {
  40852. /**
  40853. * Context to enter xr with
  40854. */
  40855. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40856. /**
  40857. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40858. */
  40859. customButtons?: Array<WebXREnterExitUIButton>;
  40860. }
  40861. /**
  40862. * UI to allow the user to enter/exit XR mode
  40863. */
  40864. export class WebXREnterExitUI implements IDisposable {
  40865. private scene;
  40866. private _overlay;
  40867. private _buttons;
  40868. private _activeButton;
  40869. /**
  40870. * Fired every time the active button is changed.
  40871. *
  40872. * When xr is entered via a button that launches xr that button will be the callback parameter
  40873. *
  40874. * When exiting xr the callback parameter will be null)
  40875. */
  40876. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40877. /**
  40878. * Creates UI to allow the user to enter/exit XR mode
  40879. * @param scene the scene to add the ui to
  40880. * @param helper the xr experience helper to enter/exit xr with
  40881. * @param options options to configure the UI
  40882. * @returns the created ui
  40883. */
  40884. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40885. private constructor();
  40886. private _updateButtons;
  40887. /**
  40888. * Disposes of the object
  40889. */
  40890. dispose(): void;
  40891. }
  40892. }
  40893. declare module "babylonjs/Cameras/XR/webXRInput" {
  40894. import { IDisposable, Scene } from "babylonjs/scene";
  40895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40896. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40897. /**
  40898. * Represents an XR input
  40899. */
  40900. export class WebXRController {
  40901. /**
  40902. * 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
  40903. */
  40904. grip?: AbstractMesh;
  40905. /**
  40906. * Pointer which can be used to select objects or attach a visible laser to
  40907. */
  40908. pointer: AbstractMesh;
  40909. /**
  40910. * Creates the controller
  40911. * @see https://doc.babylonjs.com/how_to/webxr
  40912. * @param scene the scene which the controller should be associated to
  40913. */
  40914. constructor(scene: Scene);
  40915. /**
  40916. * Disposes of the object
  40917. */
  40918. dispose(): void;
  40919. }
  40920. /**
  40921. * XR input used to track XR inputs such as controllers/rays
  40922. */
  40923. export class WebXRInput implements IDisposable {
  40924. private helper;
  40925. /**
  40926. * XR controllers being tracked
  40927. */
  40928. controllers: Array<WebXRController>;
  40929. private _tmpMatrix;
  40930. private _frameObserver;
  40931. /**
  40932. * Initializes the WebXRInput
  40933. * @param helper experience helper which the input should be created for
  40934. */
  40935. constructor(helper: WebXRExperienceHelper);
  40936. /**
  40937. * Disposes of the object
  40938. */
  40939. dispose(): void;
  40940. }
  40941. }
  40942. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40943. import { Nullable } from "babylonjs/types";
  40944. import { IDisposable } from "babylonjs/scene";
  40945. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40946. /**
  40947. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40948. */
  40949. export class WebXRManagedOutputCanvas implements IDisposable {
  40950. private _canvas;
  40951. /**
  40952. * xrpresent context of the canvas which can be used to display/mirror xr content
  40953. */
  40954. canvasContext: Nullable<WebGLRenderingContext>;
  40955. /**
  40956. * Initializes the canvas to be added/removed upon entering/exiting xr
  40957. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40958. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40959. */
  40960. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40961. /**
  40962. * Disposes of the object
  40963. */
  40964. dispose(): void;
  40965. private _setManagedOutputCanvas;
  40966. private _addCanvas;
  40967. private _removeCanvas;
  40968. }
  40969. }
  40970. declare module "babylonjs/Cameras/XR/index" {
  40971. export * from "babylonjs/Cameras/XR/webXRCamera";
  40972. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40973. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40974. export * from "babylonjs/Cameras/XR/webXRInput";
  40975. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40976. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40977. }
  40978. declare module "babylonjs/Cameras/RigModes/index" {
  40979. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40980. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40981. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40982. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40983. }
  40984. declare module "babylonjs/Cameras/index" {
  40985. export * from "babylonjs/Cameras/Inputs/index";
  40986. export * from "babylonjs/Cameras/cameraInputsManager";
  40987. export * from "babylonjs/Cameras/camera";
  40988. export * from "babylonjs/Cameras/targetCamera";
  40989. export * from "babylonjs/Cameras/freeCamera";
  40990. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40991. export * from "babylonjs/Cameras/touchCamera";
  40992. export * from "babylonjs/Cameras/arcRotateCamera";
  40993. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40994. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40995. export * from "babylonjs/Cameras/flyCamera";
  40996. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40997. export * from "babylonjs/Cameras/followCamera";
  40998. export * from "babylonjs/Cameras/gamepadCamera";
  40999. export * from "babylonjs/Cameras/Stereoscopic/index";
  41000. export * from "babylonjs/Cameras/universalCamera";
  41001. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41002. export * from "babylonjs/Cameras/VR/index";
  41003. export * from "babylonjs/Cameras/XR/index";
  41004. export * from "babylonjs/Cameras/RigModes/index";
  41005. }
  41006. declare module "babylonjs/Collisions/index" {
  41007. export * from "babylonjs/Collisions/collider";
  41008. export * from "babylonjs/Collisions/collisionCoordinator";
  41009. export * from "babylonjs/Collisions/pickingInfo";
  41010. export * from "babylonjs/Collisions/intersectionInfo";
  41011. }
  41012. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41013. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41014. import { Vector3, Plane } from "babylonjs/Maths/math";
  41015. import { Ray } from "babylonjs/Culling/ray";
  41016. /**
  41017. * Contains an array of blocks representing the octree
  41018. */
  41019. export interface IOctreeContainer<T> {
  41020. /**
  41021. * Blocks within the octree
  41022. */
  41023. blocks: Array<OctreeBlock<T>>;
  41024. }
  41025. /**
  41026. * Class used to store a cell in an octree
  41027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41028. */
  41029. export class OctreeBlock<T> {
  41030. /**
  41031. * Gets the content of the current block
  41032. */
  41033. entries: T[];
  41034. /**
  41035. * Gets the list of block children
  41036. */
  41037. blocks: Array<OctreeBlock<T>>;
  41038. private _depth;
  41039. private _maxDepth;
  41040. private _capacity;
  41041. private _minPoint;
  41042. private _maxPoint;
  41043. private _boundingVectors;
  41044. private _creationFunc;
  41045. /**
  41046. * Creates a new block
  41047. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41048. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41049. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41050. * @param depth defines the current depth of this block in the octree
  41051. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41052. * @param creationFunc defines a callback to call when an element is added to the block
  41053. */
  41054. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41055. /**
  41056. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41057. */
  41058. readonly capacity: number;
  41059. /**
  41060. * Gets the minimum vector (in world space) of the block's bounding box
  41061. */
  41062. readonly minPoint: Vector3;
  41063. /**
  41064. * Gets the maximum vector (in world space) of the block's bounding box
  41065. */
  41066. readonly maxPoint: Vector3;
  41067. /**
  41068. * Add a new element to this block
  41069. * @param entry defines the element to add
  41070. */
  41071. addEntry(entry: T): void;
  41072. /**
  41073. * Remove an element from this block
  41074. * @param entry defines the element to remove
  41075. */
  41076. removeEntry(entry: T): void;
  41077. /**
  41078. * Add an array of elements to this block
  41079. * @param entries defines the array of elements to add
  41080. */
  41081. addEntries(entries: T[]): void;
  41082. /**
  41083. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41084. * @param frustumPlanes defines the frustum planes to test
  41085. * @param selection defines the array to store current content if selection is positive
  41086. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41087. */
  41088. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41089. /**
  41090. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41091. * @param sphereCenter defines the bounding sphere center
  41092. * @param sphereRadius defines the bounding sphere radius
  41093. * @param selection defines the array to store current content if selection is positive
  41094. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41095. */
  41096. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41097. /**
  41098. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41099. * @param ray defines the ray to test with
  41100. * @param selection defines the array to store current content if selection is positive
  41101. */
  41102. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41103. /**
  41104. * Subdivide the content into child blocks (this block will then be empty)
  41105. */
  41106. createInnerBlocks(): void;
  41107. /**
  41108. * @hidden
  41109. */
  41110. 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;
  41111. }
  41112. }
  41113. declare module "babylonjs/Culling/Octrees/octree" {
  41114. import { SmartArray } from "babylonjs/Misc/smartArray";
  41115. import { Vector3, Plane } from "babylonjs/Maths/math";
  41116. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41118. import { Ray } from "babylonjs/Culling/ray";
  41119. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41120. /**
  41121. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41122. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41123. */
  41124. export class Octree<T> {
  41125. /** 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.) */
  41126. maxDepth: number;
  41127. /**
  41128. * Blocks within the octree containing objects
  41129. */
  41130. blocks: Array<OctreeBlock<T>>;
  41131. /**
  41132. * Content stored in the octree
  41133. */
  41134. dynamicContent: T[];
  41135. private _maxBlockCapacity;
  41136. private _selectionContent;
  41137. private _creationFunc;
  41138. /**
  41139. * Creates a octree
  41140. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41141. * @param creationFunc function to be used to instatiate the octree
  41142. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41143. * @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.)
  41144. */
  41145. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41146. /** 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.) */
  41147. maxDepth?: number);
  41148. /**
  41149. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41150. * @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);
  41151. * @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);
  41152. * @param entries meshes to be added to the octree blocks
  41153. */
  41154. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41155. /**
  41156. * Adds a mesh to the octree
  41157. * @param entry Mesh to add to the octree
  41158. */
  41159. addMesh(entry: T): void;
  41160. /**
  41161. * Remove an element from the octree
  41162. * @param entry defines the element to remove
  41163. */
  41164. removeMesh(entry: T): void;
  41165. /**
  41166. * Selects an array of meshes within the frustum
  41167. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41168. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41169. * @returns array of meshes within the frustum
  41170. */
  41171. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41172. /**
  41173. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41174. * @param sphereCenter defines the bounding sphere center
  41175. * @param sphereRadius defines the bounding sphere radius
  41176. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41177. * @returns an array of objects that intersect the sphere
  41178. */
  41179. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41180. /**
  41181. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41182. * @param ray defines the ray to test with
  41183. * @returns array of intersected objects
  41184. */
  41185. intersectsRay(ray: Ray): SmartArray<T>;
  41186. /**
  41187. * Adds a mesh into the octree block if it intersects the block
  41188. */
  41189. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41190. /**
  41191. * Adds a submesh into the octree block if it intersects the block
  41192. */
  41193. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41194. }
  41195. }
  41196. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41197. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41198. import { Scene } from "babylonjs/scene";
  41199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41201. import { Collider } from "babylonjs/Collisions/collider";
  41202. import { Ray } from "babylonjs/Culling/ray";
  41203. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41204. module "babylonjs/scene" {
  41205. interface Scene {
  41206. /**
  41207. * @hidden
  41208. * Backing Filed
  41209. */
  41210. _selectionOctree: Octree<AbstractMesh>;
  41211. /**
  41212. * Gets the octree used to boost mesh selection (picking)
  41213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41214. */
  41215. selectionOctree: Octree<AbstractMesh>;
  41216. /**
  41217. * Creates or updates the octree used to boost selection (picking)
  41218. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41219. * @param maxCapacity defines the maximum capacity per leaf
  41220. * @param maxDepth defines the maximum depth of the octree
  41221. * @returns an octree of AbstractMesh
  41222. */
  41223. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41224. }
  41225. }
  41226. module "babylonjs/Meshes/abstractMesh" {
  41227. interface AbstractMesh {
  41228. /**
  41229. * @hidden
  41230. * Backing Field
  41231. */
  41232. _submeshesOctree: Octree<SubMesh>;
  41233. /**
  41234. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41235. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41236. * @param maxCapacity defines the maximum size of each block (64 by default)
  41237. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41238. * @returns the new octree
  41239. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41241. */
  41242. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41243. }
  41244. }
  41245. /**
  41246. * Defines the octree scene component responsible to manage any octrees
  41247. * in a given scene.
  41248. */
  41249. export class OctreeSceneComponent {
  41250. /**
  41251. * The component name helpfull to identify the component in the list of scene components.
  41252. */
  41253. readonly name: string;
  41254. /**
  41255. * The scene the component belongs to.
  41256. */
  41257. scene: Scene;
  41258. /**
  41259. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41260. */
  41261. readonly checksIsEnabled: boolean;
  41262. /**
  41263. * Creates a new instance of the component for the given scene
  41264. * @param scene Defines the scene to register the component in
  41265. */
  41266. constructor(scene: Scene);
  41267. /**
  41268. * Registers the component in a given scene
  41269. */
  41270. register(): void;
  41271. /**
  41272. * Return the list of active meshes
  41273. * @returns the list of active meshes
  41274. */
  41275. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41276. /**
  41277. * Return the list of active sub meshes
  41278. * @param mesh The mesh to get the candidates sub meshes from
  41279. * @returns the list of active sub meshes
  41280. */
  41281. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41282. private _tempRay;
  41283. /**
  41284. * Return the list of sub meshes intersecting with a given local ray
  41285. * @param mesh defines the mesh to find the submesh for
  41286. * @param localRay defines the ray in local space
  41287. * @returns the list of intersecting sub meshes
  41288. */
  41289. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41290. /**
  41291. * Return the list of sub meshes colliding with a collider
  41292. * @param mesh defines the mesh to find the submesh for
  41293. * @param collider defines the collider to evaluate the collision against
  41294. * @returns the list of colliding sub meshes
  41295. */
  41296. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41297. /**
  41298. * Rebuilds the elements related to this component in case of
  41299. * context lost for instance.
  41300. */
  41301. rebuild(): void;
  41302. /**
  41303. * Disposes the component and the associated ressources.
  41304. */
  41305. dispose(): void;
  41306. }
  41307. }
  41308. declare module "babylonjs/Culling/Octrees/index" {
  41309. export * from "babylonjs/Culling/Octrees/octree";
  41310. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41311. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41312. }
  41313. declare module "babylonjs/Culling/index" {
  41314. export * from "babylonjs/Culling/boundingBox";
  41315. export * from "babylonjs/Culling/boundingInfo";
  41316. export * from "babylonjs/Culling/boundingSphere";
  41317. export * from "babylonjs/Culling/Octrees/index";
  41318. export * from "babylonjs/Culling/ray";
  41319. }
  41320. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41321. import { IDisposable, Scene } from "babylonjs/scene";
  41322. import { Nullable } from "babylonjs/types";
  41323. import { Observable } from "babylonjs/Misc/observable";
  41324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41325. /**
  41326. * Renders a layer on top of an existing scene
  41327. */
  41328. export class UtilityLayerRenderer implements IDisposable {
  41329. /** the original scene that will be rendered on top of */
  41330. originalScene: Scene;
  41331. private _pointerCaptures;
  41332. private _lastPointerEvents;
  41333. private static _DefaultUtilityLayer;
  41334. private static _DefaultKeepDepthUtilityLayer;
  41335. /**
  41336. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41337. */
  41338. pickUtilitySceneFirst: boolean;
  41339. /**
  41340. * 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)
  41341. */
  41342. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41343. /**
  41344. * 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)
  41345. */
  41346. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41347. /**
  41348. * The scene that is rendered on top of the original scene
  41349. */
  41350. utilityLayerScene: Scene;
  41351. /**
  41352. * If the utility layer should automatically be rendered on top of existing scene
  41353. */
  41354. shouldRender: boolean;
  41355. /**
  41356. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41357. */
  41358. onlyCheckPointerDownEvents: boolean;
  41359. /**
  41360. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41361. */
  41362. processAllEvents: boolean;
  41363. /**
  41364. * Observable raised when the pointer move from the utility layer scene to the main scene
  41365. */
  41366. onPointerOutObservable: Observable<number>;
  41367. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41368. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41369. private _afterRenderObserver;
  41370. private _sceneDisposeObserver;
  41371. private _originalPointerObserver;
  41372. /**
  41373. * Instantiates a UtilityLayerRenderer
  41374. * @param originalScene the original scene that will be rendered on top of
  41375. * @param handleEvents boolean indicating if the utility layer should handle events
  41376. */
  41377. constructor(
  41378. /** the original scene that will be rendered on top of */
  41379. originalScene: Scene, handleEvents?: boolean);
  41380. private _notifyObservers;
  41381. /**
  41382. * Renders the utility layers scene on top of the original scene
  41383. */
  41384. render(): void;
  41385. /**
  41386. * Disposes of the renderer
  41387. */
  41388. dispose(): void;
  41389. private _updateCamera;
  41390. }
  41391. }
  41392. declare module "babylonjs/Gizmos/gizmo" {
  41393. import { Nullable } from "babylonjs/types";
  41394. import { IDisposable } from "babylonjs/scene";
  41395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41396. import { Mesh } from "babylonjs/Meshes/mesh";
  41397. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41398. /**
  41399. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41400. */
  41401. export class Gizmo implements IDisposable {
  41402. /** The utility layer the gizmo will be added to */
  41403. gizmoLayer: UtilityLayerRenderer;
  41404. /**
  41405. * The root mesh of the gizmo
  41406. */
  41407. protected _rootMesh: Mesh;
  41408. private _attachedMesh;
  41409. /**
  41410. * Ratio for the scale of the gizmo (Default: 1)
  41411. */
  41412. scaleRatio: number;
  41413. private _tmpMatrix;
  41414. /**
  41415. * If a custom mesh has been set (Default: false)
  41416. */
  41417. protected _customMeshSet: boolean;
  41418. /**
  41419. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41420. * * When set, interactions will be enabled
  41421. */
  41422. attachedMesh: Nullable<AbstractMesh>;
  41423. /**
  41424. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41425. * @param mesh The mesh to replace the default mesh of the gizmo
  41426. */
  41427. setCustomMesh(mesh: Mesh): void;
  41428. /**
  41429. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41430. */
  41431. updateGizmoRotationToMatchAttachedMesh: boolean;
  41432. /**
  41433. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41434. */
  41435. updateGizmoPositionToMatchAttachedMesh: boolean;
  41436. /**
  41437. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41438. */
  41439. protected _updateScale: boolean;
  41440. protected _interactionsEnabled: boolean;
  41441. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41442. private _beforeRenderObserver;
  41443. /**
  41444. * Creates a gizmo
  41445. * @param gizmoLayer The utility layer the gizmo will be added to
  41446. */
  41447. constructor(
  41448. /** The utility layer the gizmo will be added to */
  41449. gizmoLayer?: UtilityLayerRenderer);
  41450. private _tempVector;
  41451. /**
  41452. * @hidden
  41453. * Updates the gizmo to match the attached mesh's position/rotation
  41454. */
  41455. protected _update(): void;
  41456. /**
  41457. * Disposes of the gizmo
  41458. */
  41459. dispose(): void;
  41460. }
  41461. }
  41462. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41463. import { Observable } from "babylonjs/Misc/observable";
  41464. import { Nullable } from "babylonjs/types";
  41465. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41468. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41469. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41470. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41471. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41472. import { Scene } from "babylonjs/scene";
  41473. /**
  41474. * Single axis drag gizmo
  41475. */
  41476. export class AxisDragGizmo extends Gizmo {
  41477. /**
  41478. * Drag behavior responsible for the gizmos dragging interactions
  41479. */
  41480. dragBehavior: PointerDragBehavior;
  41481. private _pointerObserver;
  41482. /**
  41483. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41484. */
  41485. snapDistance: number;
  41486. /**
  41487. * Event that fires each time the gizmo snaps to a new location.
  41488. * * snapDistance is the the change in distance
  41489. */
  41490. onSnapObservable: Observable<{
  41491. snapDistance: number;
  41492. }>;
  41493. /** @hidden */
  41494. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41495. /** @hidden */
  41496. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  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 { TransformNode } from "babylonjs/Meshes/transformNode";
  41516. /**
  41517. * The Axes viewer will show 3 axes in a specific point in space
  41518. */
  41519. export class AxesViewer {
  41520. private _xAxis;
  41521. private _yAxis;
  41522. private _zAxis;
  41523. private _scaleLinesFactor;
  41524. private _instanced;
  41525. /**
  41526. * Gets the hosting scene
  41527. */
  41528. scene: Scene;
  41529. /**
  41530. * Gets or sets a number used to scale line length
  41531. */
  41532. scaleLines: number;
  41533. /** Gets the node hierarchy used to render x-axis */
  41534. readonly xAxis: TransformNode;
  41535. /** Gets the node hierarchy used to render y-axis */
  41536. readonly yAxis: TransformNode;
  41537. /** Gets the node hierarchy used to render z-axis */
  41538. readonly zAxis: TransformNode;
  41539. /**
  41540. * Creates a new AxesViewer
  41541. * @param scene defines the hosting scene
  41542. * @param scaleLines defines a number used to scale line length (1 by default)
  41543. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41544. * @param xAxis defines the node hierarchy used to render the x-axis
  41545. * @param yAxis defines the node hierarchy used to render the y-axis
  41546. * @param zAxis defines the node hierarchy used to render the z-axis
  41547. */
  41548. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41549. /**
  41550. * Force the viewer to update
  41551. * @param position defines the position of the viewer
  41552. * @param xaxis defines the x axis of the viewer
  41553. * @param yaxis defines the y axis of the viewer
  41554. * @param zaxis defines the z axis of the viewer
  41555. */
  41556. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41557. /**
  41558. * Creates an instance of this axes viewer.
  41559. * @returns a new axes viewer with instanced meshes
  41560. */
  41561. createInstance(): AxesViewer;
  41562. /** Releases resources */
  41563. dispose(): void;
  41564. private static _SetRenderingGroupId;
  41565. }
  41566. }
  41567. declare module "babylonjs/Debug/boneAxesViewer" {
  41568. import { Nullable } from "babylonjs/types";
  41569. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41570. import { Vector3 } from "babylonjs/Maths/math";
  41571. import { Mesh } from "babylonjs/Meshes/mesh";
  41572. import { Bone } from "babylonjs/Bones/bone";
  41573. import { Scene } from "babylonjs/scene";
  41574. /**
  41575. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41576. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41577. */
  41578. export class BoneAxesViewer extends AxesViewer {
  41579. /**
  41580. * Gets or sets the target mesh where to display the axes viewer
  41581. */
  41582. mesh: Nullable<Mesh>;
  41583. /**
  41584. * Gets or sets the target bone where to display the axes viewer
  41585. */
  41586. bone: Nullable<Bone>;
  41587. /** Gets current position */
  41588. pos: Vector3;
  41589. /** Gets direction of X axis */
  41590. xaxis: Vector3;
  41591. /** Gets direction of Y axis */
  41592. yaxis: Vector3;
  41593. /** Gets direction of Z axis */
  41594. zaxis: Vector3;
  41595. /**
  41596. * Creates a new BoneAxesViewer
  41597. * @param scene defines the hosting scene
  41598. * @param bone defines the target bone
  41599. * @param mesh defines the target mesh
  41600. * @param scaleLines defines a scaling factor for line length (1 by default)
  41601. */
  41602. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41603. /**
  41604. * Force the viewer to update
  41605. */
  41606. update(): void;
  41607. /** Releases resources */
  41608. dispose(): void;
  41609. }
  41610. }
  41611. declare module "babylonjs/Debug/debugLayer" {
  41612. import { Observable } from "babylonjs/Misc/observable";
  41613. import { Scene } from "babylonjs/scene";
  41614. /**
  41615. * Interface used to define scene explorer extensibility option
  41616. */
  41617. export interface IExplorerExtensibilityOption {
  41618. /**
  41619. * Define the option label
  41620. */
  41621. label: string;
  41622. /**
  41623. * Defines the action to execute on click
  41624. */
  41625. action: (entity: any) => void;
  41626. }
  41627. /**
  41628. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41629. */
  41630. export interface IExplorerExtensibilityGroup {
  41631. /**
  41632. * Defines a predicate to test if a given type mut be extended
  41633. */
  41634. predicate: (entity: any) => boolean;
  41635. /**
  41636. * Gets the list of options added to a type
  41637. */
  41638. entries: IExplorerExtensibilityOption[];
  41639. }
  41640. /**
  41641. * Interface used to define the options to use to create the Inspector
  41642. */
  41643. export interface IInspectorOptions {
  41644. /**
  41645. * Display in overlay mode (default: false)
  41646. */
  41647. overlay?: boolean;
  41648. /**
  41649. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41650. */
  41651. globalRoot?: HTMLElement;
  41652. /**
  41653. * Display the Scene explorer
  41654. */
  41655. showExplorer?: boolean;
  41656. /**
  41657. * Display the property inspector
  41658. */
  41659. showInspector?: boolean;
  41660. /**
  41661. * Display in embed mode (both panes on the right)
  41662. */
  41663. embedMode?: boolean;
  41664. /**
  41665. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41666. */
  41667. handleResize?: boolean;
  41668. /**
  41669. * Allow the panes to popup (default: true)
  41670. */
  41671. enablePopup?: boolean;
  41672. /**
  41673. * Allow the panes to be closed by users (default: true)
  41674. */
  41675. enableClose?: boolean;
  41676. /**
  41677. * Optional list of extensibility entries
  41678. */
  41679. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41680. }
  41681. module "babylonjs/scene" {
  41682. interface Scene {
  41683. /**
  41684. * @hidden
  41685. * Backing field
  41686. */
  41687. _debugLayer: DebugLayer;
  41688. /**
  41689. * Gets the debug layer (aka Inspector) associated with the scene
  41690. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41691. */
  41692. debugLayer: DebugLayer;
  41693. }
  41694. }
  41695. /**
  41696. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41697. * what is happening in your scene
  41698. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41699. */
  41700. export class DebugLayer {
  41701. /**
  41702. * Define the url to get the inspector script from.
  41703. * By default it uses the babylonjs CDN.
  41704. * @ignoreNaming
  41705. */
  41706. static InspectorURL: string;
  41707. private _scene;
  41708. private BJSINSPECTOR;
  41709. /**
  41710. * Observable triggered when a property is changed through the inspector.
  41711. */
  41712. onPropertyChangedObservable: Observable<{
  41713. object: any;
  41714. property: string;
  41715. value: any;
  41716. initialValue: any;
  41717. }>;
  41718. /**
  41719. * Instantiates a new debug layer.
  41720. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41721. * what is happening in your scene
  41722. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41723. * @param scene Defines the scene to inspect
  41724. */
  41725. constructor(scene: Scene);
  41726. /** Creates the inspector window. */
  41727. private _createInspector;
  41728. /** Get the inspector from bundle or global */
  41729. private _getGlobalInspector;
  41730. /**
  41731. * Get if the inspector is visible or not.
  41732. * @returns true if visible otherwise, false
  41733. */
  41734. isVisible(): boolean;
  41735. /**
  41736. * Hide the inspector and close its window.
  41737. */
  41738. hide(): void;
  41739. /**
  41740. * Launch the debugLayer.
  41741. * @param config Define the configuration of the inspector
  41742. */
  41743. show(config?: IInspectorOptions): void;
  41744. }
  41745. }
  41746. declare module "babylonjs/Debug/physicsViewer" {
  41747. import { Nullable } from "babylonjs/types";
  41748. import { Scene } from "babylonjs/scene";
  41749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41750. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41751. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41752. /**
  41753. * Used to show the physics impostor around the specific mesh
  41754. */
  41755. export class PhysicsViewer {
  41756. /** @hidden */
  41757. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41758. /** @hidden */
  41759. protected _meshes: Array<Nullable<AbstractMesh>>;
  41760. /** @hidden */
  41761. protected _scene: Nullable<Scene>;
  41762. /** @hidden */
  41763. protected _numMeshes: number;
  41764. /** @hidden */
  41765. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41766. private _renderFunction;
  41767. private _utilityLayer;
  41768. private _debugBoxMesh;
  41769. private _debugSphereMesh;
  41770. private _debugMaterial;
  41771. /**
  41772. * Creates a new PhysicsViewer
  41773. * @param scene defines the hosting scene
  41774. */
  41775. constructor(scene: Scene);
  41776. /** @hidden */
  41777. protected _updateDebugMeshes(): void;
  41778. /**
  41779. * Renders a specified physic impostor
  41780. * @param impostor defines the impostor to render
  41781. * @returns the new debug mesh used to render the impostor
  41782. */
  41783. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41784. /**
  41785. * Hides a specified physic impostor
  41786. * @param impostor defines the impostor to hide
  41787. */
  41788. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41789. private _getDebugMaterial;
  41790. private _getDebugBoxMesh;
  41791. private _getDebugSphereMesh;
  41792. private _getDebugMesh;
  41793. /** Releases all resources */
  41794. dispose(): void;
  41795. }
  41796. }
  41797. declare module "babylonjs/Debug/rayHelper" {
  41798. import { Nullable } from "babylonjs/types";
  41799. import { Ray } from "babylonjs/Culling/ray";
  41800. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41801. import { Scene } from "babylonjs/scene";
  41802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41803. /**
  41804. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41805. * in order to better appreciate the issue one might have.
  41806. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41807. */
  41808. export class RayHelper {
  41809. /**
  41810. * Defines the ray we are currently tryin to visualize.
  41811. */
  41812. ray: Nullable<Ray>;
  41813. private _renderPoints;
  41814. private _renderLine;
  41815. private _renderFunction;
  41816. private _scene;
  41817. private _updateToMeshFunction;
  41818. private _attachedToMesh;
  41819. private _meshSpaceDirection;
  41820. private _meshSpaceOrigin;
  41821. /**
  41822. * Helper function to create a colored helper in a scene in one line.
  41823. * @param ray Defines the ray we are currently tryin to visualize
  41824. * @param scene Defines the scene the ray is used in
  41825. * @param color Defines the color we want to see the ray in
  41826. * @returns The newly created ray helper.
  41827. */
  41828. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41829. /**
  41830. * Instantiate a new ray helper.
  41831. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41832. * in order to better appreciate the issue one might have.
  41833. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41834. * @param ray Defines the ray we are currently tryin to visualize
  41835. */
  41836. constructor(ray: Ray);
  41837. /**
  41838. * Shows the ray we are willing to debug.
  41839. * @param scene Defines the scene the ray needs to be rendered in
  41840. * @param color Defines the color the ray needs to be rendered in
  41841. */
  41842. show(scene: Scene, color?: Color3): void;
  41843. /**
  41844. * Hides the ray we are debugging.
  41845. */
  41846. hide(): void;
  41847. private _render;
  41848. /**
  41849. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41850. * @param mesh Defines the mesh we want the helper attached to
  41851. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41852. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41853. * @param length Defines the length of the ray
  41854. */
  41855. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41856. /**
  41857. * Detach the ray helper from the mesh it has previously been attached to.
  41858. */
  41859. detachFromMesh(): void;
  41860. private _updateToMesh;
  41861. /**
  41862. * Dispose the helper and release its associated resources.
  41863. */
  41864. dispose(): void;
  41865. }
  41866. }
  41867. declare module "babylonjs/Debug/skeletonViewer" {
  41868. import { Color3 } from "babylonjs/Maths/math";
  41869. import { Scene } from "babylonjs/scene";
  41870. import { Nullable } from "babylonjs/types";
  41871. import { Skeleton } from "babylonjs/Bones/skeleton";
  41872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41873. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41874. /**
  41875. * Class used to render a debug view of a given skeleton
  41876. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41877. */
  41878. export class SkeletonViewer {
  41879. /** defines the skeleton to render */
  41880. skeleton: Skeleton;
  41881. /** defines the mesh attached to the skeleton */
  41882. mesh: AbstractMesh;
  41883. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41884. autoUpdateBonesMatrices: boolean;
  41885. /** defines the rendering group id to use with the viewer */
  41886. renderingGroupId: number;
  41887. /** Gets or sets the color used to render the skeleton */
  41888. color: Color3;
  41889. private _scene;
  41890. private _debugLines;
  41891. private _debugMesh;
  41892. private _isEnabled;
  41893. private _renderFunction;
  41894. private _utilityLayer;
  41895. /**
  41896. * Returns the mesh used to render the bones
  41897. */
  41898. readonly debugMesh: Nullable<LinesMesh>;
  41899. /**
  41900. * Creates a new SkeletonViewer
  41901. * @param skeleton defines the skeleton to render
  41902. * @param mesh defines the mesh attached to the skeleton
  41903. * @param scene defines the hosting scene
  41904. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41905. * @param renderingGroupId defines the rendering group id to use with the viewer
  41906. */
  41907. constructor(
  41908. /** defines the skeleton to render */
  41909. skeleton: Skeleton,
  41910. /** defines the mesh attached to the skeleton */
  41911. mesh: AbstractMesh, scene: Scene,
  41912. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41913. autoUpdateBonesMatrices?: boolean,
  41914. /** defines the rendering group id to use with the viewer */
  41915. renderingGroupId?: number);
  41916. /** Gets or sets a boolean indicating if the viewer is enabled */
  41917. isEnabled: boolean;
  41918. private _getBonePosition;
  41919. private _getLinesForBonesWithLength;
  41920. private _getLinesForBonesNoLength;
  41921. /** Update the viewer to sync with current skeleton state */
  41922. update(): void;
  41923. /** Release associated resources */
  41924. dispose(): void;
  41925. }
  41926. }
  41927. declare module "babylonjs/Debug/index" {
  41928. export * from "babylonjs/Debug/axesViewer";
  41929. export * from "babylonjs/Debug/boneAxesViewer";
  41930. export * from "babylonjs/Debug/debugLayer";
  41931. export * from "babylonjs/Debug/physicsViewer";
  41932. export * from "babylonjs/Debug/rayHelper";
  41933. export * from "babylonjs/Debug/skeletonViewer";
  41934. }
  41935. declare module "babylonjs/Engines/nullEngine" {
  41936. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41937. import { Scene } from "babylonjs/scene";
  41938. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41939. import { Engine } from "babylonjs/Engines/engine";
  41940. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41941. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41942. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41943. import { Effect } from "babylonjs/Materials/effect";
  41944. /**
  41945. * Options to create the null engine
  41946. */
  41947. export class NullEngineOptions {
  41948. /**
  41949. * Render width (Default: 512)
  41950. */
  41951. renderWidth: number;
  41952. /**
  41953. * Render height (Default: 256)
  41954. */
  41955. renderHeight: number;
  41956. /**
  41957. * Texture size (Default: 512)
  41958. */
  41959. textureSize: number;
  41960. /**
  41961. * If delta time between frames should be constant
  41962. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41963. */
  41964. deterministicLockstep: boolean;
  41965. /**
  41966. * Maximum about of steps between frames (Default: 4)
  41967. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41968. */
  41969. lockstepMaxSteps: number;
  41970. }
  41971. /**
  41972. * The null engine class provides support for headless version of babylon.js.
  41973. * This can be used in server side scenario or for testing purposes
  41974. */
  41975. export class NullEngine extends Engine {
  41976. private _options;
  41977. /**
  41978. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41979. */
  41980. isDeterministicLockStep(): boolean;
  41981. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41982. getLockstepMaxSteps(): number;
  41983. /**
  41984. * Sets hardware scaling, used to save performance if needed
  41985. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41986. */
  41987. getHardwareScalingLevel(): number;
  41988. constructor(options?: NullEngineOptions);
  41989. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41990. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41991. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41992. getRenderWidth(useScreen?: boolean): number;
  41993. getRenderHeight(useScreen?: boolean): number;
  41994. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41995. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41996. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41997. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41998. bindSamplers(effect: Effect): void;
  41999. enableEffect(effect: Effect): void;
  42000. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42001. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42002. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42003. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42004. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42005. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42006. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42007. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42008. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42009. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42010. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42011. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42012. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42013. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42014. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42015. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42016. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42017. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42018. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42019. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42020. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42021. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42022. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42023. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42024. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42025. bindBuffers(vertexBuffers: {
  42026. [key: string]: VertexBuffer;
  42027. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42028. wipeCaches(bruteForce?: boolean): void;
  42029. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42030. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42031. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42032. /** @hidden */
  42033. _createTexture(): WebGLTexture;
  42034. /** @hidden */
  42035. _releaseTexture(texture: InternalTexture): void;
  42036. 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;
  42037. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42038. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42039. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42040. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42041. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42042. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42043. areAllEffectsReady(): boolean;
  42044. /**
  42045. * @hidden
  42046. * Get the current error code of the webGL context
  42047. * @returns the error code
  42048. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42049. */
  42050. getError(): number;
  42051. /** @hidden */
  42052. _getUnpackAlignement(): number;
  42053. /** @hidden */
  42054. _unpackFlipY(value: boolean): void;
  42055. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42056. /**
  42057. * Updates a dynamic vertex buffer.
  42058. * @param vertexBuffer the vertex buffer to update
  42059. * @param data the data used to update the vertex buffer
  42060. * @param byteOffset the byte offset of the data (optional)
  42061. * @param byteLength the byte length of the data (optional)
  42062. */
  42063. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42064. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42065. /** @hidden */
  42066. _bindTexture(channel: number, texture: InternalTexture): void;
  42067. /** @hidden */
  42068. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42069. releaseEffects(): void;
  42070. displayLoadingUI(): void;
  42071. hideLoadingUI(): void;
  42072. /** @hidden */
  42073. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42074. /** @hidden */
  42075. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42076. /** @hidden */
  42077. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42078. /** @hidden */
  42079. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42080. }
  42081. }
  42082. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42083. import { Nullable, int } from "babylonjs/types";
  42084. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42085. /** @hidden */
  42086. export class _OcclusionDataStorage {
  42087. /** @hidden */
  42088. occlusionInternalRetryCounter: number;
  42089. /** @hidden */
  42090. isOcclusionQueryInProgress: boolean;
  42091. /** @hidden */
  42092. isOccluded: boolean;
  42093. /** @hidden */
  42094. occlusionRetryCount: number;
  42095. /** @hidden */
  42096. occlusionType: number;
  42097. /** @hidden */
  42098. occlusionQueryAlgorithmType: number;
  42099. }
  42100. module "babylonjs/Engines/engine" {
  42101. interface Engine {
  42102. /**
  42103. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42104. * @return the new query
  42105. */
  42106. createQuery(): WebGLQuery;
  42107. /**
  42108. * Delete and release a webGL query
  42109. * @param query defines the query to delete
  42110. * @return the current engine
  42111. */
  42112. deleteQuery(query: WebGLQuery): Engine;
  42113. /**
  42114. * Check if a given query has resolved and got its value
  42115. * @param query defines the query to check
  42116. * @returns true if the query got its value
  42117. */
  42118. isQueryResultAvailable(query: WebGLQuery): boolean;
  42119. /**
  42120. * Gets the value of a given query
  42121. * @param query defines the query to check
  42122. * @returns the value of the query
  42123. */
  42124. getQueryResult(query: WebGLQuery): number;
  42125. /**
  42126. * Initiates an occlusion query
  42127. * @param algorithmType defines the algorithm to use
  42128. * @param query defines the query to use
  42129. * @returns the current engine
  42130. * @see http://doc.babylonjs.com/features/occlusionquery
  42131. */
  42132. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42133. /**
  42134. * Ends an occlusion query
  42135. * @see http://doc.babylonjs.com/features/occlusionquery
  42136. * @param algorithmType defines the algorithm to use
  42137. * @returns the current engine
  42138. */
  42139. endOcclusionQuery(algorithmType: number): Engine;
  42140. /**
  42141. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42142. * Please note that only one query can be issued at a time
  42143. * @returns a time token used to track the time span
  42144. */
  42145. startTimeQuery(): Nullable<_TimeToken>;
  42146. /**
  42147. * Ends a time query
  42148. * @param token defines the token used to measure the time span
  42149. * @returns the time spent (in ns)
  42150. */
  42151. endTimeQuery(token: _TimeToken): int;
  42152. /** @hidden */
  42153. _currentNonTimestampToken: Nullable<_TimeToken>;
  42154. /** @hidden */
  42155. _createTimeQuery(): WebGLQuery;
  42156. /** @hidden */
  42157. _deleteTimeQuery(query: WebGLQuery): void;
  42158. /** @hidden */
  42159. _getGlAlgorithmType(algorithmType: number): number;
  42160. /** @hidden */
  42161. _getTimeQueryResult(query: WebGLQuery): any;
  42162. /** @hidden */
  42163. _getTimeQueryAvailability(query: WebGLQuery): any;
  42164. }
  42165. }
  42166. module "babylonjs/Meshes/abstractMesh" {
  42167. interface AbstractMesh {
  42168. /**
  42169. * Backing filed
  42170. * @hidden
  42171. */
  42172. __occlusionDataStorage: _OcclusionDataStorage;
  42173. /**
  42174. * Access property
  42175. * @hidden
  42176. */
  42177. _occlusionDataStorage: _OcclusionDataStorage;
  42178. /**
  42179. * 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.
  42180. * The default value is -1 which means don't break the query and wait till the result
  42181. * @see http://doc.babylonjs.com/features/occlusionquery
  42182. */
  42183. occlusionRetryCount: number;
  42184. /**
  42185. * 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:
  42186. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42187. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42188. * * 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.
  42189. * @see http://doc.babylonjs.com/features/occlusionquery
  42190. */
  42191. occlusionType: number;
  42192. /**
  42193. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42194. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42195. * * 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.
  42196. * @see http://doc.babylonjs.com/features/occlusionquery
  42197. */
  42198. occlusionQueryAlgorithmType: number;
  42199. /**
  42200. * 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
  42201. * @see http://doc.babylonjs.com/features/occlusionquery
  42202. */
  42203. isOccluded: boolean;
  42204. /**
  42205. * Flag to check the progress status of the query
  42206. * @see http://doc.babylonjs.com/features/occlusionquery
  42207. */
  42208. isOcclusionQueryInProgress: boolean;
  42209. }
  42210. }
  42211. }
  42212. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42213. import { Nullable } from "babylonjs/types";
  42214. /** @hidden */
  42215. export var _forceTransformFeedbackToBundle: boolean;
  42216. module "babylonjs/Engines/engine" {
  42217. interface Engine {
  42218. /**
  42219. * Creates a webGL transform feedback object
  42220. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42221. * @returns the webGL transform feedback object
  42222. */
  42223. createTransformFeedback(): WebGLTransformFeedback;
  42224. /**
  42225. * Delete a webGL transform feedback object
  42226. * @param value defines the webGL transform feedback object to delete
  42227. */
  42228. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42229. /**
  42230. * Bind a webGL transform feedback object to the webgl context
  42231. * @param value defines the webGL transform feedback object to bind
  42232. */
  42233. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42234. /**
  42235. * Begins a transform feedback operation
  42236. * @param usePoints defines if points or triangles must be used
  42237. */
  42238. beginTransformFeedback(usePoints: boolean): void;
  42239. /**
  42240. * Ends a transform feedback operation
  42241. */
  42242. endTransformFeedback(): void;
  42243. /**
  42244. * Specify the varyings to use with transform feedback
  42245. * @param program defines the associated webGL program
  42246. * @param value defines the list of strings representing the varying names
  42247. */
  42248. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42249. /**
  42250. * Bind a webGL buffer for a transform feedback operation
  42251. * @param value defines the webGL buffer to bind
  42252. */
  42253. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42254. }
  42255. }
  42256. }
  42257. declare module "babylonjs/Engines/Extensions/index" {
  42258. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42259. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42260. }
  42261. declare module "babylonjs/Engines/index" {
  42262. export * from "babylonjs/Engines/constants";
  42263. export * from "babylonjs/Engines/engine";
  42264. export * from "babylonjs/Engines/engineStore";
  42265. export * from "babylonjs/Engines/nullEngine";
  42266. export * from "babylonjs/Engines/Extensions/index";
  42267. }
  42268. declare module "babylonjs/Events/clipboardEvents" {
  42269. /**
  42270. * Gather the list of clipboard event types as constants.
  42271. */
  42272. export class ClipboardEventTypes {
  42273. /**
  42274. * The clipboard event is fired when a copy command is active (pressed).
  42275. */
  42276. static readonly COPY: number;
  42277. /**
  42278. * The clipboard event is fired when a cut command is active (pressed).
  42279. */
  42280. static readonly CUT: number;
  42281. /**
  42282. * The clipboard event is fired when a paste command is active (pressed).
  42283. */
  42284. static readonly PASTE: number;
  42285. }
  42286. /**
  42287. * This class is used to store clipboard related info for the onClipboardObservable event.
  42288. */
  42289. export class ClipboardInfo {
  42290. /**
  42291. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42292. */
  42293. type: number;
  42294. /**
  42295. * Defines the related dom event
  42296. */
  42297. event: ClipboardEvent;
  42298. /**
  42299. *Creates an instance of ClipboardInfo.
  42300. * @param {number} type
  42301. * @param {ClipboardEvent} event
  42302. */
  42303. constructor(
  42304. /**
  42305. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42306. */
  42307. type: number,
  42308. /**
  42309. * Defines the related dom event
  42310. */
  42311. event: ClipboardEvent);
  42312. /**
  42313. * Get the clipboard event's type from the keycode.
  42314. * @param keyCode Defines the keyCode for the current keyboard event.
  42315. * @return {number}
  42316. */
  42317. static GetTypeFromCharacter(keyCode: number): number;
  42318. }
  42319. }
  42320. declare module "babylonjs/Events/index" {
  42321. export * from "babylonjs/Events/keyboardEvents";
  42322. export * from "babylonjs/Events/pointerEvents";
  42323. export * from "babylonjs/Events/clipboardEvents";
  42324. }
  42325. declare module "babylonjs/Loading/sceneLoader" {
  42326. import { Observable } from "babylonjs/Misc/observable";
  42327. import { Nullable } from "babylonjs/types";
  42328. import { Scene } from "babylonjs/scene";
  42329. import { Engine } from "babylonjs/Engines/engine";
  42330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42331. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42332. import { AssetContainer } from "babylonjs/assetContainer";
  42333. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42334. import { Skeleton } from "babylonjs/Bones/skeleton";
  42335. /**
  42336. * Class used to represent data loading progression
  42337. */
  42338. export class SceneLoaderProgressEvent {
  42339. /** defines if data length to load can be evaluated */
  42340. readonly lengthComputable: boolean;
  42341. /** defines the loaded data length */
  42342. readonly loaded: number;
  42343. /** defines the data length to load */
  42344. readonly total: number;
  42345. /**
  42346. * Create a new progress event
  42347. * @param lengthComputable defines if data length to load can be evaluated
  42348. * @param loaded defines the loaded data length
  42349. * @param total defines the data length to load
  42350. */
  42351. constructor(
  42352. /** defines if data length to load can be evaluated */
  42353. lengthComputable: boolean,
  42354. /** defines the loaded data length */
  42355. loaded: number,
  42356. /** defines the data length to load */
  42357. total: number);
  42358. /**
  42359. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42360. * @param event defines the source event
  42361. * @returns a new SceneLoaderProgressEvent
  42362. */
  42363. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42364. }
  42365. /**
  42366. * Interface used by SceneLoader plugins to define supported file extensions
  42367. */
  42368. export interface ISceneLoaderPluginExtensions {
  42369. /**
  42370. * Defines the list of supported extensions
  42371. */
  42372. [extension: string]: {
  42373. isBinary: boolean;
  42374. };
  42375. }
  42376. /**
  42377. * Interface used by SceneLoader plugin factory
  42378. */
  42379. export interface ISceneLoaderPluginFactory {
  42380. /**
  42381. * Defines the name of the factory
  42382. */
  42383. name: string;
  42384. /**
  42385. * Function called to create a new plugin
  42386. * @return the new plugin
  42387. */
  42388. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42389. /**
  42390. * Boolean indicating if the plugin can direct load specific data
  42391. */
  42392. canDirectLoad?: (data: string) => boolean;
  42393. }
  42394. /**
  42395. * Interface used to define a SceneLoader plugin
  42396. */
  42397. export interface ISceneLoaderPlugin {
  42398. /**
  42399. * The friendly name of this plugin.
  42400. */
  42401. name: string;
  42402. /**
  42403. * The file extensions supported by this plugin.
  42404. */
  42405. extensions: string | ISceneLoaderPluginExtensions;
  42406. /**
  42407. * Import meshes into a scene.
  42408. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42409. * @param scene The scene to import into
  42410. * @param data The data to import
  42411. * @param rootUrl The root url for scene and resources
  42412. * @param meshes The meshes array to import into
  42413. * @param particleSystems The particle systems array to import into
  42414. * @param skeletons The skeletons array to import into
  42415. * @param onError The callback when import fails
  42416. * @returns True if successful or false otherwise
  42417. */
  42418. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42419. /**
  42420. * Load into a scene.
  42421. * @param scene The scene to load into
  42422. * @param data The data to import
  42423. * @param rootUrl The root url for scene and resources
  42424. * @param onError The callback when import fails
  42425. * @returns true if successful or false otherwise
  42426. */
  42427. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42428. /**
  42429. * The callback that returns true if the data can be directly loaded.
  42430. */
  42431. canDirectLoad?: (data: string) => boolean;
  42432. /**
  42433. * The callback that allows custom handling of the root url based on the response url.
  42434. */
  42435. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42436. /**
  42437. * Load into an asset container.
  42438. * @param scene The scene to load into
  42439. * @param data The data to import
  42440. * @param rootUrl The root url for scene and resources
  42441. * @param onError The callback when import fails
  42442. * @returns The loaded asset container
  42443. */
  42444. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42445. }
  42446. /**
  42447. * Interface used to define an async SceneLoader plugin
  42448. */
  42449. export interface ISceneLoaderPluginAsync {
  42450. /**
  42451. * The friendly name of this plugin.
  42452. */
  42453. name: string;
  42454. /**
  42455. * The file extensions supported by this plugin.
  42456. */
  42457. extensions: string | ISceneLoaderPluginExtensions;
  42458. /**
  42459. * Import meshes into a scene.
  42460. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42461. * @param scene The scene to import into
  42462. * @param data The data to import
  42463. * @param rootUrl The root url for scene and resources
  42464. * @param onProgress The callback when the load progresses
  42465. * @param fileName Defines the name of the file to load
  42466. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42467. */
  42468. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42469. meshes: AbstractMesh[];
  42470. particleSystems: IParticleSystem[];
  42471. skeletons: Skeleton[];
  42472. animationGroups: AnimationGroup[];
  42473. }>;
  42474. /**
  42475. * Load into a scene.
  42476. * @param scene The scene to load into
  42477. * @param data The data to import
  42478. * @param rootUrl The root url for scene and resources
  42479. * @param onProgress The callback when the load progresses
  42480. * @param fileName Defines the name of the file to load
  42481. * @returns Nothing
  42482. */
  42483. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42484. /**
  42485. * The callback that returns true if the data can be directly loaded.
  42486. */
  42487. canDirectLoad?: (data: string) => boolean;
  42488. /**
  42489. * The callback that allows custom handling of the root url based on the response url.
  42490. */
  42491. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42492. /**
  42493. * Load into an asset container.
  42494. * @param scene The scene to load into
  42495. * @param data The data to import
  42496. * @param rootUrl The root url for scene and resources
  42497. * @param onProgress The callback when the load progresses
  42498. * @param fileName Defines the name of the file to load
  42499. * @returns The loaded asset container
  42500. */
  42501. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42502. }
  42503. /**
  42504. * Class used to load scene from various file formats using registered plugins
  42505. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42506. */
  42507. export class SceneLoader {
  42508. /**
  42509. * No logging while loading
  42510. */
  42511. static readonly NO_LOGGING: number;
  42512. /**
  42513. * Minimal logging while loading
  42514. */
  42515. static readonly MINIMAL_LOGGING: number;
  42516. /**
  42517. * Summary logging while loading
  42518. */
  42519. static readonly SUMMARY_LOGGING: number;
  42520. /**
  42521. * Detailled logging while loading
  42522. */
  42523. static readonly DETAILED_LOGGING: number;
  42524. /**
  42525. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42526. */
  42527. static ForceFullSceneLoadingForIncremental: boolean;
  42528. /**
  42529. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42530. */
  42531. static ShowLoadingScreen: boolean;
  42532. /**
  42533. * Defines the current logging level (while loading the scene)
  42534. * @ignorenaming
  42535. */
  42536. static loggingLevel: number;
  42537. /**
  42538. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42539. */
  42540. static CleanBoneMatrixWeights: boolean;
  42541. /**
  42542. * Event raised when a plugin is used to load a scene
  42543. */
  42544. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42545. private static _registeredPlugins;
  42546. private static _getDefaultPlugin;
  42547. private static _getPluginForExtension;
  42548. private static _getPluginForDirectLoad;
  42549. private static _getPluginForFilename;
  42550. private static _getDirectLoad;
  42551. private static _loadData;
  42552. private static _getFileInfo;
  42553. /**
  42554. * Gets a plugin that can load the given extension
  42555. * @param extension defines the extension to load
  42556. * @returns a plugin or null if none works
  42557. */
  42558. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42559. /**
  42560. * Gets a boolean indicating that the given extension can be loaded
  42561. * @param extension defines the extension to load
  42562. * @returns true if the extension is supported
  42563. */
  42564. static IsPluginForExtensionAvailable(extension: string): boolean;
  42565. /**
  42566. * Adds a new plugin to the list of registered plugins
  42567. * @param plugin defines the plugin to add
  42568. */
  42569. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42570. /**
  42571. * Import meshes into a scene
  42572. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42573. * @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)
  42574. * @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)
  42575. * @param scene the instance of BABYLON.Scene to append to
  42576. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42577. * @param onProgress a callback with a progress event for each file being loaded
  42578. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42579. * @param pluginExtension the extension used to determine the plugin
  42580. * @returns The loaded plugin
  42581. */
  42582. 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>;
  42583. /**
  42584. * Import meshes into a scene
  42585. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42586. * @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)
  42587. * @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)
  42588. * @param scene the instance of BABYLON.Scene to append to
  42589. * @param onProgress a callback with a progress event for each file being loaded
  42590. * @param pluginExtension the extension used to determine the plugin
  42591. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42592. */
  42593. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42594. meshes: AbstractMesh[];
  42595. particleSystems: IParticleSystem[];
  42596. skeletons: Skeleton[];
  42597. animationGroups: AnimationGroup[];
  42598. }>;
  42599. /**
  42600. * Load a scene
  42601. * @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)
  42602. * @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)
  42603. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42604. * @param onSuccess a callback with the scene when import succeeds
  42605. * @param onProgress a callback with a progress event for each file being loaded
  42606. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42607. * @param pluginExtension the extension used to determine the plugin
  42608. * @returns The loaded plugin
  42609. */
  42610. 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>;
  42611. /**
  42612. * Load a scene
  42613. * @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)
  42614. * @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)
  42615. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42616. * @param onProgress a callback with a progress event for each file being loaded
  42617. * @param pluginExtension the extension used to determine the plugin
  42618. * @returns The loaded scene
  42619. */
  42620. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42621. /**
  42622. * Append a scene
  42623. * @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)
  42624. * @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)
  42625. * @param scene is the instance of BABYLON.Scene to append to
  42626. * @param onSuccess a callback with the scene when import succeeds
  42627. * @param onProgress a callback with a progress event for each file being loaded
  42628. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42629. * @param pluginExtension the extension used to determine the plugin
  42630. * @returns The loaded plugin
  42631. */
  42632. 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>;
  42633. /**
  42634. * Append a scene
  42635. * @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)
  42636. * @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)
  42637. * @param scene is the instance of BABYLON.Scene to append to
  42638. * @param onProgress a callback with a progress event for each file being loaded
  42639. * @param pluginExtension the extension used to determine the plugin
  42640. * @returns The given scene
  42641. */
  42642. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42643. /**
  42644. * Load a scene into an asset container
  42645. * @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)
  42646. * @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)
  42647. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42648. * @param onSuccess a callback with the scene when import succeeds
  42649. * @param onProgress a callback with a progress event for each file being loaded
  42650. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42651. * @param pluginExtension the extension used to determine the plugin
  42652. * @returns The loaded plugin
  42653. */
  42654. 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>;
  42655. /**
  42656. * Load a scene into an asset container
  42657. * @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)
  42658. * @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)
  42659. * @param scene is the instance of Scene to append to
  42660. * @param onProgress a callback with a progress event for each file being loaded
  42661. * @param pluginExtension the extension used to determine the plugin
  42662. * @returns The loaded asset container
  42663. */
  42664. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42665. }
  42666. }
  42667. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42668. import { Scene } from "babylonjs/scene";
  42669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42671. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42672. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42673. /**
  42674. * Google Daydream controller
  42675. */
  42676. export class DaydreamController extends WebVRController {
  42677. /**
  42678. * Base Url for the controller model.
  42679. */
  42680. static MODEL_BASE_URL: string;
  42681. /**
  42682. * File name for the controller model.
  42683. */
  42684. static MODEL_FILENAME: string;
  42685. /**
  42686. * Gamepad Id prefix used to identify Daydream Controller.
  42687. */
  42688. static readonly GAMEPAD_ID_PREFIX: string;
  42689. /**
  42690. * Creates a new DaydreamController from a gamepad
  42691. * @param vrGamepad the gamepad that the controller should be created from
  42692. */
  42693. constructor(vrGamepad: any);
  42694. /**
  42695. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42696. * @param scene scene in which to add meshes
  42697. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42698. */
  42699. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42700. /**
  42701. * Called once for each button that changed state since the last frame
  42702. * @param buttonIdx Which button index changed
  42703. * @param state New state of the button
  42704. * @param changes Which properties on the state changed since last frame
  42705. */
  42706. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42707. }
  42708. }
  42709. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42710. import { Scene } from "babylonjs/scene";
  42711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42712. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42713. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42714. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42715. /**
  42716. * Gear VR Controller
  42717. */
  42718. export class GearVRController extends WebVRController {
  42719. /**
  42720. * Base Url for the controller model.
  42721. */
  42722. static MODEL_BASE_URL: string;
  42723. /**
  42724. * File name for the controller model.
  42725. */
  42726. static MODEL_FILENAME: string;
  42727. /**
  42728. * Gamepad Id prefix used to identify this controller.
  42729. */
  42730. static readonly GAMEPAD_ID_PREFIX: string;
  42731. private readonly _buttonIndexToObservableNameMap;
  42732. /**
  42733. * Creates a new GearVRController from a gamepad
  42734. * @param vrGamepad the gamepad that the controller should be created from
  42735. */
  42736. constructor(vrGamepad: any);
  42737. /**
  42738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42739. * @param scene scene in which to add meshes
  42740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42741. */
  42742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42743. /**
  42744. * Called once for each button that changed state since the last frame
  42745. * @param buttonIdx Which button index changed
  42746. * @param state New state of the button
  42747. * @param changes Which properties on the state changed since last frame
  42748. */
  42749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42750. }
  42751. }
  42752. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42753. import { Scene } from "babylonjs/scene";
  42754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42755. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42756. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42757. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42758. /**
  42759. * Generic Controller
  42760. */
  42761. export class GenericController extends WebVRController {
  42762. /**
  42763. * Base Url for the controller model.
  42764. */
  42765. static readonly MODEL_BASE_URL: string;
  42766. /**
  42767. * File name for the controller model.
  42768. */
  42769. static readonly MODEL_FILENAME: string;
  42770. /**
  42771. * Creates a new GenericController from a gamepad
  42772. * @param vrGamepad the gamepad that the controller should be created from
  42773. */
  42774. constructor(vrGamepad: any);
  42775. /**
  42776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42777. * @param scene scene in which to add meshes
  42778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42779. */
  42780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42781. /**
  42782. * Called once for each button that changed state since the last frame
  42783. * @param buttonIdx Which button index changed
  42784. * @param state New state of the button
  42785. * @param changes Which properties on the state changed since last frame
  42786. */
  42787. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42788. }
  42789. }
  42790. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42791. import { Observable } from "babylonjs/Misc/observable";
  42792. import { Scene } from "babylonjs/scene";
  42793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42794. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42795. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42796. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42797. /**
  42798. * Oculus Touch Controller
  42799. */
  42800. export class OculusTouchController extends WebVRController {
  42801. /**
  42802. * Base Url for the controller model.
  42803. */
  42804. static MODEL_BASE_URL: string;
  42805. /**
  42806. * File name for the left controller model.
  42807. */
  42808. static MODEL_LEFT_FILENAME: string;
  42809. /**
  42810. * File name for the right controller model.
  42811. */
  42812. static MODEL_RIGHT_FILENAME: string;
  42813. /**
  42814. * Fired when the secondary trigger on this controller is modified
  42815. */
  42816. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42817. /**
  42818. * Fired when the thumb rest on this controller is modified
  42819. */
  42820. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42821. /**
  42822. * Creates a new OculusTouchController from a gamepad
  42823. * @param vrGamepad the gamepad that the controller should be created from
  42824. */
  42825. constructor(vrGamepad: any);
  42826. /**
  42827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42828. * @param scene scene in which to add meshes
  42829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42830. */
  42831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42832. /**
  42833. * Fired when the A button on this controller is modified
  42834. */
  42835. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42836. /**
  42837. * Fired when the B button on this controller is modified
  42838. */
  42839. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42840. /**
  42841. * Fired when the X button on this controller is modified
  42842. */
  42843. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42844. /**
  42845. * Fired when the Y button on this controller is modified
  42846. */
  42847. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42848. /**
  42849. * Called once for each button that changed state since the last frame
  42850. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42851. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42852. * 2) secondary trigger (same)
  42853. * 3) A (right) X (left), touch, pressed = value
  42854. * 4) B / Y
  42855. * 5) thumb rest
  42856. * @param buttonIdx Which button index changed
  42857. * @param state New state of the button
  42858. * @param changes Which properties on the state changed since last frame
  42859. */
  42860. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42861. }
  42862. }
  42863. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42864. import { Scene } from "babylonjs/scene";
  42865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42866. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42867. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42868. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42869. import { Observable } from "babylonjs/Misc/observable";
  42870. /**
  42871. * Vive Controller
  42872. */
  42873. export class ViveController extends WebVRController {
  42874. /**
  42875. * Base Url for the controller model.
  42876. */
  42877. static MODEL_BASE_URL: string;
  42878. /**
  42879. * File name for the controller model.
  42880. */
  42881. static MODEL_FILENAME: string;
  42882. /**
  42883. * Creates a new ViveController from a gamepad
  42884. * @param vrGamepad the gamepad that the controller should be created from
  42885. */
  42886. constructor(vrGamepad: any);
  42887. /**
  42888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42889. * @param scene scene in which to add meshes
  42890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42891. */
  42892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42893. /**
  42894. * Fired when the left button on this controller is modified
  42895. */
  42896. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42897. /**
  42898. * Fired when the right button on this controller is modified
  42899. */
  42900. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42901. /**
  42902. * Fired when the menu button on this controller is modified
  42903. */
  42904. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42905. /**
  42906. * Called once for each button that changed state since the last frame
  42907. * Vive mapping:
  42908. * 0: touchpad
  42909. * 1: trigger
  42910. * 2: left AND right buttons
  42911. * 3: menu button
  42912. * @param buttonIdx Which button index changed
  42913. * @param state New state of the button
  42914. * @param changes Which properties on the state changed since last frame
  42915. */
  42916. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42917. }
  42918. }
  42919. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42920. import { Observable } from "babylonjs/Misc/observable";
  42921. import { Scene } from "babylonjs/scene";
  42922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42923. import { Ray } from "babylonjs/Culling/ray";
  42924. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42925. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42926. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42927. /**
  42928. * Defines the WindowsMotionController object that the state of the windows motion controller
  42929. */
  42930. export class WindowsMotionController extends WebVRController {
  42931. /**
  42932. * The base url used to load the left and right controller models
  42933. */
  42934. static MODEL_BASE_URL: string;
  42935. /**
  42936. * The name of the left controller model file
  42937. */
  42938. static MODEL_LEFT_FILENAME: string;
  42939. /**
  42940. * The name of the right controller model file
  42941. */
  42942. static MODEL_RIGHT_FILENAME: string;
  42943. /**
  42944. * The controller name prefix for this controller type
  42945. */
  42946. static readonly GAMEPAD_ID_PREFIX: string;
  42947. /**
  42948. * The controller id pattern for this controller type
  42949. */
  42950. private static readonly GAMEPAD_ID_PATTERN;
  42951. private _loadedMeshInfo;
  42952. private readonly _mapping;
  42953. /**
  42954. * Fired when the trackpad on this controller is clicked
  42955. */
  42956. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42957. /**
  42958. * Fired when the trackpad on this controller is modified
  42959. */
  42960. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42961. /**
  42962. * The current x and y values of this controller's trackpad
  42963. */
  42964. trackpad: StickValues;
  42965. /**
  42966. * Creates a new WindowsMotionController from a gamepad
  42967. * @param vrGamepad the gamepad that the controller should be created from
  42968. */
  42969. constructor(vrGamepad: any);
  42970. /**
  42971. * Fired when the trigger on this controller is modified
  42972. */
  42973. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42974. /**
  42975. * Fired when the menu button on this controller is modified
  42976. */
  42977. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42978. /**
  42979. * Fired when the grip button on this controller is modified
  42980. */
  42981. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42982. /**
  42983. * Fired when the thumbstick button on this controller is modified
  42984. */
  42985. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42986. /**
  42987. * Fired when the touchpad button on this controller is modified
  42988. */
  42989. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42990. /**
  42991. * Fired when the touchpad values on this controller are modified
  42992. */
  42993. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42994. private _updateTrackpad;
  42995. /**
  42996. * Called once per frame by the engine.
  42997. */
  42998. update(): void;
  42999. /**
  43000. * Called once for each button that changed state since the last frame
  43001. * @param buttonIdx Which button index changed
  43002. * @param state New state of the button
  43003. * @param changes Which properties on the state changed since last frame
  43004. */
  43005. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43006. /**
  43007. * Moves the buttons on the controller mesh based on their current state
  43008. * @param buttonName the name of the button to move
  43009. * @param buttonValue the value of the button which determines the buttons new position
  43010. */
  43011. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43012. /**
  43013. * Moves the axis on the controller mesh based on its current state
  43014. * @param axis the index of the axis
  43015. * @param axisValue the value of the axis which determines the meshes new position
  43016. * @hidden
  43017. */
  43018. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43019. /**
  43020. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43021. * @param scene scene in which to add meshes
  43022. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43023. */
  43024. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43025. /**
  43026. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43027. * can be transformed by button presses and axes values, based on this._mapping.
  43028. *
  43029. * @param scene scene in which the meshes exist
  43030. * @param meshes list of meshes that make up the controller model to process
  43031. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43032. */
  43033. private processModel;
  43034. private createMeshInfo;
  43035. /**
  43036. * Gets the ray of the controller in the direction the controller is pointing
  43037. * @param length the length the resulting ray should be
  43038. * @returns a ray in the direction the controller is pointing
  43039. */
  43040. getForwardRay(length?: number): Ray;
  43041. /**
  43042. * Disposes of the controller
  43043. */
  43044. dispose(): void;
  43045. }
  43046. }
  43047. declare module "babylonjs/Gamepads/Controllers/index" {
  43048. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43049. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43050. export * from "babylonjs/Gamepads/Controllers/genericController";
  43051. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43052. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43053. export * from "babylonjs/Gamepads/Controllers/viveController";
  43054. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43055. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43056. }
  43057. declare module "babylonjs/Gamepads/gamepadManager" {
  43058. import { Observable } from "babylonjs/Misc/observable";
  43059. import { Nullable } from "babylonjs/types";
  43060. import { Scene } from "babylonjs/scene";
  43061. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43062. /**
  43063. * Manager for handling gamepads
  43064. */
  43065. export class GamepadManager {
  43066. private _scene?;
  43067. private _babylonGamepads;
  43068. private _oneGamepadConnected;
  43069. /** @hidden */
  43070. _isMonitoring: boolean;
  43071. private _gamepadEventSupported;
  43072. private _gamepadSupport;
  43073. /**
  43074. * observable to be triggered when the gamepad controller has been connected
  43075. */
  43076. onGamepadConnectedObservable: Observable<Gamepad>;
  43077. /**
  43078. * observable to be triggered when the gamepad controller has been disconnected
  43079. */
  43080. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43081. private _onGamepadConnectedEvent;
  43082. private _onGamepadDisconnectedEvent;
  43083. /**
  43084. * Initializes the gamepad manager
  43085. * @param _scene BabylonJS scene
  43086. */
  43087. constructor(_scene?: Scene | undefined);
  43088. /**
  43089. * The gamepads in the game pad manager
  43090. */
  43091. readonly gamepads: Gamepad[];
  43092. /**
  43093. * Get the gamepad controllers based on type
  43094. * @param type The type of gamepad controller
  43095. * @returns Nullable gamepad
  43096. */
  43097. getGamepadByType(type?: number): Nullable<Gamepad>;
  43098. /**
  43099. * Disposes the gamepad manager
  43100. */
  43101. dispose(): void;
  43102. private _addNewGamepad;
  43103. private _startMonitoringGamepads;
  43104. private _stopMonitoringGamepads;
  43105. /** @hidden */
  43106. _checkGamepadsStatus(): void;
  43107. private _updateGamepadObjects;
  43108. }
  43109. }
  43110. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43111. import { Nullable } from "babylonjs/types";
  43112. import { Scene } from "babylonjs/scene";
  43113. import { ISceneComponent } from "babylonjs/sceneComponent";
  43114. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43115. module "babylonjs/scene" {
  43116. interface Scene {
  43117. /** @hidden */
  43118. _gamepadManager: Nullable<GamepadManager>;
  43119. /**
  43120. * Gets the gamepad manager associated with the scene
  43121. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43122. */
  43123. gamepadManager: GamepadManager;
  43124. }
  43125. }
  43126. module "babylonjs/Cameras/freeCameraInputsManager" {
  43127. /**
  43128. * Interface representing a free camera inputs manager
  43129. */
  43130. interface FreeCameraInputsManager {
  43131. /**
  43132. * Adds gamepad input support to the FreeCameraInputsManager.
  43133. * @returns the FreeCameraInputsManager
  43134. */
  43135. addGamepad(): FreeCameraInputsManager;
  43136. }
  43137. }
  43138. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43139. /**
  43140. * Interface representing an arc rotate camera inputs manager
  43141. */
  43142. interface ArcRotateCameraInputsManager {
  43143. /**
  43144. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43145. * @returns the camera inputs manager
  43146. */
  43147. addGamepad(): ArcRotateCameraInputsManager;
  43148. }
  43149. }
  43150. /**
  43151. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43152. */
  43153. export class GamepadSystemSceneComponent implements ISceneComponent {
  43154. /**
  43155. * The component name helpfull to identify the component in the list of scene components.
  43156. */
  43157. readonly name: string;
  43158. /**
  43159. * The scene the component belongs to.
  43160. */
  43161. scene: Scene;
  43162. /**
  43163. * Creates a new instance of the component for the given scene
  43164. * @param scene Defines the scene to register the component in
  43165. */
  43166. constructor(scene: Scene);
  43167. /**
  43168. * Registers the component in a given scene
  43169. */
  43170. register(): void;
  43171. /**
  43172. * Rebuilds the elements related to this component in case of
  43173. * context lost for instance.
  43174. */
  43175. rebuild(): void;
  43176. /**
  43177. * Disposes the component and the associated ressources
  43178. */
  43179. dispose(): void;
  43180. private _beforeCameraUpdate;
  43181. }
  43182. }
  43183. declare module "babylonjs/Gamepads/index" {
  43184. export * from "babylonjs/Gamepads/Controllers/index";
  43185. export * from "babylonjs/Gamepads/gamepad";
  43186. export * from "babylonjs/Gamepads/gamepadManager";
  43187. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43188. export * from "babylonjs/Gamepads/xboxGamepad";
  43189. }
  43190. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43191. import { Observable } from "babylonjs/Misc/observable";
  43192. import { Nullable } from "babylonjs/types";
  43193. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43195. import { Mesh } from "babylonjs/Meshes/mesh";
  43196. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43197. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43198. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43199. /**
  43200. * Single axis scale gizmo
  43201. */
  43202. export class AxisScaleGizmo extends Gizmo {
  43203. private _coloredMaterial;
  43204. /**
  43205. * Drag behavior responsible for the gizmos dragging interactions
  43206. */
  43207. dragBehavior: PointerDragBehavior;
  43208. private _pointerObserver;
  43209. /**
  43210. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43211. */
  43212. snapDistance: number;
  43213. /**
  43214. * Event that fires each time the gizmo snaps to a new location.
  43215. * * snapDistance is the the change in distance
  43216. */
  43217. onSnapObservable: Observable<{
  43218. snapDistance: number;
  43219. }>;
  43220. /**
  43221. * If the scaling operation should be done on all axis (default: false)
  43222. */
  43223. uniformScaling: boolean;
  43224. /**
  43225. * Creates an AxisScaleGizmo
  43226. * @param gizmoLayer The utility layer the gizmo will be added to
  43227. * @param dragAxis The axis which the gizmo will be able to scale on
  43228. * @param color The color of the gizmo
  43229. */
  43230. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43231. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43232. /**
  43233. * Disposes of the gizmo
  43234. */
  43235. dispose(): void;
  43236. /**
  43237. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43238. * @param mesh The mesh to replace the default mesh of the gizmo
  43239. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43240. */
  43241. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43242. }
  43243. }
  43244. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43245. import { Observable } from "babylonjs/Misc/observable";
  43246. import { Nullable } from "babylonjs/types";
  43247. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43249. import { Mesh } from "babylonjs/Meshes/mesh";
  43250. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43252. /**
  43253. * Bounding box gizmo
  43254. */
  43255. export class BoundingBoxGizmo extends Gizmo {
  43256. private _lineBoundingBox;
  43257. private _rotateSpheresParent;
  43258. private _scaleBoxesParent;
  43259. private _boundingDimensions;
  43260. private _renderObserver;
  43261. private _pointerObserver;
  43262. private _scaleDragSpeed;
  43263. private _tmpQuaternion;
  43264. private _tmpVector;
  43265. private _tmpRotationMatrix;
  43266. /**
  43267. * 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)
  43268. */
  43269. ignoreChildren: boolean;
  43270. /**
  43271. * 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)
  43272. */
  43273. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43274. /**
  43275. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43276. */
  43277. rotationSphereSize: number;
  43278. /**
  43279. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43280. */
  43281. scaleBoxSize: number;
  43282. /**
  43283. * 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)
  43284. */
  43285. fixedDragMeshScreenSize: boolean;
  43286. /**
  43287. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43288. */
  43289. fixedDragMeshScreenSizeDistanceFactor: number;
  43290. /**
  43291. * Fired when a rotation sphere or scale box is dragged
  43292. */
  43293. onDragStartObservable: Observable<{}>;
  43294. /**
  43295. * Fired when a scale box is dragged
  43296. */
  43297. onScaleBoxDragObservable: Observable<{}>;
  43298. /**
  43299. * Fired when a scale box drag is ended
  43300. */
  43301. onScaleBoxDragEndObservable: Observable<{}>;
  43302. /**
  43303. * Fired when a rotation sphere is dragged
  43304. */
  43305. onRotationSphereDragObservable: Observable<{}>;
  43306. /**
  43307. * Fired when a rotation sphere drag is ended
  43308. */
  43309. onRotationSphereDragEndObservable: Observable<{}>;
  43310. /**
  43311. * 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)
  43312. */
  43313. scalePivot: Nullable<Vector3>;
  43314. private _anchorMesh;
  43315. private _existingMeshScale;
  43316. private _dragMesh;
  43317. private pointerDragBehavior;
  43318. /**
  43319. * Creates an BoundingBoxGizmo
  43320. * @param gizmoLayer The utility layer the gizmo will be added to
  43321. * @param color The color of the gizmo
  43322. */
  43323. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43324. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43325. private _selectNode;
  43326. /**
  43327. * Updates the bounding box information for the Gizmo
  43328. */
  43329. updateBoundingBox(): void;
  43330. private _updateRotationSpheres;
  43331. private _updateScaleBoxes;
  43332. /**
  43333. * Enables rotation on the specified axis and disables rotation on the others
  43334. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43335. */
  43336. setEnabledRotationAxis(axis: string): void;
  43337. /**
  43338. * Enables/disables scaling
  43339. * @param enable if scaling should be enabled
  43340. */
  43341. setEnabledScaling(enable: boolean): void;
  43342. private _updateDummy;
  43343. /**
  43344. * Enables a pointer drag behavior on the bounding box of the gizmo
  43345. */
  43346. enableDragBehavior(): void;
  43347. /**
  43348. * Disposes of the gizmo
  43349. */
  43350. dispose(): void;
  43351. /**
  43352. * 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)
  43353. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43354. * @returns the bounding box mesh with the passed in mesh as a child
  43355. */
  43356. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43357. /**
  43358. * CustomMeshes are not supported by this gizmo
  43359. * @param mesh The mesh to replace the default mesh of the gizmo
  43360. */
  43361. setCustomMesh(mesh: Mesh): void;
  43362. }
  43363. }
  43364. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43365. import { Observable } from "babylonjs/Misc/observable";
  43366. import { Nullable } from "babylonjs/types";
  43367. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43369. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43370. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43371. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43372. /**
  43373. * Single plane rotation gizmo
  43374. */
  43375. export class PlaneRotationGizmo extends Gizmo {
  43376. /**
  43377. * Drag behavior responsible for the gizmos dragging interactions
  43378. */
  43379. dragBehavior: PointerDragBehavior;
  43380. private _pointerObserver;
  43381. /**
  43382. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43383. */
  43384. snapDistance: number;
  43385. /**
  43386. * Event that fires each time the gizmo snaps to a new location.
  43387. * * snapDistance is the the change in distance
  43388. */
  43389. onSnapObservable: Observable<{
  43390. snapDistance: number;
  43391. }>;
  43392. /**
  43393. * Creates a PlaneRotationGizmo
  43394. * @param gizmoLayer The utility layer the gizmo will be added to
  43395. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43396. * @param color The color of the gizmo
  43397. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43398. */
  43399. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43400. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43401. /**
  43402. * Disposes of the gizmo
  43403. */
  43404. dispose(): void;
  43405. }
  43406. }
  43407. declare module "babylonjs/Gizmos/rotationGizmo" {
  43408. import { Observable } from "babylonjs/Misc/observable";
  43409. import { Nullable } from "babylonjs/types";
  43410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43411. import { Mesh } from "babylonjs/Meshes/mesh";
  43412. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43413. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43414. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43415. /**
  43416. * Gizmo that enables rotating a mesh along 3 axis
  43417. */
  43418. export class RotationGizmo extends Gizmo {
  43419. /**
  43420. * Internal gizmo used for interactions on the x axis
  43421. */
  43422. xGizmo: PlaneRotationGizmo;
  43423. /**
  43424. * Internal gizmo used for interactions on the y axis
  43425. */
  43426. yGizmo: PlaneRotationGizmo;
  43427. /**
  43428. * Internal gizmo used for interactions on the z axis
  43429. */
  43430. zGizmo: PlaneRotationGizmo;
  43431. /** Fires an event when any of it's sub gizmos are dragged */
  43432. onDragStartObservable: Observable<{}>;
  43433. /** Fires an event when any of it's sub gizmos are released from dragging */
  43434. onDragEndObservable: Observable<{}>;
  43435. attachedMesh: Nullable<AbstractMesh>;
  43436. /**
  43437. * Creates a RotationGizmo
  43438. * @param gizmoLayer The utility layer the gizmo will be added to
  43439. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43440. */
  43441. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43442. updateGizmoRotationToMatchAttachedMesh: boolean;
  43443. /**
  43444. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43445. */
  43446. snapDistance: number;
  43447. /**
  43448. * Ratio for the scale of the gizmo (Default: 1)
  43449. */
  43450. scaleRatio: number;
  43451. /**
  43452. * Disposes of the gizmo
  43453. */
  43454. dispose(): void;
  43455. /**
  43456. * CustomMeshes are not supported by this gizmo
  43457. * @param mesh The mesh to replace the default mesh of the gizmo
  43458. */
  43459. setCustomMesh(mesh: Mesh): void;
  43460. }
  43461. }
  43462. declare module "babylonjs/Gizmos/positionGizmo" {
  43463. import { Observable } from "babylonjs/Misc/observable";
  43464. import { Nullable } from "babylonjs/types";
  43465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43466. import { Mesh } from "babylonjs/Meshes/mesh";
  43467. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43468. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43470. /**
  43471. * Gizmo that enables dragging a mesh along 3 axis
  43472. */
  43473. export class PositionGizmo extends Gizmo {
  43474. /**
  43475. * Internal gizmo used for interactions on the x axis
  43476. */
  43477. xGizmo: AxisDragGizmo;
  43478. /**
  43479. * Internal gizmo used for interactions on the y axis
  43480. */
  43481. yGizmo: AxisDragGizmo;
  43482. /**
  43483. * Internal gizmo used for interactions on the z axis
  43484. */
  43485. zGizmo: AxisDragGizmo;
  43486. /** Fires an event when any of it's sub gizmos are dragged */
  43487. onDragStartObservable: Observable<{}>;
  43488. /** Fires an event when any of it's sub gizmos are released from dragging */
  43489. onDragEndObservable: Observable<{}>;
  43490. attachedMesh: Nullable<AbstractMesh>;
  43491. /**
  43492. * Creates a PositionGizmo
  43493. * @param gizmoLayer The utility layer the gizmo will be added to
  43494. */
  43495. constructor(gizmoLayer?: UtilityLayerRenderer);
  43496. updateGizmoRotationToMatchAttachedMesh: boolean;
  43497. /**
  43498. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43499. */
  43500. snapDistance: number;
  43501. /**
  43502. * Ratio for the scale of the gizmo (Default: 1)
  43503. */
  43504. scaleRatio: number;
  43505. /**
  43506. * Disposes of the gizmo
  43507. */
  43508. dispose(): void;
  43509. /**
  43510. * CustomMeshes are not supported by this gizmo
  43511. * @param mesh The mesh to replace the default mesh of the gizmo
  43512. */
  43513. setCustomMesh(mesh: Mesh): void;
  43514. }
  43515. }
  43516. declare module "babylonjs/Gizmos/scaleGizmo" {
  43517. import { Observable } from "babylonjs/Misc/observable";
  43518. import { Nullable } from "babylonjs/types";
  43519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43520. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43521. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43522. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43523. /**
  43524. * Gizmo that enables scaling a mesh along 3 axis
  43525. */
  43526. export class ScaleGizmo extends Gizmo {
  43527. /**
  43528. * Internal gizmo used for interactions on the x axis
  43529. */
  43530. xGizmo: AxisScaleGizmo;
  43531. /**
  43532. * Internal gizmo used for interactions on the y axis
  43533. */
  43534. yGizmo: AxisScaleGizmo;
  43535. /**
  43536. * Internal gizmo used for interactions on the z axis
  43537. */
  43538. zGizmo: AxisScaleGizmo;
  43539. /**
  43540. * Internal gizmo used to scale all axis equally
  43541. */
  43542. uniformScaleGizmo: AxisScaleGizmo;
  43543. /** Fires an event when any of it's sub gizmos are dragged */
  43544. onDragStartObservable: Observable<{}>;
  43545. /** Fires an event when any of it's sub gizmos are released from dragging */
  43546. onDragEndObservable: Observable<{}>;
  43547. attachedMesh: Nullable<AbstractMesh>;
  43548. /**
  43549. * Creates a ScaleGizmo
  43550. * @param gizmoLayer The utility layer the gizmo will be added to
  43551. */
  43552. constructor(gizmoLayer?: UtilityLayerRenderer);
  43553. updateGizmoRotationToMatchAttachedMesh: boolean;
  43554. /**
  43555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43556. */
  43557. snapDistance: number;
  43558. /**
  43559. * Ratio for the scale of the gizmo (Default: 1)
  43560. */
  43561. scaleRatio: number;
  43562. /**
  43563. * Disposes of the gizmo
  43564. */
  43565. dispose(): void;
  43566. }
  43567. }
  43568. declare module "babylonjs/Gizmos/gizmoManager" {
  43569. import { Observable } from "babylonjs/Misc/observable";
  43570. import { Nullable } from "babylonjs/types";
  43571. import { Scene, IDisposable } from "babylonjs/scene";
  43572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43573. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43574. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43575. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43576. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43577. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43578. /**
  43579. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43580. */
  43581. export class GizmoManager implements IDisposable {
  43582. private scene;
  43583. /**
  43584. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43585. */
  43586. gizmos: {
  43587. positionGizmo: Nullable<PositionGizmo>;
  43588. rotationGizmo: Nullable<RotationGizmo>;
  43589. scaleGizmo: Nullable<ScaleGizmo>;
  43590. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43591. };
  43592. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43593. clearGizmoOnEmptyPointerEvent: boolean;
  43594. /** Fires an event when the manager is attached to a mesh */
  43595. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43596. private _gizmosEnabled;
  43597. private _pointerObserver;
  43598. private _attachedMesh;
  43599. private _boundingBoxColor;
  43600. private _defaultUtilityLayer;
  43601. private _defaultKeepDepthUtilityLayer;
  43602. /**
  43603. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43604. */
  43605. boundingBoxDragBehavior: SixDofDragBehavior;
  43606. /**
  43607. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43608. */
  43609. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43610. /**
  43611. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43612. */
  43613. usePointerToAttachGizmos: boolean;
  43614. /**
  43615. * Instatiates a gizmo manager
  43616. * @param scene the scene to overlay the gizmos on top of
  43617. */
  43618. constructor(scene: Scene);
  43619. /**
  43620. * Attaches a set of gizmos to the specified mesh
  43621. * @param mesh The mesh the gizmo's should be attached to
  43622. */
  43623. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43624. /**
  43625. * If the position gizmo is enabled
  43626. */
  43627. positionGizmoEnabled: boolean;
  43628. /**
  43629. * If the rotation gizmo is enabled
  43630. */
  43631. rotationGizmoEnabled: boolean;
  43632. /**
  43633. * If the scale gizmo is enabled
  43634. */
  43635. scaleGizmoEnabled: boolean;
  43636. /**
  43637. * If the boundingBox gizmo is enabled
  43638. */
  43639. boundingBoxGizmoEnabled: boolean;
  43640. /**
  43641. * Disposes of the gizmo manager
  43642. */
  43643. dispose(): void;
  43644. }
  43645. }
  43646. declare module "babylonjs/Gizmos/index" {
  43647. export * from "babylonjs/Gizmos/axisDragGizmo";
  43648. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43649. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43650. export * from "babylonjs/Gizmos/gizmo";
  43651. export * from "babylonjs/Gizmos/gizmoManager";
  43652. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43653. export * from "babylonjs/Gizmos/positionGizmo";
  43654. export * from "babylonjs/Gizmos/rotationGizmo";
  43655. export * from "babylonjs/Gizmos/scaleGizmo";
  43656. }
  43657. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43658. /** @hidden */
  43659. export var backgroundFragmentDeclaration: {
  43660. name: string;
  43661. shader: string;
  43662. };
  43663. }
  43664. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43665. /** @hidden */
  43666. export var backgroundUboDeclaration: {
  43667. name: string;
  43668. shader: string;
  43669. };
  43670. }
  43671. declare module "babylonjs/Shaders/background.fragment" {
  43672. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43673. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43674. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43675. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43676. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43677. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43678. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43679. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43680. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43681. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43682. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43683. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43684. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43685. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43686. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43687. /** @hidden */
  43688. export var backgroundPixelShader: {
  43689. name: string;
  43690. shader: string;
  43691. };
  43692. }
  43693. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43694. /** @hidden */
  43695. export var backgroundVertexDeclaration: {
  43696. name: string;
  43697. shader: string;
  43698. };
  43699. }
  43700. declare module "babylonjs/Shaders/background.vertex" {
  43701. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43702. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43703. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43704. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43705. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43706. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43707. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43708. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43709. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43710. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43711. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43712. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43713. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43714. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43715. /** @hidden */
  43716. export var backgroundVertexShader: {
  43717. name: string;
  43718. shader: string;
  43719. };
  43720. }
  43721. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43722. import { Nullable, int, float } from "babylonjs/types";
  43723. import { Scene } from "babylonjs/scene";
  43724. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43725. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43727. import { Mesh } from "babylonjs/Meshes/mesh";
  43728. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43729. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43730. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43732. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43733. import "babylonjs/Shaders/background.fragment";
  43734. import "babylonjs/Shaders/background.vertex";
  43735. /**
  43736. * Background material used to create an efficient environement around your scene.
  43737. */
  43738. export class BackgroundMaterial extends PushMaterial {
  43739. /**
  43740. * Standard reflectance value at parallel view angle.
  43741. */
  43742. static StandardReflectance0: number;
  43743. /**
  43744. * Standard reflectance value at grazing angle.
  43745. */
  43746. static StandardReflectance90: number;
  43747. protected _primaryColor: Color3;
  43748. /**
  43749. * Key light Color (multiply against the environement texture)
  43750. */
  43751. primaryColor: Color3;
  43752. protected __perceptualColor: Nullable<Color3>;
  43753. /**
  43754. * Experimental Internal Use Only.
  43755. *
  43756. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43757. * This acts as a helper to set the primary color to a more "human friendly" value.
  43758. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43759. * output color as close as possible from the chosen value.
  43760. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43761. * part of lighting setup.)
  43762. */
  43763. _perceptualColor: Nullable<Color3>;
  43764. protected _primaryColorShadowLevel: float;
  43765. /**
  43766. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43767. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43768. */
  43769. primaryColorShadowLevel: float;
  43770. protected _primaryColorHighlightLevel: float;
  43771. /**
  43772. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43773. * The primary color is used at the level chosen to define what the white area would look.
  43774. */
  43775. primaryColorHighlightLevel: float;
  43776. protected _reflectionTexture: Nullable<BaseTexture>;
  43777. /**
  43778. * Reflection Texture used in the material.
  43779. * Should be author in a specific way for the best result (refer to the documentation).
  43780. */
  43781. reflectionTexture: Nullable<BaseTexture>;
  43782. protected _reflectionBlur: float;
  43783. /**
  43784. * Reflection Texture level of blur.
  43785. *
  43786. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43787. * texture twice.
  43788. */
  43789. reflectionBlur: float;
  43790. protected _diffuseTexture: Nullable<BaseTexture>;
  43791. /**
  43792. * Diffuse Texture used in the material.
  43793. * Should be author in a specific way for the best result (refer to the documentation).
  43794. */
  43795. diffuseTexture: Nullable<BaseTexture>;
  43796. protected _shadowLights: Nullable<IShadowLight[]>;
  43797. /**
  43798. * Specify the list of lights casting shadow on the material.
  43799. * All scene shadow lights will be included if null.
  43800. */
  43801. shadowLights: Nullable<IShadowLight[]>;
  43802. protected _shadowLevel: float;
  43803. /**
  43804. * Helps adjusting the shadow to a softer level if required.
  43805. * 0 means black shadows and 1 means no shadows.
  43806. */
  43807. shadowLevel: float;
  43808. protected _sceneCenter: Vector3;
  43809. /**
  43810. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43811. * It is usually zero but might be interesting to modify according to your setup.
  43812. */
  43813. sceneCenter: Vector3;
  43814. protected _opacityFresnel: boolean;
  43815. /**
  43816. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43817. * This helps ensuring a nice transition when the camera goes under the ground.
  43818. */
  43819. opacityFresnel: boolean;
  43820. protected _reflectionFresnel: boolean;
  43821. /**
  43822. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43823. * This helps adding a mirror texture on the ground.
  43824. */
  43825. reflectionFresnel: boolean;
  43826. protected _reflectionFalloffDistance: number;
  43827. /**
  43828. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43829. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43830. */
  43831. reflectionFalloffDistance: number;
  43832. protected _reflectionAmount: number;
  43833. /**
  43834. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43835. */
  43836. reflectionAmount: number;
  43837. protected _reflectionReflectance0: number;
  43838. /**
  43839. * This specifies the weight of the reflection at grazing angle.
  43840. */
  43841. reflectionReflectance0: number;
  43842. protected _reflectionReflectance90: number;
  43843. /**
  43844. * This specifies the weight of the reflection at a perpendicular point of view.
  43845. */
  43846. reflectionReflectance90: number;
  43847. /**
  43848. * Sets the reflection reflectance fresnel values according to the default standard
  43849. * empirically know to work well :-)
  43850. */
  43851. reflectionStandardFresnelWeight: number;
  43852. protected _useRGBColor: boolean;
  43853. /**
  43854. * Helps to directly use the maps channels instead of their level.
  43855. */
  43856. useRGBColor: boolean;
  43857. protected _enableNoise: boolean;
  43858. /**
  43859. * This helps reducing the banding effect that could occur on the background.
  43860. */
  43861. enableNoise: boolean;
  43862. /**
  43863. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43864. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43865. * Recommended to be keep at 1.0 except for special cases.
  43866. */
  43867. fovMultiplier: number;
  43868. private _fovMultiplier;
  43869. /**
  43870. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43871. */
  43872. useEquirectangularFOV: boolean;
  43873. private _maxSimultaneousLights;
  43874. /**
  43875. * Number of Simultaneous lights allowed on the material.
  43876. */
  43877. maxSimultaneousLights: int;
  43878. /**
  43879. * Default configuration related to image processing available in the Background Material.
  43880. */
  43881. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43882. /**
  43883. * Keep track of the image processing observer to allow dispose and replace.
  43884. */
  43885. private _imageProcessingObserver;
  43886. /**
  43887. * Attaches a new image processing configuration to the PBR Material.
  43888. * @param configuration (if null the scene configuration will be use)
  43889. */
  43890. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43891. /**
  43892. * Gets the image processing configuration used either in this material.
  43893. */
  43894. /**
  43895. * Sets the Default image processing configuration used either in the this material.
  43896. *
  43897. * If sets to null, the scene one is in use.
  43898. */
  43899. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43900. /**
  43901. * Gets wether the color curves effect is enabled.
  43902. */
  43903. /**
  43904. * Sets wether the color curves effect is enabled.
  43905. */
  43906. cameraColorCurvesEnabled: boolean;
  43907. /**
  43908. * Gets wether the color grading effect is enabled.
  43909. */
  43910. /**
  43911. * Gets wether the color grading effect is enabled.
  43912. */
  43913. cameraColorGradingEnabled: boolean;
  43914. /**
  43915. * Gets wether tonemapping is enabled or not.
  43916. */
  43917. /**
  43918. * Sets wether tonemapping is enabled or not
  43919. */
  43920. cameraToneMappingEnabled: boolean;
  43921. /**
  43922. * The camera exposure used on this material.
  43923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43924. * This corresponds to a photographic exposure.
  43925. */
  43926. /**
  43927. * The camera exposure used on this material.
  43928. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43929. * This corresponds to a photographic exposure.
  43930. */
  43931. cameraExposure: float;
  43932. /**
  43933. * Gets The camera contrast used on this material.
  43934. */
  43935. /**
  43936. * Sets The camera contrast used on this material.
  43937. */
  43938. cameraContrast: float;
  43939. /**
  43940. * Gets the Color Grading 2D Lookup Texture.
  43941. */
  43942. /**
  43943. * Sets the Color Grading 2D Lookup Texture.
  43944. */
  43945. cameraColorGradingTexture: Nullable<BaseTexture>;
  43946. /**
  43947. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43948. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43949. * 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;
  43950. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43951. */
  43952. /**
  43953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43955. * 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;
  43956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43957. */
  43958. cameraColorCurves: Nullable<ColorCurves>;
  43959. /**
  43960. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43961. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43962. */
  43963. switchToBGR: boolean;
  43964. private _renderTargets;
  43965. private _reflectionControls;
  43966. private _white;
  43967. private _primaryShadowColor;
  43968. private _primaryHighlightColor;
  43969. /**
  43970. * Instantiates a Background Material in the given scene
  43971. * @param name The friendly name of the material
  43972. * @param scene The scene to add the material to
  43973. */
  43974. constructor(name: string, scene: Scene);
  43975. /**
  43976. * Gets a boolean indicating that current material needs to register RTT
  43977. */
  43978. readonly hasRenderTargetTextures: boolean;
  43979. /**
  43980. * The entire material has been created in order to prevent overdraw.
  43981. * @returns false
  43982. */
  43983. needAlphaTesting(): boolean;
  43984. /**
  43985. * The entire material has been created in order to prevent overdraw.
  43986. * @returns true if blending is enable
  43987. */
  43988. needAlphaBlending(): boolean;
  43989. /**
  43990. * Checks wether the material is ready to be rendered for a given mesh.
  43991. * @param mesh The mesh to render
  43992. * @param subMesh The submesh to check against
  43993. * @param useInstances Specify wether or not the material is used with instances
  43994. * @returns true if all the dependencies are ready (Textures, Effects...)
  43995. */
  43996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43997. /**
  43998. * Compute the primary color according to the chosen perceptual color.
  43999. */
  44000. private _computePrimaryColorFromPerceptualColor;
  44001. /**
  44002. * Compute the highlights and shadow colors according to their chosen levels.
  44003. */
  44004. private _computePrimaryColors;
  44005. /**
  44006. * Build the uniform buffer used in the material.
  44007. */
  44008. buildUniformLayout(): void;
  44009. /**
  44010. * Unbind the material.
  44011. */
  44012. unbind(): void;
  44013. /**
  44014. * Bind only the world matrix to the material.
  44015. * @param world The world matrix to bind.
  44016. */
  44017. bindOnlyWorldMatrix(world: Matrix): void;
  44018. /**
  44019. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44020. * @param world The world matrix to bind.
  44021. * @param subMesh The submesh to bind for.
  44022. */
  44023. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44024. /**
  44025. * Dispose the material.
  44026. * @param forceDisposeEffect Force disposal of the associated effect.
  44027. * @param forceDisposeTextures Force disposal of the associated textures.
  44028. */
  44029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44030. /**
  44031. * Clones the material.
  44032. * @param name The cloned name.
  44033. * @returns The cloned material.
  44034. */
  44035. clone(name: string): BackgroundMaterial;
  44036. /**
  44037. * Serializes the current material to its JSON representation.
  44038. * @returns The JSON representation.
  44039. */
  44040. serialize(): any;
  44041. /**
  44042. * Gets the class name of the material
  44043. * @returns "BackgroundMaterial"
  44044. */
  44045. getClassName(): string;
  44046. /**
  44047. * Parse a JSON input to create back a background material.
  44048. * @param source The JSON data to parse
  44049. * @param scene The scene to create the parsed material in
  44050. * @param rootUrl The root url of the assets the material depends upon
  44051. * @returns the instantiated BackgroundMaterial.
  44052. */
  44053. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44054. }
  44055. }
  44056. declare module "babylonjs/Helpers/environmentHelper" {
  44057. import { Observable } from "babylonjs/Misc/observable";
  44058. import { Nullable } from "babylonjs/types";
  44059. import { Scene } from "babylonjs/scene";
  44060. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44062. import { Mesh } from "babylonjs/Meshes/mesh";
  44063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44064. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44065. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44066. /**
  44067. * Represents the different options available during the creation of
  44068. * a Environment helper.
  44069. *
  44070. * This can control the default ground, skybox and image processing setup of your scene.
  44071. */
  44072. export interface IEnvironmentHelperOptions {
  44073. /**
  44074. * Specifies wether or not to create a ground.
  44075. * True by default.
  44076. */
  44077. createGround: boolean;
  44078. /**
  44079. * Specifies the ground size.
  44080. * 15 by default.
  44081. */
  44082. groundSize: number;
  44083. /**
  44084. * The texture used on the ground for the main color.
  44085. * Comes from the BabylonJS CDN by default.
  44086. *
  44087. * Remarks: Can be either a texture or a url.
  44088. */
  44089. groundTexture: string | BaseTexture;
  44090. /**
  44091. * The color mixed in the ground texture by default.
  44092. * BabylonJS clearColor by default.
  44093. */
  44094. groundColor: Color3;
  44095. /**
  44096. * Specifies the ground opacity.
  44097. * 1 by default.
  44098. */
  44099. groundOpacity: number;
  44100. /**
  44101. * Enables the ground to receive shadows.
  44102. * True by default.
  44103. */
  44104. enableGroundShadow: boolean;
  44105. /**
  44106. * Helps preventing the shadow to be fully black on the ground.
  44107. * 0.5 by default.
  44108. */
  44109. groundShadowLevel: number;
  44110. /**
  44111. * Creates a mirror texture attach to the ground.
  44112. * false by default.
  44113. */
  44114. enableGroundMirror: boolean;
  44115. /**
  44116. * Specifies the ground mirror size ratio.
  44117. * 0.3 by default as the default kernel is 64.
  44118. */
  44119. groundMirrorSizeRatio: number;
  44120. /**
  44121. * Specifies the ground mirror blur kernel size.
  44122. * 64 by default.
  44123. */
  44124. groundMirrorBlurKernel: number;
  44125. /**
  44126. * Specifies the ground mirror visibility amount.
  44127. * 1 by default
  44128. */
  44129. groundMirrorAmount: number;
  44130. /**
  44131. * Specifies the ground mirror reflectance weight.
  44132. * This uses the standard weight of the background material to setup the fresnel effect
  44133. * of the mirror.
  44134. * 1 by default.
  44135. */
  44136. groundMirrorFresnelWeight: number;
  44137. /**
  44138. * Specifies the ground mirror Falloff distance.
  44139. * This can helps reducing the size of the reflection.
  44140. * 0 by Default.
  44141. */
  44142. groundMirrorFallOffDistance: number;
  44143. /**
  44144. * Specifies the ground mirror texture type.
  44145. * Unsigned Int by Default.
  44146. */
  44147. groundMirrorTextureType: number;
  44148. /**
  44149. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44150. * the shown objects.
  44151. */
  44152. groundYBias: number;
  44153. /**
  44154. * Specifies wether or not to create a skybox.
  44155. * True by default.
  44156. */
  44157. createSkybox: boolean;
  44158. /**
  44159. * Specifies the skybox size.
  44160. * 20 by default.
  44161. */
  44162. skyboxSize: number;
  44163. /**
  44164. * The texture used on the skybox for the main color.
  44165. * Comes from the BabylonJS CDN by default.
  44166. *
  44167. * Remarks: Can be either a texture or a url.
  44168. */
  44169. skyboxTexture: string | BaseTexture;
  44170. /**
  44171. * The color mixed in the skybox texture by default.
  44172. * BabylonJS clearColor by default.
  44173. */
  44174. skyboxColor: Color3;
  44175. /**
  44176. * The background rotation around the Y axis of the scene.
  44177. * This helps aligning the key lights of your scene with the background.
  44178. * 0 by default.
  44179. */
  44180. backgroundYRotation: number;
  44181. /**
  44182. * Compute automatically the size of the elements to best fit with the scene.
  44183. */
  44184. sizeAuto: boolean;
  44185. /**
  44186. * Default position of the rootMesh if autoSize is not true.
  44187. */
  44188. rootPosition: Vector3;
  44189. /**
  44190. * Sets up the image processing in the scene.
  44191. * true by default.
  44192. */
  44193. setupImageProcessing: boolean;
  44194. /**
  44195. * The texture used as your environment texture in the scene.
  44196. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44197. *
  44198. * Remarks: Can be either a texture or a url.
  44199. */
  44200. environmentTexture: string | BaseTexture;
  44201. /**
  44202. * The value of the exposure to apply to the scene.
  44203. * 0.6 by default if setupImageProcessing is true.
  44204. */
  44205. cameraExposure: number;
  44206. /**
  44207. * The value of the contrast to apply to the scene.
  44208. * 1.6 by default if setupImageProcessing is true.
  44209. */
  44210. cameraContrast: number;
  44211. /**
  44212. * Specifies wether or not tonemapping should be enabled in the scene.
  44213. * true by default if setupImageProcessing is true.
  44214. */
  44215. toneMappingEnabled: boolean;
  44216. }
  44217. /**
  44218. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44219. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44220. * It also helps with the default setup of your imageProcessing configuration.
  44221. */
  44222. export class EnvironmentHelper {
  44223. /**
  44224. * Default ground texture URL.
  44225. */
  44226. private static _groundTextureCDNUrl;
  44227. /**
  44228. * Default skybox texture URL.
  44229. */
  44230. private static _skyboxTextureCDNUrl;
  44231. /**
  44232. * Default environment texture URL.
  44233. */
  44234. private static _environmentTextureCDNUrl;
  44235. /**
  44236. * Creates the default options for the helper.
  44237. */
  44238. private static _getDefaultOptions;
  44239. private _rootMesh;
  44240. /**
  44241. * Gets the root mesh created by the helper.
  44242. */
  44243. readonly rootMesh: Mesh;
  44244. private _skybox;
  44245. /**
  44246. * Gets the skybox created by the helper.
  44247. */
  44248. readonly skybox: Nullable<Mesh>;
  44249. private _skyboxTexture;
  44250. /**
  44251. * Gets the skybox texture created by the helper.
  44252. */
  44253. readonly skyboxTexture: Nullable<BaseTexture>;
  44254. private _skyboxMaterial;
  44255. /**
  44256. * Gets the skybox material created by the helper.
  44257. */
  44258. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44259. private _ground;
  44260. /**
  44261. * Gets the ground mesh created by the helper.
  44262. */
  44263. readonly ground: Nullable<Mesh>;
  44264. private _groundTexture;
  44265. /**
  44266. * Gets the ground texture created by the helper.
  44267. */
  44268. readonly groundTexture: Nullable<BaseTexture>;
  44269. private _groundMirror;
  44270. /**
  44271. * Gets the ground mirror created by the helper.
  44272. */
  44273. readonly groundMirror: Nullable<MirrorTexture>;
  44274. /**
  44275. * Gets the ground mirror render list to helps pushing the meshes
  44276. * you wish in the ground reflection.
  44277. */
  44278. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44279. private _groundMaterial;
  44280. /**
  44281. * Gets the ground material created by the helper.
  44282. */
  44283. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44284. /**
  44285. * Stores the creation options.
  44286. */
  44287. private readonly _scene;
  44288. private _options;
  44289. /**
  44290. * This observable will be notified with any error during the creation of the environment,
  44291. * mainly texture creation errors.
  44292. */
  44293. onErrorObservable: Observable<{
  44294. message?: string;
  44295. exception?: any;
  44296. }>;
  44297. /**
  44298. * constructor
  44299. * @param options
  44300. * @param scene The scene to add the material to
  44301. */
  44302. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44303. /**
  44304. * Updates the background according to the new options
  44305. * @param options
  44306. */
  44307. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44308. /**
  44309. * Sets the primary color of all the available elements.
  44310. * @param color the main color to affect to the ground and the background
  44311. */
  44312. setMainColor(color: Color3): void;
  44313. /**
  44314. * Setup the image processing according to the specified options.
  44315. */
  44316. private _setupImageProcessing;
  44317. /**
  44318. * Setup the environment texture according to the specified options.
  44319. */
  44320. private _setupEnvironmentTexture;
  44321. /**
  44322. * Setup the background according to the specified options.
  44323. */
  44324. private _setupBackground;
  44325. /**
  44326. * Get the scene sizes according to the setup.
  44327. */
  44328. private _getSceneSize;
  44329. /**
  44330. * Setup the ground according to the specified options.
  44331. */
  44332. private _setupGround;
  44333. /**
  44334. * Setup the ground material according to the specified options.
  44335. */
  44336. private _setupGroundMaterial;
  44337. /**
  44338. * Setup the ground diffuse texture according to the specified options.
  44339. */
  44340. private _setupGroundDiffuseTexture;
  44341. /**
  44342. * Setup the ground mirror texture according to the specified options.
  44343. */
  44344. private _setupGroundMirrorTexture;
  44345. /**
  44346. * Setup the ground to receive the mirror texture.
  44347. */
  44348. private _setupMirrorInGroundMaterial;
  44349. /**
  44350. * Setup the skybox according to the specified options.
  44351. */
  44352. private _setupSkybox;
  44353. /**
  44354. * Setup the skybox material according to the specified options.
  44355. */
  44356. private _setupSkyboxMaterial;
  44357. /**
  44358. * Setup the skybox reflection texture according to the specified options.
  44359. */
  44360. private _setupSkyboxReflectionTexture;
  44361. private _errorHandler;
  44362. /**
  44363. * Dispose all the elements created by the Helper.
  44364. */
  44365. dispose(): void;
  44366. }
  44367. }
  44368. declare module "babylonjs/Helpers/photoDome" {
  44369. import { Observable } from "babylonjs/Misc/observable";
  44370. import { Nullable } from "babylonjs/types";
  44371. import { Scene } from "babylonjs/scene";
  44372. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44373. import { Mesh } from "babylonjs/Meshes/mesh";
  44374. import { Texture } from "babylonjs/Materials/Textures/texture";
  44375. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44376. import "babylonjs/Meshes/meshBuilder";
  44377. /**
  44378. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44379. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44380. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44381. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44382. */
  44383. export class PhotoDome extends TransformNode {
  44384. private _useDirectMapping;
  44385. /**
  44386. * The texture being displayed on the sphere
  44387. */
  44388. protected _photoTexture: Texture;
  44389. /**
  44390. * Gets or sets the texture being displayed on the sphere
  44391. */
  44392. photoTexture: Texture;
  44393. /**
  44394. * Observable raised when an error occured while loading the 360 image
  44395. */
  44396. onLoadErrorObservable: Observable<string>;
  44397. /**
  44398. * The skybox material
  44399. */
  44400. protected _material: BackgroundMaterial;
  44401. /**
  44402. * The surface used for the skybox
  44403. */
  44404. protected _mesh: Mesh;
  44405. /**
  44406. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44407. * Also see the options.resolution property.
  44408. */
  44409. fovMultiplier: number;
  44410. /**
  44411. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44412. * @param name Element's name, child elements will append suffixes for their own names.
  44413. * @param urlsOfPhoto defines the url of the photo to display
  44414. * @param options defines an object containing optional or exposed sub element properties
  44415. * @param onError defines a callback called when an error occured while loading the texture
  44416. */
  44417. constructor(name: string, urlOfPhoto: string, options: {
  44418. resolution?: number;
  44419. size?: number;
  44420. useDirectMapping?: boolean;
  44421. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44422. /**
  44423. * Releases resources associated with this node.
  44424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44426. */
  44427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44428. }
  44429. }
  44430. declare module "babylonjs/Misc/textureTools" {
  44431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44432. import { Texture } from "babylonjs/Materials/Textures/texture";
  44433. import { Scene } from "babylonjs/scene";
  44434. /**
  44435. * Class used to host texture specific utilities
  44436. */
  44437. export class TextureTools {
  44438. /**
  44439. * Uses the GPU to create a copy texture rescaled at a given size
  44440. * @param texture Texture to copy from
  44441. * @param width defines the desired width
  44442. * @param height defines the desired height
  44443. * @param useBilinearMode defines if bilinear mode has to be used
  44444. * @return the generated texture
  44445. */
  44446. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44447. /**
  44448. * Gets an environment BRDF texture for a given scene
  44449. * @param scene defines the hosting scene
  44450. * @returns the environment BRDF texture
  44451. */
  44452. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44453. private static _environmentBRDFBase64Texture;
  44454. }
  44455. }
  44456. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44457. /** @hidden */
  44458. export var pbrFragmentDeclaration: {
  44459. name: string;
  44460. shader: string;
  44461. };
  44462. }
  44463. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44464. /** @hidden */
  44465. export var pbrUboDeclaration: {
  44466. name: string;
  44467. shader: string;
  44468. };
  44469. }
  44470. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44471. /** @hidden */
  44472. export var pbrFunctions: {
  44473. name: string;
  44474. shader: string;
  44475. };
  44476. }
  44477. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44478. /** @hidden */
  44479. export var harmonicsFunctions: {
  44480. name: string;
  44481. shader: string;
  44482. };
  44483. }
  44484. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  44485. /** @hidden */
  44486. export var pbrLightFunctions: {
  44487. name: string;
  44488. shader: string;
  44489. };
  44490. }
  44491. declare module "babylonjs/Shaders/pbr.fragment" {
  44492. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44493. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44494. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44495. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44496. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44497. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44499. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44500. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44501. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44502. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44503. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  44504. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44505. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44506. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44508. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44509. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44510. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44511. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44512. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44513. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44514. /** @hidden */
  44515. export var pbrPixelShader: {
  44516. name: string;
  44517. shader: string;
  44518. };
  44519. }
  44520. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44521. /** @hidden */
  44522. export var pbrVertexDeclaration: {
  44523. name: string;
  44524. shader: string;
  44525. };
  44526. }
  44527. declare module "babylonjs/Shaders/pbr.vertex" {
  44528. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44529. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44530. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44531. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44532. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44533. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44534. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44535. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44536. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44537. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44538. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44541. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44543. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44544. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44545. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44546. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44547. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44548. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44549. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44550. /** @hidden */
  44551. export var pbrVertexShader: {
  44552. name: string;
  44553. shader: string;
  44554. };
  44555. }
  44556. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44557. import { IAnimatable } from "babylonjs/Misc/tools";
  44558. import { Nullable } from "babylonjs/types";
  44559. import { Scene } from "babylonjs/scene";
  44560. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44561. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44563. import { Mesh } from "babylonjs/Meshes/mesh";
  44564. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44565. import { Material } from "babylonjs/Materials/material";
  44566. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44568. import "babylonjs/Shaders/pbr.fragment";
  44569. import "babylonjs/Shaders/pbr.vertex";
  44570. /**
  44571. * The Physically based material base class of BJS.
  44572. *
  44573. * This offers the main features of a standard PBR material.
  44574. * For more information, please refer to the documentation :
  44575. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44576. */
  44577. export abstract class PBRBaseMaterial extends PushMaterial {
  44578. /**
  44579. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44580. */
  44581. static readonly PBRMATERIAL_OPAQUE: number;
  44582. /**
  44583. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44584. */
  44585. static readonly PBRMATERIAL_ALPHATEST: number;
  44586. /**
  44587. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44588. */
  44589. static readonly PBRMATERIAL_ALPHABLEND: number;
  44590. /**
  44591. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44592. * They are also discarded below the alpha cutoff threshold to improve performances.
  44593. */
  44594. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44595. /**
  44596. * Defines the default value of how much AO map is occluding the analytical lights
  44597. * (point spot...).
  44598. */
  44599. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44600. /**
  44601. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44602. */
  44603. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44604. /**
  44605. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44606. * to enhance interoperability with other engines.
  44607. */
  44608. static readonly LIGHTFALLOFF_GLTF: number;
  44609. /**
  44610. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44611. * to enhance interoperability with other materials.
  44612. */
  44613. static readonly LIGHTFALLOFF_STANDARD: number;
  44614. /**
  44615. * Intensity of the direct lights e.g. the four lights available in your scene.
  44616. * This impacts both the direct diffuse and specular highlights.
  44617. */
  44618. protected _directIntensity: number;
  44619. /**
  44620. * Intensity of the emissive part of the material.
  44621. * This helps controlling the emissive effect without modifying the emissive color.
  44622. */
  44623. protected _emissiveIntensity: number;
  44624. /**
  44625. * Intensity of the environment e.g. how much the environment will light the object
  44626. * either through harmonics for rough material or through the refelction for shiny ones.
  44627. */
  44628. protected _environmentIntensity: number;
  44629. /**
  44630. * This is a special control allowing the reduction of the specular highlights coming from the
  44631. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44632. */
  44633. protected _specularIntensity: number;
  44634. /**
  44635. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44636. */
  44637. private _lightingInfos;
  44638. /**
  44639. * Debug Control allowing disabling the bump map on this material.
  44640. */
  44641. protected _disableBumpMap: boolean;
  44642. /**
  44643. * AKA Diffuse Texture in standard nomenclature.
  44644. */
  44645. protected _albedoTexture: BaseTexture;
  44646. /**
  44647. * AKA Occlusion Texture in other nomenclature.
  44648. */
  44649. protected _ambientTexture: BaseTexture;
  44650. /**
  44651. * AKA Occlusion Texture Intensity in other nomenclature.
  44652. */
  44653. protected _ambientTextureStrength: number;
  44654. /**
  44655. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44656. * 1 means it completely occludes it
  44657. * 0 mean it has no impact
  44658. */
  44659. protected _ambientTextureImpactOnAnalyticalLights: number;
  44660. /**
  44661. * Stores the alpha values in a texture.
  44662. */
  44663. protected _opacityTexture: BaseTexture;
  44664. /**
  44665. * Stores the reflection values in a texture.
  44666. */
  44667. protected _reflectionTexture: BaseTexture;
  44668. /**
  44669. * Stores the refraction values in a texture.
  44670. */
  44671. protected _refractionTexture: BaseTexture;
  44672. /**
  44673. * Stores the emissive values in a texture.
  44674. */
  44675. protected _emissiveTexture: BaseTexture;
  44676. /**
  44677. * AKA Specular texture in other nomenclature.
  44678. */
  44679. protected _reflectivityTexture: BaseTexture;
  44680. /**
  44681. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44682. */
  44683. protected _metallicTexture: BaseTexture;
  44684. /**
  44685. * Specifies the metallic scalar of the metallic/roughness workflow.
  44686. * Can also be used to scale the metalness values of the metallic texture.
  44687. */
  44688. protected _metallic: Nullable<number>;
  44689. /**
  44690. * Specifies the roughness scalar of the metallic/roughness workflow.
  44691. * Can also be used to scale the roughness values of the metallic texture.
  44692. */
  44693. protected _roughness: Nullable<number>;
  44694. /**
  44695. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44696. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44697. */
  44698. protected _microSurfaceTexture: BaseTexture;
  44699. /**
  44700. * Stores surface normal data used to displace a mesh in a texture.
  44701. */
  44702. protected _bumpTexture: BaseTexture;
  44703. /**
  44704. * Stores the pre-calculated light information of a mesh in a texture.
  44705. */
  44706. protected _lightmapTexture: BaseTexture;
  44707. /**
  44708. * The color of a material in ambient lighting.
  44709. */
  44710. protected _ambientColor: Color3;
  44711. /**
  44712. * AKA Diffuse Color in other nomenclature.
  44713. */
  44714. protected _albedoColor: Color3;
  44715. /**
  44716. * AKA Specular Color in other nomenclature.
  44717. */
  44718. protected _reflectivityColor: Color3;
  44719. /**
  44720. * The color applied when light is reflected from a material.
  44721. */
  44722. protected _reflectionColor: Color3;
  44723. /**
  44724. * The color applied when light is emitted from a material.
  44725. */
  44726. protected _emissiveColor: Color3;
  44727. /**
  44728. * AKA Glossiness in other nomenclature.
  44729. */
  44730. protected _microSurface: number;
  44731. /**
  44732. * source material index of refraction (IOR)' / 'destination material IOR.
  44733. */
  44734. protected _indexOfRefraction: number;
  44735. /**
  44736. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44737. */
  44738. protected _invertRefractionY: boolean;
  44739. /**
  44740. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44741. * Materials half opaque for instance using refraction could benefit from this control.
  44742. */
  44743. protected _linkRefractionWithTransparency: boolean;
  44744. /**
  44745. * Specifies that the material will use the light map as a show map.
  44746. */
  44747. protected _useLightmapAsShadowmap: boolean;
  44748. /**
  44749. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44750. * makes the reflect vector face the model (under horizon).
  44751. */
  44752. protected _useHorizonOcclusion: boolean;
  44753. /**
  44754. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44755. * too much the area relying on ambient texture to define their ambient occlusion.
  44756. */
  44757. protected _useRadianceOcclusion: boolean;
  44758. /**
  44759. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44760. */
  44761. protected _useAlphaFromAlbedoTexture: boolean;
  44762. /**
  44763. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44764. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44765. */
  44766. protected _useSpecularOverAlpha: boolean;
  44767. /**
  44768. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44769. */
  44770. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44771. /**
  44772. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44773. */
  44774. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44775. /**
  44776. * Specifies if the metallic texture contains the roughness information in its green channel.
  44777. */
  44778. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44779. /**
  44780. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44781. */
  44782. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44783. /**
  44784. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44785. */
  44786. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44787. /**
  44788. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44789. */
  44790. protected _useAmbientInGrayScale: boolean;
  44791. /**
  44792. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44793. * The material will try to infer what glossiness each pixel should be.
  44794. */
  44795. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44796. /**
  44797. * Defines the falloff type used in this material.
  44798. * It by default is Physical.
  44799. */
  44800. protected _lightFalloff: number;
  44801. /**
  44802. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44803. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44804. */
  44805. protected _useRadianceOverAlpha: boolean;
  44806. /**
  44807. * Allows using an object space normal map (instead of tangent space).
  44808. */
  44809. protected _useObjectSpaceNormalMap: boolean;
  44810. /**
  44811. * Allows using the bump map in parallax mode.
  44812. */
  44813. protected _useParallax: boolean;
  44814. /**
  44815. * Allows using the bump map in parallax occlusion mode.
  44816. */
  44817. protected _useParallaxOcclusion: boolean;
  44818. /**
  44819. * Controls the scale bias of the parallax mode.
  44820. */
  44821. protected _parallaxScaleBias: number;
  44822. /**
  44823. * If sets to true, disables all the lights affecting the material.
  44824. */
  44825. protected _disableLighting: boolean;
  44826. /**
  44827. * Number of Simultaneous lights allowed on the material.
  44828. */
  44829. protected _maxSimultaneousLights: number;
  44830. /**
  44831. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44832. */
  44833. protected _invertNormalMapX: boolean;
  44834. /**
  44835. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44836. */
  44837. protected _invertNormalMapY: boolean;
  44838. /**
  44839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44840. */
  44841. protected _twoSidedLighting: boolean;
  44842. /**
  44843. * Defines the alpha limits in alpha test mode.
  44844. */
  44845. protected _alphaCutOff: number;
  44846. /**
  44847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44848. */
  44849. protected _forceAlphaTest: boolean;
  44850. /**
  44851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44853. */
  44854. protected _useAlphaFresnel: boolean;
  44855. /**
  44856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44858. */
  44859. protected _useLinearAlphaFresnel: boolean;
  44860. /**
  44861. * The transparency mode of the material.
  44862. */
  44863. protected _transparencyMode: Nullable<number>;
  44864. /**
  44865. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44866. * from cos thetav and roughness:
  44867. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44868. */
  44869. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44870. /**
  44871. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44872. */
  44873. protected _forceIrradianceInFragment: boolean;
  44874. /**
  44875. * Force normal to face away from face.
  44876. */
  44877. protected _forceNormalForward: boolean;
  44878. /**
  44879. * Enables specular anti aliasing in the PBR shader.
  44880. * It will both interacts on the Geometry for analytical and IBL lighting.
  44881. * It also prefilter the roughness map based on the bump values.
  44882. */
  44883. protected _enableSpecularAntiAliasing: boolean;
  44884. /**
  44885. * Default configuration related to image processing available in the PBR Material.
  44886. */
  44887. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44888. /**
  44889. * Keep track of the image processing observer to allow dispose and replace.
  44890. */
  44891. private _imageProcessingObserver;
  44892. /**
  44893. * Attaches a new image processing configuration to the PBR Material.
  44894. * @param configuration
  44895. */
  44896. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44897. /**
  44898. * Stores the available render targets.
  44899. */
  44900. private _renderTargets;
  44901. /**
  44902. * Sets the global ambient color for the material used in lighting calculations.
  44903. */
  44904. private _globalAmbientColor;
  44905. /**
  44906. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44907. */
  44908. private _useLogarithmicDepth;
  44909. /**
  44910. * If set to true, no lighting calculations will be applied.
  44911. */
  44912. private _unlit;
  44913. /**
  44914. * Instantiates a new PBRMaterial instance.
  44915. *
  44916. * @param name The material name
  44917. * @param scene The scene the material will be use in.
  44918. */
  44919. constructor(name: string, scene: Scene);
  44920. /**
  44921. * Gets a boolean indicating that current material needs to register RTT
  44922. */
  44923. readonly hasRenderTargetTextures: boolean;
  44924. /**
  44925. * Gets the name of the material class.
  44926. */
  44927. getClassName(): string;
  44928. /**
  44929. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44930. */
  44931. /**
  44932. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44933. */
  44934. useLogarithmicDepth: boolean;
  44935. /**
  44936. * Gets the current transparency mode.
  44937. */
  44938. /**
  44939. * Sets the transparency mode of the material.
  44940. *
  44941. * | Value | Type | Description |
  44942. * | ----- | ----------------------------------- | ----------- |
  44943. * | 0 | OPAQUE | |
  44944. * | 1 | ALPHATEST | |
  44945. * | 2 | ALPHABLEND | |
  44946. * | 3 | ALPHATESTANDBLEND | |
  44947. *
  44948. */
  44949. transparencyMode: Nullable<number>;
  44950. /**
  44951. * Returns true if alpha blending should be disabled.
  44952. */
  44953. private readonly _disableAlphaBlending;
  44954. /**
  44955. * Specifies whether or not this material should be rendered in alpha blend mode.
  44956. */
  44957. needAlphaBlending(): boolean;
  44958. /**
  44959. * Specifies if the mesh will require alpha blending.
  44960. * @param mesh - BJS mesh.
  44961. */
  44962. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44963. /**
  44964. * Specifies whether or not this material should be rendered in alpha test mode.
  44965. */
  44966. needAlphaTesting(): boolean;
  44967. /**
  44968. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44969. */
  44970. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44971. /**
  44972. * Gets the texture used for the alpha test.
  44973. */
  44974. getAlphaTestTexture(): BaseTexture;
  44975. /**
  44976. * Specifies that the submesh is ready to be used.
  44977. * @param mesh - BJS mesh.
  44978. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44979. * @param useInstances - Specifies that instances should be used.
  44980. * @returns - boolean indicating that the submesh is ready or not.
  44981. */
  44982. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44983. /**
  44984. * Specifies if the material uses metallic roughness workflow.
  44985. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44986. */
  44987. isMetallicWorkflow(): boolean;
  44988. private _prepareEffect;
  44989. private _prepareDefines;
  44990. /**
  44991. * Force shader compilation
  44992. */
  44993. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44994. clipPlane: boolean;
  44995. }>): void;
  44996. /**
  44997. * Initializes the uniform buffer layout for the shader.
  44998. */
  44999. buildUniformLayout(): void;
  45000. /**
  45001. * Unbinds the textures.
  45002. */
  45003. unbind(): void;
  45004. /**
  45005. * Binds the submesh data.
  45006. * @param world - The world matrix.
  45007. * @param mesh - The BJS mesh.
  45008. * @param subMesh - A submesh of the BJS mesh.
  45009. */
  45010. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45011. /**
  45012. * Returns the animatable textures.
  45013. * @returns - Array of animatable textures.
  45014. */
  45015. getAnimatables(): IAnimatable[];
  45016. /**
  45017. * Returns the texture used for reflections.
  45018. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45019. */
  45020. private _getReflectionTexture;
  45021. /**
  45022. * Returns the texture used for refraction or null if none is used.
  45023. * @returns - Refection texture if present. If no refraction texture and refraction
  45024. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45025. */
  45026. private _getRefractionTexture;
  45027. /**
  45028. * Disposes the resources of the material.
  45029. * @param forceDisposeEffect - Forces the disposal of effects.
  45030. * @param forceDisposeTextures - Forces the disposal of all textures.
  45031. */
  45032. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45033. }
  45034. }
  45035. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45036. import { Nullable } from "babylonjs/types";
  45037. import { Scene } from "babylonjs/scene";
  45038. import { Color3 } from "babylonjs/Maths/math";
  45039. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45040. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45042. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45043. /**
  45044. * The Physically based material of BJS.
  45045. *
  45046. * This offers the main features of a standard PBR material.
  45047. * For more information, please refer to the documentation :
  45048. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45049. */
  45050. export class PBRMaterial extends PBRBaseMaterial {
  45051. /**
  45052. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45053. */
  45054. static readonly PBRMATERIAL_OPAQUE: number;
  45055. /**
  45056. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45057. */
  45058. static readonly PBRMATERIAL_ALPHATEST: number;
  45059. /**
  45060. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45061. */
  45062. static readonly PBRMATERIAL_ALPHABLEND: number;
  45063. /**
  45064. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45065. * They are also discarded below the alpha cutoff threshold to improve performances.
  45066. */
  45067. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45068. /**
  45069. * Defines the default value of how much AO map is occluding the analytical lights
  45070. * (point spot...).
  45071. */
  45072. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45073. /**
  45074. * Intensity of the direct lights e.g. the four lights available in your scene.
  45075. * This impacts both the direct diffuse and specular highlights.
  45076. */
  45077. directIntensity: number;
  45078. /**
  45079. * Intensity of the emissive part of the material.
  45080. * This helps controlling the emissive effect without modifying the emissive color.
  45081. */
  45082. emissiveIntensity: number;
  45083. /**
  45084. * Intensity of the environment e.g. how much the environment will light the object
  45085. * either through harmonics for rough material or through the refelction for shiny ones.
  45086. */
  45087. environmentIntensity: number;
  45088. /**
  45089. * This is a special control allowing the reduction of the specular highlights coming from the
  45090. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45091. */
  45092. specularIntensity: number;
  45093. /**
  45094. * Debug Control allowing disabling the bump map on this material.
  45095. */
  45096. disableBumpMap: boolean;
  45097. /**
  45098. * AKA Diffuse Texture in standard nomenclature.
  45099. */
  45100. albedoTexture: BaseTexture;
  45101. /**
  45102. * AKA Occlusion Texture in other nomenclature.
  45103. */
  45104. ambientTexture: BaseTexture;
  45105. /**
  45106. * AKA Occlusion Texture Intensity in other nomenclature.
  45107. */
  45108. ambientTextureStrength: number;
  45109. /**
  45110. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45111. * 1 means it completely occludes it
  45112. * 0 mean it has no impact
  45113. */
  45114. ambientTextureImpactOnAnalyticalLights: number;
  45115. /**
  45116. * Stores the alpha values in a texture.
  45117. */
  45118. opacityTexture: BaseTexture;
  45119. /**
  45120. * Stores the reflection values in a texture.
  45121. */
  45122. reflectionTexture: Nullable<BaseTexture>;
  45123. /**
  45124. * Stores the emissive values in a texture.
  45125. */
  45126. emissiveTexture: BaseTexture;
  45127. /**
  45128. * AKA Specular texture in other nomenclature.
  45129. */
  45130. reflectivityTexture: BaseTexture;
  45131. /**
  45132. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45133. */
  45134. metallicTexture: BaseTexture;
  45135. /**
  45136. * Specifies the metallic scalar of the metallic/roughness workflow.
  45137. * Can also be used to scale the metalness values of the metallic texture.
  45138. */
  45139. metallic: Nullable<number>;
  45140. /**
  45141. * Specifies the roughness scalar of the metallic/roughness workflow.
  45142. * Can also be used to scale the roughness values of the metallic texture.
  45143. */
  45144. roughness: Nullable<number>;
  45145. /**
  45146. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45147. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45148. */
  45149. microSurfaceTexture: BaseTexture;
  45150. /**
  45151. * Stores surface normal data used to displace a mesh in a texture.
  45152. */
  45153. bumpTexture: BaseTexture;
  45154. /**
  45155. * Stores the pre-calculated light information of a mesh in a texture.
  45156. */
  45157. lightmapTexture: BaseTexture;
  45158. /**
  45159. * Stores the refracted light information in a texture.
  45160. */
  45161. refractionTexture: BaseTexture;
  45162. /**
  45163. * The color of a material in ambient lighting.
  45164. */
  45165. ambientColor: Color3;
  45166. /**
  45167. * AKA Diffuse Color in other nomenclature.
  45168. */
  45169. albedoColor: Color3;
  45170. /**
  45171. * AKA Specular Color in other nomenclature.
  45172. */
  45173. reflectivityColor: Color3;
  45174. /**
  45175. * The color reflected from the material.
  45176. */
  45177. reflectionColor: Color3;
  45178. /**
  45179. * The color emitted from the material.
  45180. */
  45181. emissiveColor: Color3;
  45182. /**
  45183. * AKA Glossiness in other nomenclature.
  45184. */
  45185. microSurface: number;
  45186. /**
  45187. * source material index of refraction (IOR)' / 'destination material IOR.
  45188. */
  45189. indexOfRefraction: number;
  45190. /**
  45191. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45192. */
  45193. invertRefractionY: boolean;
  45194. /**
  45195. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45196. * Materials half opaque for instance using refraction could benefit from this control.
  45197. */
  45198. linkRefractionWithTransparency: boolean;
  45199. /**
  45200. * If true, the light map contains occlusion information instead of lighting info.
  45201. */
  45202. useLightmapAsShadowmap: boolean;
  45203. /**
  45204. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45205. */
  45206. useAlphaFromAlbedoTexture: boolean;
  45207. /**
  45208. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45209. */
  45210. forceAlphaTest: boolean;
  45211. /**
  45212. * Defines the alpha limits in alpha test mode.
  45213. */
  45214. alphaCutOff: number;
  45215. /**
  45216. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45217. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45218. */
  45219. useSpecularOverAlpha: boolean;
  45220. /**
  45221. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45222. */
  45223. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45224. /**
  45225. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45226. */
  45227. useRoughnessFromMetallicTextureAlpha: boolean;
  45228. /**
  45229. * Specifies if the metallic texture contains the roughness information in its green channel.
  45230. */
  45231. useRoughnessFromMetallicTextureGreen: boolean;
  45232. /**
  45233. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45234. */
  45235. useMetallnessFromMetallicTextureBlue: boolean;
  45236. /**
  45237. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45238. */
  45239. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45240. /**
  45241. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45242. */
  45243. useAmbientInGrayScale: boolean;
  45244. /**
  45245. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45246. * The material will try to infer what glossiness each pixel should be.
  45247. */
  45248. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45249. /**
  45250. * BJS is using an harcoded light falloff based on a manually sets up range.
  45251. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45252. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45253. */
  45254. /**
  45255. * BJS is using an harcoded light falloff based on a manually sets up range.
  45256. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45257. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45258. */
  45259. usePhysicalLightFalloff: boolean;
  45260. /**
  45261. * In order to support the falloff compatibility with gltf, a special mode has been added
  45262. * to reproduce the gltf light falloff.
  45263. */
  45264. /**
  45265. * In order to support the falloff compatibility with gltf, a special mode has been added
  45266. * to reproduce the gltf light falloff.
  45267. */
  45268. useGLTFLightFalloff: boolean;
  45269. /**
  45270. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45271. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45272. */
  45273. useRadianceOverAlpha: boolean;
  45274. /**
  45275. * Allows using an object space normal map (instead of tangent space).
  45276. */
  45277. useObjectSpaceNormalMap: boolean;
  45278. /**
  45279. * Allows using the bump map in parallax mode.
  45280. */
  45281. useParallax: boolean;
  45282. /**
  45283. * Allows using the bump map in parallax occlusion mode.
  45284. */
  45285. useParallaxOcclusion: boolean;
  45286. /**
  45287. * Controls the scale bias of the parallax mode.
  45288. */
  45289. parallaxScaleBias: number;
  45290. /**
  45291. * If sets to true, disables all the lights affecting the material.
  45292. */
  45293. disableLighting: boolean;
  45294. /**
  45295. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45296. */
  45297. forceIrradianceInFragment: boolean;
  45298. /**
  45299. * Number of Simultaneous lights allowed on the material.
  45300. */
  45301. maxSimultaneousLights: number;
  45302. /**
  45303. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45304. */
  45305. invertNormalMapX: boolean;
  45306. /**
  45307. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45308. */
  45309. invertNormalMapY: boolean;
  45310. /**
  45311. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45312. */
  45313. twoSidedLighting: boolean;
  45314. /**
  45315. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45316. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45317. */
  45318. useAlphaFresnel: boolean;
  45319. /**
  45320. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45321. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45322. */
  45323. useLinearAlphaFresnel: boolean;
  45324. /**
  45325. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45326. * And/Or occlude the blended part.
  45327. */
  45328. environmentBRDFTexture: Nullable<BaseTexture>;
  45329. /**
  45330. * Force normal to face away from face.
  45331. */
  45332. forceNormalForward: boolean;
  45333. /**
  45334. * Enables specular anti aliasing in the PBR shader.
  45335. * It will both interacts on the Geometry for analytical and IBL lighting.
  45336. * It also prefilter the roughness map based on the bump values.
  45337. */
  45338. enableSpecularAntiAliasing: boolean;
  45339. /**
  45340. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45341. * makes the reflect vector face the model (under horizon).
  45342. */
  45343. useHorizonOcclusion: boolean;
  45344. /**
  45345. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45346. * too much the area relying on ambient texture to define their ambient occlusion.
  45347. */
  45348. useRadianceOcclusion: boolean;
  45349. /**
  45350. * If set to true, no lighting calculations will be applied.
  45351. */
  45352. unlit: boolean;
  45353. /**
  45354. * Gets the image processing configuration used either in this material.
  45355. */
  45356. /**
  45357. * Sets the Default image processing configuration used either in the this material.
  45358. *
  45359. * If sets to null, the scene one is in use.
  45360. */
  45361. imageProcessingConfiguration: ImageProcessingConfiguration;
  45362. /**
  45363. * Gets wether the color curves effect is enabled.
  45364. */
  45365. /**
  45366. * Sets wether the color curves effect is enabled.
  45367. */
  45368. cameraColorCurvesEnabled: boolean;
  45369. /**
  45370. * Gets wether the color grading effect is enabled.
  45371. */
  45372. /**
  45373. * Gets wether the color grading effect is enabled.
  45374. */
  45375. cameraColorGradingEnabled: boolean;
  45376. /**
  45377. * Gets wether tonemapping is enabled or not.
  45378. */
  45379. /**
  45380. * Sets wether tonemapping is enabled or not
  45381. */
  45382. cameraToneMappingEnabled: boolean;
  45383. /**
  45384. * The camera exposure used on this material.
  45385. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45386. * This corresponds to a photographic exposure.
  45387. */
  45388. /**
  45389. * The camera exposure used on this material.
  45390. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45391. * This corresponds to a photographic exposure.
  45392. */
  45393. cameraExposure: number;
  45394. /**
  45395. * Gets The camera contrast used on this material.
  45396. */
  45397. /**
  45398. * Sets The camera contrast used on this material.
  45399. */
  45400. cameraContrast: number;
  45401. /**
  45402. * Gets the Color Grading 2D Lookup Texture.
  45403. */
  45404. /**
  45405. * Sets the Color Grading 2D Lookup Texture.
  45406. */
  45407. cameraColorGradingTexture: Nullable<BaseTexture>;
  45408. /**
  45409. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45410. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45411. * 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;
  45412. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45413. */
  45414. /**
  45415. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45416. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45417. * 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;
  45418. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45419. */
  45420. cameraColorCurves: Nullable<ColorCurves>;
  45421. /**
  45422. * Instantiates a new PBRMaterial instance.
  45423. *
  45424. * @param name The material name
  45425. * @param scene The scene the material will be use in.
  45426. */
  45427. constructor(name: string, scene: Scene);
  45428. /**
  45429. * Returns the name of this material class.
  45430. */
  45431. getClassName(): string;
  45432. /**
  45433. * Returns an array of the actively used textures.
  45434. * @returns - Array of BaseTextures
  45435. */
  45436. getActiveTextures(): BaseTexture[];
  45437. /**
  45438. * Checks to see if a texture is used in the material.
  45439. * @param texture - Base texture to use.
  45440. * @returns - Boolean specifying if a texture is used in the material.
  45441. */
  45442. hasTexture(texture: BaseTexture): boolean;
  45443. /**
  45444. * Makes a duplicate of the current material.
  45445. * @param name - name to use for the new material.
  45446. */
  45447. clone(name: string): PBRMaterial;
  45448. /**
  45449. * Serializes this PBR Material.
  45450. * @returns - An object with the serialized material.
  45451. */
  45452. serialize(): any;
  45453. /**
  45454. * Parses a PBR Material from a serialized object.
  45455. * @param source - Serialized object.
  45456. * @param scene - BJS scene instance.
  45457. * @param rootUrl - url for the scene object
  45458. * @returns - PBRMaterial
  45459. */
  45460. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45461. }
  45462. }
  45463. declare module "babylonjs/Helpers/sceneHelpers" {
  45464. import { Nullable } from "babylonjs/types";
  45465. import { Mesh } from "babylonjs/Meshes/mesh";
  45466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45467. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45468. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45469. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45470. import "babylonjs/Meshes/meshBuilder";
  45471. /** @hidden */
  45472. export var _forceSceneHelpersToBundle: boolean;
  45473. module "babylonjs/scene" {
  45474. interface Scene {
  45475. /**
  45476. * Creates a default light for the scene.
  45477. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45478. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45479. */
  45480. createDefaultLight(replace?: boolean): void;
  45481. /**
  45482. * Creates a default camera for the scene.
  45483. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45484. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45485. * @param replace has default false, when true replaces the active camera in the scene
  45486. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45487. */
  45488. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45489. /**
  45490. * Creates a default camera and a default light.
  45491. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45492. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45493. * @param replace has the default false, when true replaces the active camera/light in the scene
  45494. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45495. */
  45496. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45497. /**
  45498. * Creates a new sky box
  45499. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45500. * @param environmentTexture defines the texture to use as environment texture
  45501. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45502. * @param scale defines the overall scale of the skybox
  45503. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45504. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45505. * @returns a new mesh holding the sky box
  45506. */
  45507. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45508. /**
  45509. * Creates a new environment
  45510. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45511. * @param options defines the options you can use to configure the environment
  45512. * @returns the new EnvironmentHelper
  45513. */
  45514. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45515. /**
  45516. * Creates a new VREXperienceHelper
  45517. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45518. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45519. * @returns a new VREXperienceHelper
  45520. */
  45521. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45522. /**
  45523. * Creates a new XREXperienceHelper
  45524. * @see http://doc.babylonjs.com/how_to/webxr
  45525. * @returns a promise for a new XREXperienceHelper
  45526. */
  45527. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45528. }
  45529. }
  45530. }
  45531. declare module "babylonjs/Helpers/videoDome" {
  45532. import { Scene } from "babylonjs/scene";
  45533. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45534. import { Mesh } from "babylonjs/Meshes/mesh";
  45535. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45536. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45537. import "babylonjs/Meshes/meshBuilder";
  45538. /**
  45539. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45540. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45541. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45542. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45543. */
  45544. export class VideoDome extends TransformNode {
  45545. private _useDirectMapping;
  45546. /**
  45547. * The video texture being displayed on the sphere
  45548. */
  45549. protected _videoTexture: VideoTexture;
  45550. /**
  45551. * Gets the video texture being displayed on the sphere
  45552. */
  45553. readonly videoTexture: VideoTexture;
  45554. /**
  45555. * The skybox material
  45556. */
  45557. protected _material: BackgroundMaterial;
  45558. /**
  45559. * The surface used for the skybox
  45560. */
  45561. protected _mesh: Mesh;
  45562. /**
  45563. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45564. * Also see the options.resolution property.
  45565. */
  45566. fovMultiplier: number;
  45567. /**
  45568. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45569. * @param name Element's name, child elements will append suffixes for their own names.
  45570. * @param urlsOrVideo defines the url(s) or the video element to use
  45571. * @param options An object containing optional or exposed sub element properties
  45572. */
  45573. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45574. resolution?: number;
  45575. clickToPlay?: boolean;
  45576. autoPlay?: boolean;
  45577. loop?: boolean;
  45578. size?: number;
  45579. poster?: string;
  45580. useDirectMapping?: boolean;
  45581. }, scene: Scene);
  45582. /**
  45583. * Releases resources associated with this node.
  45584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45586. */
  45587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45588. }
  45589. }
  45590. declare module "babylonjs/Helpers/index" {
  45591. export * from "babylonjs/Helpers/environmentHelper";
  45592. export * from "babylonjs/Helpers/photoDome";
  45593. export * from "babylonjs/Helpers/sceneHelpers";
  45594. export * from "babylonjs/Helpers/videoDome";
  45595. }
  45596. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45597. import { PerfCounter } from "babylonjs/Misc/tools";
  45598. import { IDisposable } from "babylonjs/scene";
  45599. import { Engine } from "babylonjs/Engines/engine";
  45600. /**
  45601. * This class can be used to get instrumentation data from a Babylon engine
  45602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45603. */
  45604. export class EngineInstrumentation implements IDisposable {
  45605. /**
  45606. * Define the instrumented engine.
  45607. */
  45608. engine: Engine;
  45609. private _captureGPUFrameTime;
  45610. private _gpuFrameTimeToken;
  45611. private _gpuFrameTime;
  45612. private _captureShaderCompilationTime;
  45613. private _shaderCompilationTime;
  45614. private _onBeginFrameObserver;
  45615. private _onEndFrameObserver;
  45616. private _onBeforeShaderCompilationObserver;
  45617. private _onAfterShaderCompilationObserver;
  45618. /**
  45619. * Gets the perf counter used for GPU frame time
  45620. */
  45621. readonly gpuFrameTimeCounter: PerfCounter;
  45622. /**
  45623. * Gets the GPU frame time capture status
  45624. */
  45625. /**
  45626. * Enable or disable the GPU frame time capture
  45627. */
  45628. captureGPUFrameTime: boolean;
  45629. /**
  45630. * Gets the perf counter used for shader compilation time
  45631. */
  45632. readonly shaderCompilationTimeCounter: PerfCounter;
  45633. /**
  45634. * Gets the shader compilation time capture status
  45635. */
  45636. /**
  45637. * Enable or disable the shader compilation time capture
  45638. */
  45639. captureShaderCompilationTime: boolean;
  45640. /**
  45641. * Instantiates a new engine instrumentation.
  45642. * This class can be used to get instrumentation data from a Babylon engine
  45643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45644. * @param engine Defines the engine to instrument
  45645. */
  45646. constructor(
  45647. /**
  45648. * Define the instrumented engine.
  45649. */
  45650. engine: Engine);
  45651. /**
  45652. * Dispose and release associated resources.
  45653. */
  45654. dispose(): void;
  45655. }
  45656. }
  45657. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45658. import { PerfCounter } from "babylonjs/Misc/tools";
  45659. import { Scene, IDisposable } from "babylonjs/scene";
  45660. /**
  45661. * This class can be used to get instrumentation data from a Babylon engine
  45662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45663. */
  45664. export class SceneInstrumentation implements IDisposable {
  45665. /**
  45666. * Defines the scene to instrument
  45667. */
  45668. scene: Scene;
  45669. private _captureActiveMeshesEvaluationTime;
  45670. private _activeMeshesEvaluationTime;
  45671. private _captureRenderTargetsRenderTime;
  45672. private _renderTargetsRenderTime;
  45673. private _captureFrameTime;
  45674. private _frameTime;
  45675. private _captureRenderTime;
  45676. private _renderTime;
  45677. private _captureInterFrameTime;
  45678. private _interFrameTime;
  45679. private _captureParticlesRenderTime;
  45680. private _particlesRenderTime;
  45681. private _captureSpritesRenderTime;
  45682. private _spritesRenderTime;
  45683. private _capturePhysicsTime;
  45684. private _physicsTime;
  45685. private _captureAnimationsTime;
  45686. private _animationsTime;
  45687. private _captureCameraRenderTime;
  45688. private _cameraRenderTime;
  45689. private _onBeforeActiveMeshesEvaluationObserver;
  45690. private _onAfterActiveMeshesEvaluationObserver;
  45691. private _onBeforeRenderTargetsRenderObserver;
  45692. private _onAfterRenderTargetsRenderObserver;
  45693. private _onAfterRenderObserver;
  45694. private _onBeforeDrawPhaseObserver;
  45695. private _onAfterDrawPhaseObserver;
  45696. private _onBeforeAnimationsObserver;
  45697. private _onBeforeParticlesRenderingObserver;
  45698. private _onAfterParticlesRenderingObserver;
  45699. private _onBeforeSpritesRenderingObserver;
  45700. private _onAfterSpritesRenderingObserver;
  45701. private _onBeforePhysicsObserver;
  45702. private _onAfterPhysicsObserver;
  45703. private _onAfterAnimationsObserver;
  45704. private _onBeforeCameraRenderObserver;
  45705. private _onAfterCameraRenderObserver;
  45706. /**
  45707. * Gets the perf counter used for active meshes evaluation time
  45708. */
  45709. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45710. /**
  45711. * Gets the active meshes evaluation time capture status
  45712. */
  45713. /**
  45714. * Enable or disable the active meshes evaluation time capture
  45715. */
  45716. captureActiveMeshesEvaluationTime: boolean;
  45717. /**
  45718. * Gets the perf counter used for render targets render time
  45719. */
  45720. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45721. /**
  45722. * Gets the render targets render time capture status
  45723. */
  45724. /**
  45725. * Enable or disable the render targets render time capture
  45726. */
  45727. captureRenderTargetsRenderTime: boolean;
  45728. /**
  45729. * Gets the perf counter used for particles render time
  45730. */
  45731. readonly particlesRenderTimeCounter: PerfCounter;
  45732. /**
  45733. * Gets the particles render time capture status
  45734. */
  45735. /**
  45736. * Enable or disable the particles render time capture
  45737. */
  45738. captureParticlesRenderTime: boolean;
  45739. /**
  45740. * Gets the perf counter used for sprites render time
  45741. */
  45742. readonly spritesRenderTimeCounter: PerfCounter;
  45743. /**
  45744. * Gets the sprites render time capture status
  45745. */
  45746. /**
  45747. * Enable or disable the sprites render time capture
  45748. */
  45749. captureSpritesRenderTime: boolean;
  45750. /**
  45751. * Gets the perf counter used for physics time
  45752. */
  45753. readonly physicsTimeCounter: PerfCounter;
  45754. /**
  45755. * Gets the physics time capture status
  45756. */
  45757. /**
  45758. * Enable or disable the physics time capture
  45759. */
  45760. capturePhysicsTime: boolean;
  45761. /**
  45762. * Gets the perf counter used for animations time
  45763. */
  45764. readonly animationsTimeCounter: PerfCounter;
  45765. /**
  45766. * Gets the animations time capture status
  45767. */
  45768. /**
  45769. * Enable or disable the animations time capture
  45770. */
  45771. captureAnimationsTime: boolean;
  45772. /**
  45773. * Gets the perf counter used for frame time capture
  45774. */
  45775. readonly frameTimeCounter: PerfCounter;
  45776. /**
  45777. * Gets the frame time capture status
  45778. */
  45779. /**
  45780. * Enable or disable the frame time capture
  45781. */
  45782. captureFrameTime: boolean;
  45783. /**
  45784. * Gets the perf counter used for inter-frames time capture
  45785. */
  45786. readonly interFrameTimeCounter: PerfCounter;
  45787. /**
  45788. * Gets the inter-frames time capture status
  45789. */
  45790. /**
  45791. * Enable or disable the inter-frames time capture
  45792. */
  45793. captureInterFrameTime: boolean;
  45794. /**
  45795. * Gets the perf counter used for render time capture
  45796. */
  45797. readonly renderTimeCounter: PerfCounter;
  45798. /**
  45799. * Gets the render time capture status
  45800. */
  45801. /**
  45802. * Enable or disable the render time capture
  45803. */
  45804. captureRenderTime: boolean;
  45805. /**
  45806. * Gets the perf counter used for camera render time capture
  45807. */
  45808. readonly cameraRenderTimeCounter: PerfCounter;
  45809. /**
  45810. * Gets the camera render time capture status
  45811. */
  45812. /**
  45813. * Enable or disable the camera render time capture
  45814. */
  45815. captureCameraRenderTime: boolean;
  45816. /**
  45817. * Gets the perf counter used for draw calls
  45818. */
  45819. readonly drawCallsCounter: PerfCounter;
  45820. /**
  45821. * Gets the perf counter used for texture collisions
  45822. */
  45823. readonly textureCollisionsCounter: PerfCounter;
  45824. /**
  45825. * Instantiates a new scene instrumentation.
  45826. * This class can be used to get instrumentation data from a Babylon engine
  45827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45828. * @param scene Defines the scene to instrument
  45829. */
  45830. constructor(
  45831. /**
  45832. * Defines the scene to instrument
  45833. */
  45834. scene: Scene);
  45835. /**
  45836. * Dispose and release associated resources.
  45837. */
  45838. dispose(): void;
  45839. }
  45840. }
  45841. declare module "babylonjs/Instrumentation/index" {
  45842. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45843. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45844. export * from "babylonjs/Instrumentation/timeToken";
  45845. }
  45846. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45847. /** @hidden */
  45848. export var glowMapGenerationPixelShader: {
  45849. name: string;
  45850. shader: string;
  45851. };
  45852. }
  45853. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45854. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45859. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45860. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45861. /** @hidden */
  45862. export var glowMapGenerationVertexShader: {
  45863. name: string;
  45864. shader: string;
  45865. };
  45866. }
  45867. declare module "babylonjs/Layers/effectLayer" {
  45868. import { Observable } from "babylonjs/Misc/observable";
  45869. import { Nullable } from "babylonjs/types";
  45870. import { Camera } from "babylonjs/Cameras/camera";
  45871. import { Scene } from "babylonjs/scene";
  45872. import { Color4, ISize } from "babylonjs/Maths/math";
  45873. import { Engine } from "babylonjs/Engines/engine";
  45874. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45876. import { Mesh } from "babylonjs/Meshes/mesh";
  45877. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45880. import { Effect } from "babylonjs/Materials/effect";
  45881. import { Material } from "babylonjs/Materials/material";
  45882. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45883. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45884. /**
  45885. * Effect layer options. This helps customizing the behaviour
  45886. * of the effect layer.
  45887. */
  45888. export interface IEffectLayerOptions {
  45889. /**
  45890. * Multiplication factor apply to the canvas size to compute the render target size
  45891. * used to generated the objects (the smaller the faster).
  45892. */
  45893. mainTextureRatio: number;
  45894. /**
  45895. * Enforces a fixed size texture to ensure effect stability across devices.
  45896. */
  45897. mainTextureFixedSize?: number;
  45898. /**
  45899. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45900. */
  45901. alphaBlendingMode: number;
  45902. /**
  45903. * The camera attached to the layer.
  45904. */
  45905. camera: Nullable<Camera>;
  45906. /**
  45907. * The rendering group to draw the layer in.
  45908. */
  45909. renderingGroupId: number;
  45910. }
  45911. /**
  45912. * The effect layer Helps adding post process effect blended with the main pass.
  45913. *
  45914. * This can be for instance use to generate glow or higlight effects on the scene.
  45915. *
  45916. * The effect layer class can not be used directly and is intented to inherited from to be
  45917. * customized per effects.
  45918. */
  45919. export abstract class EffectLayer {
  45920. private _vertexBuffers;
  45921. private _indexBuffer;
  45922. private _cachedDefines;
  45923. private _effectLayerMapGenerationEffect;
  45924. private _effectLayerOptions;
  45925. private _mergeEffect;
  45926. protected _scene: Scene;
  45927. protected _engine: Engine;
  45928. protected _maxSize: number;
  45929. protected _mainTextureDesiredSize: ISize;
  45930. protected _mainTexture: RenderTargetTexture;
  45931. protected _shouldRender: boolean;
  45932. protected _postProcesses: PostProcess[];
  45933. protected _textures: BaseTexture[];
  45934. protected _emissiveTextureAndColor: {
  45935. texture: Nullable<BaseTexture>;
  45936. color: Color4;
  45937. };
  45938. /**
  45939. * The name of the layer
  45940. */
  45941. name: string;
  45942. /**
  45943. * The clear color of the texture used to generate the glow map.
  45944. */
  45945. neutralColor: Color4;
  45946. /**
  45947. * Specifies wether the highlight layer is enabled or not.
  45948. */
  45949. isEnabled: boolean;
  45950. /**
  45951. * Gets the camera attached to the layer.
  45952. */
  45953. readonly camera: Nullable<Camera>;
  45954. /**
  45955. * Gets the rendering group id the layer should render in.
  45956. */
  45957. readonly renderingGroupId: number;
  45958. /**
  45959. * An event triggered when the effect layer has been disposed.
  45960. */
  45961. onDisposeObservable: Observable<EffectLayer>;
  45962. /**
  45963. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45964. */
  45965. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45966. /**
  45967. * An event triggered when the generated texture is being merged in the scene.
  45968. */
  45969. onBeforeComposeObservable: Observable<EffectLayer>;
  45970. /**
  45971. * An event triggered when the generated texture has been merged in the scene.
  45972. */
  45973. onAfterComposeObservable: Observable<EffectLayer>;
  45974. /**
  45975. * An event triggered when the efffect layer changes its size.
  45976. */
  45977. onSizeChangedObservable: Observable<EffectLayer>;
  45978. /** @hidden */
  45979. static _SceneComponentInitialization: (scene: Scene) => void;
  45980. /**
  45981. * Instantiates a new effect Layer and references it in the scene.
  45982. * @param name The name of the layer
  45983. * @param scene The scene to use the layer in
  45984. */
  45985. constructor(
  45986. /** The Friendly of the effect in the scene */
  45987. name: string, scene: Scene);
  45988. /**
  45989. * Get the effect name of the layer.
  45990. * @return The effect name
  45991. */
  45992. abstract getEffectName(): string;
  45993. /**
  45994. * Checks for the readiness of the element composing the layer.
  45995. * @param subMesh the mesh to check for
  45996. * @param useInstances specify wether or not to use instances to render the mesh
  45997. * @return true if ready otherwise, false
  45998. */
  45999. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46000. /**
  46001. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46002. * @returns true if the effect requires stencil during the main canvas render pass.
  46003. */
  46004. abstract needStencil(): boolean;
  46005. /**
  46006. * Create the merge effect. This is the shader use to blit the information back
  46007. * to the main canvas at the end of the scene rendering.
  46008. * @returns The effect containing the shader used to merge the effect on the main canvas
  46009. */
  46010. protected abstract _createMergeEffect(): Effect;
  46011. /**
  46012. * Creates the render target textures and post processes used in the effect layer.
  46013. */
  46014. protected abstract _createTextureAndPostProcesses(): void;
  46015. /**
  46016. * Implementation specific of rendering the generating effect on the main canvas.
  46017. * @param effect The effect used to render through
  46018. */
  46019. protected abstract _internalRender(effect: Effect): void;
  46020. /**
  46021. * Sets the required values for both the emissive texture and and the main color.
  46022. */
  46023. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46024. /**
  46025. * Free any resources and references associated to a mesh.
  46026. * Internal use
  46027. * @param mesh The mesh to free.
  46028. */
  46029. abstract _disposeMesh(mesh: Mesh): void;
  46030. /**
  46031. * Serializes this layer (Glow or Highlight for example)
  46032. * @returns a serialized layer object
  46033. */
  46034. abstract serialize?(): any;
  46035. /**
  46036. * Initializes the effect layer with the required options.
  46037. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46038. */
  46039. protected _init(options: Partial<IEffectLayerOptions>): void;
  46040. /**
  46041. * Generates the index buffer of the full screen quad blending to the main canvas.
  46042. */
  46043. private _generateIndexBuffer;
  46044. /**
  46045. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46046. */
  46047. private _genrateVertexBuffer;
  46048. /**
  46049. * Sets the main texture desired size which is the closest power of two
  46050. * of the engine canvas size.
  46051. */
  46052. private _setMainTextureSize;
  46053. /**
  46054. * Creates the main texture for the effect layer.
  46055. */
  46056. protected _createMainTexture(): void;
  46057. /**
  46058. * Adds specific effects defines.
  46059. * @param defines The defines to add specifics to.
  46060. */
  46061. protected _addCustomEffectDefines(defines: string[]): void;
  46062. /**
  46063. * Checks for the readiness of the element composing the layer.
  46064. * @param subMesh the mesh to check for
  46065. * @param useInstances specify wether or not to use instances to render the mesh
  46066. * @param emissiveTexture the associated emissive texture used to generate the glow
  46067. * @return true if ready otherwise, false
  46068. */
  46069. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46070. /**
  46071. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46072. */
  46073. render(): void;
  46074. /**
  46075. * Determine if a given mesh will be used in the current effect.
  46076. * @param mesh mesh to test
  46077. * @returns true if the mesh will be used
  46078. */
  46079. hasMesh(mesh: AbstractMesh): boolean;
  46080. /**
  46081. * Returns true if the layer contains information to display, otherwise false.
  46082. * @returns true if the glow layer should be rendered
  46083. */
  46084. shouldRender(): boolean;
  46085. /**
  46086. * Returns true if the mesh should render, otherwise false.
  46087. * @param mesh The mesh to render
  46088. * @returns true if it should render otherwise false
  46089. */
  46090. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46091. /**
  46092. * Returns true if the mesh can be rendered, otherwise false.
  46093. * @param mesh The mesh to render
  46094. * @param material The material used on the mesh
  46095. * @returns true if it can be rendered otherwise false
  46096. */
  46097. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46098. /**
  46099. * Returns true if the mesh should render, otherwise false.
  46100. * @param mesh The mesh to render
  46101. * @returns true if it should render otherwise false
  46102. */
  46103. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46104. /**
  46105. * Renders the submesh passed in parameter to the generation map.
  46106. */
  46107. protected _renderSubMesh(subMesh: SubMesh): void;
  46108. /**
  46109. * Rebuild the required buffers.
  46110. * @hidden Internal use only.
  46111. */
  46112. _rebuild(): void;
  46113. /**
  46114. * Dispose only the render target textures and post process.
  46115. */
  46116. private _disposeTextureAndPostProcesses;
  46117. /**
  46118. * Dispose the highlight layer and free resources.
  46119. */
  46120. dispose(): void;
  46121. /**
  46122. * Gets the class name of the effect layer
  46123. * @returns the string with the class name of the effect layer
  46124. */
  46125. getClassName(): string;
  46126. /**
  46127. * Creates an effect layer from parsed effect layer data
  46128. * @param parsedEffectLayer defines effect layer data
  46129. * @param scene defines the current scene
  46130. * @param rootUrl defines the root URL containing the effect layer information
  46131. * @returns a parsed effect Layer
  46132. */
  46133. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46134. }
  46135. }
  46136. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46137. import { Scene } from "babylonjs/scene";
  46138. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46139. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46140. import { AbstractScene } from "babylonjs/abstractScene";
  46141. module "babylonjs/abstractScene" {
  46142. interface AbstractScene {
  46143. /**
  46144. * The list of effect layers (highlights/glow) added to the scene
  46145. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46146. * @see http://doc.babylonjs.com/how_to/glow_layer
  46147. */
  46148. effectLayers: Array<EffectLayer>;
  46149. /**
  46150. * Removes the given effect layer from this scene.
  46151. * @param toRemove defines the effect layer to remove
  46152. * @returns the index of the removed effect layer
  46153. */
  46154. removeEffectLayer(toRemove: EffectLayer): number;
  46155. /**
  46156. * Adds the given effect layer to this scene
  46157. * @param newEffectLayer defines the effect layer to add
  46158. */
  46159. addEffectLayer(newEffectLayer: EffectLayer): void;
  46160. }
  46161. }
  46162. /**
  46163. * Defines the layer scene component responsible to manage any effect layers
  46164. * in a given scene.
  46165. */
  46166. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46167. /**
  46168. * The component name helpfull to identify the component in the list of scene components.
  46169. */
  46170. readonly name: string;
  46171. /**
  46172. * The scene the component belongs to.
  46173. */
  46174. scene: Scene;
  46175. private _engine;
  46176. private _renderEffects;
  46177. private _needStencil;
  46178. private _previousStencilState;
  46179. /**
  46180. * Creates a new instance of the component for the given scene
  46181. * @param scene Defines the scene to register the component in
  46182. */
  46183. constructor(scene: Scene);
  46184. /**
  46185. * Registers the component in a given scene
  46186. */
  46187. register(): void;
  46188. /**
  46189. * Rebuilds the elements related to this component in case of
  46190. * context lost for instance.
  46191. */
  46192. rebuild(): void;
  46193. /**
  46194. * Serializes the component data to the specified json object
  46195. * @param serializationObject The object to serialize to
  46196. */
  46197. serialize(serializationObject: any): void;
  46198. /**
  46199. * Adds all the element from the container to the scene
  46200. * @param container the container holding the elements
  46201. */
  46202. addFromContainer(container: AbstractScene): void;
  46203. /**
  46204. * Removes all the elements in the container from the scene
  46205. * @param container contains the elements to remove
  46206. */
  46207. removeFromContainer(container: AbstractScene): void;
  46208. /**
  46209. * Disposes the component and the associated ressources.
  46210. */
  46211. dispose(): void;
  46212. private _isReadyForMesh;
  46213. private _renderMainTexture;
  46214. private _setStencil;
  46215. private _setStencilBack;
  46216. private _draw;
  46217. private _drawCamera;
  46218. private _drawRenderingGroup;
  46219. }
  46220. }
  46221. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46222. /** @hidden */
  46223. export var glowMapMergePixelShader: {
  46224. name: string;
  46225. shader: string;
  46226. };
  46227. }
  46228. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46229. /** @hidden */
  46230. export var glowMapMergeVertexShader: {
  46231. name: string;
  46232. shader: string;
  46233. };
  46234. }
  46235. declare module "babylonjs/Layers/glowLayer" {
  46236. import { Nullable } from "babylonjs/types";
  46237. import { Camera } from "babylonjs/Cameras/camera";
  46238. import { Scene } from "babylonjs/scene";
  46239. import { Color4 } from "babylonjs/Maths/math";
  46240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46242. import { Mesh } from "babylonjs/Meshes/mesh";
  46243. import { Texture } from "babylonjs/Materials/Textures/texture";
  46244. import { Effect } from "babylonjs/Materials/effect";
  46245. import { Material } from "babylonjs/Materials/material";
  46246. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46247. import "babylonjs/Shaders/glowMapMerge.fragment";
  46248. import "babylonjs/Shaders/glowMapMerge.vertex";
  46249. module "babylonjs/abstractScene" {
  46250. interface AbstractScene {
  46251. /**
  46252. * Return a the first highlight layer of the scene with a given name.
  46253. * @param name The name of the highlight layer to look for.
  46254. * @return The highlight layer if found otherwise null.
  46255. */
  46256. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46257. }
  46258. }
  46259. /**
  46260. * Glow layer options. This helps customizing the behaviour
  46261. * of the glow layer.
  46262. */
  46263. export interface IGlowLayerOptions {
  46264. /**
  46265. * Multiplication factor apply to the canvas size to compute the render target size
  46266. * used to generated the glowing objects (the smaller the faster).
  46267. */
  46268. mainTextureRatio: number;
  46269. /**
  46270. * Enforces a fixed size texture to ensure resize independant blur.
  46271. */
  46272. mainTextureFixedSize?: number;
  46273. /**
  46274. * How big is the kernel of the blur texture.
  46275. */
  46276. blurKernelSize: number;
  46277. /**
  46278. * The camera attached to the layer.
  46279. */
  46280. camera: Nullable<Camera>;
  46281. /**
  46282. * Enable MSAA by chosing the number of samples.
  46283. */
  46284. mainTextureSamples?: number;
  46285. /**
  46286. * The rendering group to draw the layer in.
  46287. */
  46288. renderingGroupId: number;
  46289. }
  46290. /**
  46291. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46292. *
  46293. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46294. * glowy meshes to your scene.
  46295. *
  46296. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46297. */
  46298. export class GlowLayer extends EffectLayer {
  46299. /**
  46300. * Effect Name of the layer.
  46301. */
  46302. static readonly EffectName: string;
  46303. /**
  46304. * The default blur kernel size used for the glow.
  46305. */
  46306. static DefaultBlurKernelSize: number;
  46307. /**
  46308. * The default texture size ratio used for the glow.
  46309. */
  46310. static DefaultTextureRatio: number;
  46311. /**
  46312. * Sets the kernel size of the blur.
  46313. */
  46314. /**
  46315. * Gets the kernel size of the blur.
  46316. */
  46317. blurKernelSize: number;
  46318. /**
  46319. * Sets the glow intensity.
  46320. */
  46321. /**
  46322. * Gets the glow intensity.
  46323. */
  46324. intensity: number;
  46325. private _options;
  46326. private _intensity;
  46327. private _horizontalBlurPostprocess1;
  46328. private _verticalBlurPostprocess1;
  46329. private _horizontalBlurPostprocess2;
  46330. private _verticalBlurPostprocess2;
  46331. private _blurTexture1;
  46332. private _blurTexture2;
  46333. private _postProcesses1;
  46334. private _postProcesses2;
  46335. private _includedOnlyMeshes;
  46336. private _excludedMeshes;
  46337. /**
  46338. * Callback used to let the user override the color selection on a per mesh basis
  46339. */
  46340. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46341. /**
  46342. * Callback used to let the user override the texture selection on a per mesh basis
  46343. */
  46344. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46345. /**
  46346. * Instantiates a new glow Layer and references it to the scene.
  46347. * @param name The name of the layer
  46348. * @param scene The scene to use the layer in
  46349. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46350. */
  46351. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46352. /**
  46353. * Get the effect name of the layer.
  46354. * @return The effect name
  46355. */
  46356. getEffectName(): string;
  46357. /**
  46358. * Create the merge effect. This is the shader use to blit the information back
  46359. * to the main canvas at the end of the scene rendering.
  46360. */
  46361. protected _createMergeEffect(): Effect;
  46362. /**
  46363. * Creates the render target textures and post processes used in the glow layer.
  46364. */
  46365. protected _createTextureAndPostProcesses(): void;
  46366. /**
  46367. * Checks for the readiness of the element composing the layer.
  46368. * @param subMesh the mesh to check for
  46369. * @param useInstances specify wether or not to use instances to render the mesh
  46370. * @param emissiveTexture the associated emissive texture used to generate the glow
  46371. * @return true if ready otherwise, false
  46372. */
  46373. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46374. /**
  46375. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46376. */
  46377. needStencil(): boolean;
  46378. /**
  46379. * Returns true if the mesh can be rendered, otherwise false.
  46380. * @param mesh The mesh to render
  46381. * @param material The material used on the mesh
  46382. * @returns true if it can be rendered otherwise false
  46383. */
  46384. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46385. /**
  46386. * Implementation specific of rendering the generating effect on the main canvas.
  46387. * @param effect The effect used to render through
  46388. */
  46389. protected _internalRender(effect: Effect): void;
  46390. /**
  46391. * Sets the required values for both the emissive texture and and the main color.
  46392. */
  46393. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46394. /**
  46395. * Returns true if the mesh should render, otherwise false.
  46396. * @param mesh The mesh to render
  46397. * @returns true if it should render otherwise false
  46398. */
  46399. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46400. /**
  46401. * Adds specific effects defines.
  46402. * @param defines The defines to add specifics to.
  46403. */
  46404. protected _addCustomEffectDefines(defines: string[]): void;
  46405. /**
  46406. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46407. * @param mesh The mesh to exclude from the glow layer
  46408. */
  46409. addExcludedMesh(mesh: Mesh): void;
  46410. /**
  46411. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46412. * @param mesh The mesh to remove
  46413. */
  46414. removeExcludedMesh(mesh: Mesh): void;
  46415. /**
  46416. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46417. * @param mesh The mesh to include in the glow layer
  46418. */
  46419. addIncludedOnlyMesh(mesh: Mesh): void;
  46420. /**
  46421. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46422. * @param mesh The mesh to remove
  46423. */
  46424. removeIncludedOnlyMesh(mesh: Mesh): void;
  46425. /**
  46426. * Determine if a given mesh will be used in the glow layer
  46427. * @param mesh The mesh to test
  46428. * @returns true if the mesh will be highlighted by the current glow layer
  46429. */
  46430. hasMesh(mesh: AbstractMesh): boolean;
  46431. /**
  46432. * Free any resources and references associated to a mesh.
  46433. * Internal use
  46434. * @param mesh The mesh to free.
  46435. * @hidden
  46436. */
  46437. _disposeMesh(mesh: Mesh): void;
  46438. /**
  46439. * Gets the class name of the effect layer
  46440. * @returns the string with the class name of the effect layer
  46441. */
  46442. getClassName(): string;
  46443. /**
  46444. * Serializes this glow layer
  46445. * @returns a serialized glow layer object
  46446. */
  46447. serialize(): any;
  46448. /**
  46449. * Creates a Glow Layer from parsed glow layer data
  46450. * @param parsedGlowLayer defines glow layer data
  46451. * @param scene defines the current scene
  46452. * @param rootUrl defines the root URL containing the glow layer information
  46453. * @returns a parsed Glow Layer
  46454. */
  46455. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46456. }
  46457. }
  46458. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46459. /** @hidden */
  46460. export var glowBlurPostProcessPixelShader: {
  46461. name: string;
  46462. shader: string;
  46463. };
  46464. }
  46465. declare module "babylonjs/Layers/highlightLayer" {
  46466. import { Observable } from "babylonjs/Misc/observable";
  46467. import { Nullable } from "babylonjs/types";
  46468. import { Camera } from "babylonjs/Cameras/camera";
  46469. import { Scene } from "babylonjs/scene";
  46470. import { Color3, Color4 } from "babylonjs/Maths/math";
  46471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46473. import { Mesh } from "babylonjs/Meshes/mesh";
  46474. import { Effect } from "babylonjs/Materials/effect";
  46475. import { Material } from "babylonjs/Materials/material";
  46476. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46477. import "babylonjs/Shaders/glowMapMerge.fragment";
  46478. import "babylonjs/Shaders/glowMapMerge.vertex";
  46479. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46480. module "babylonjs/abstractScene" {
  46481. interface AbstractScene {
  46482. /**
  46483. * Return a the first highlight layer of the scene with a given name.
  46484. * @param name The name of the highlight layer to look for.
  46485. * @return The highlight layer if found otherwise null.
  46486. */
  46487. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46488. }
  46489. }
  46490. /**
  46491. * Highlight layer options. This helps customizing the behaviour
  46492. * of the highlight layer.
  46493. */
  46494. export interface IHighlightLayerOptions {
  46495. /**
  46496. * Multiplication factor apply to the canvas size to compute the render target size
  46497. * used to generated the glowing objects (the smaller the faster).
  46498. */
  46499. mainTextureRatio: number;
  46500. /**
  46501. * Enforces a fixed size texture to ensure resize independant blur.
  46502. */
  46503. mainTextureFixedSize?: number;
  46504. /**
  46505. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46506. * of the picture to blur (the smaller the faster).
  46507. */
  46508. blurTextureSizeRatio: number;
  46509. /**
  46510. * How big in texel of the blur texture is the vertical blur.
  46511. */
  46512. blurVerticalSize: number;
  46513. /**
  46514. * How big in texel of the blur texture is the horizontal blur.
  46515. */
  46516. blurHorizontalSize: number;
  46517. /**
  46518. * Alpha blending mode used to apply the blur. Default is combine.
  46519. */
  46520. alphaBlendingMode: number;
  46521. /**
  46522. * The camera attached to the layer.
  46523. */
  46524. camera: Nullable<Camera>;
  46525. /**
  46526. * Should we display highlight as a solid stroke?
  46527. */
  46528. isStroke?: boolean;
  46529. /**
  46530. * The rendering group to draw the layer in.
  46531. */
  46532. renderingGroupId: number;
  46533. }
  46534. /**
  46535. * The highlight layer Helps adding a glow effect around a mesh.
  46536. *
  46537. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46538. * glowy meshes to your scene.
  46539. *
  46540. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46541. */
  46542. export class HighlightLayer extends EffectLayer {
  46543. name: string;
  46544. /**
  46545. * Effect Name of the highlight layer.
  46546. */
  46547. static readonly EffectName: string;
  46548. /**
  46549. * The neutral color used during the preparation of the glow effect.
  46550. * This is black by default as the blend operation is a blend operation.
  46551. */
  46552. static NeutralColor: Color4;
  46553. /**
  46554. * Stencil value used for glowing meshes.
  46555. */
  46556. static GlowingMeshStencilReference: number;
  46557. /**
  46558. * Stencil value used for the other meshes in the scene.
  46559. */
  46560. static NormalMeshStencilReference: number;
  46561. /**
  46562. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46563. */
  46564. innerGlow: boolean;
  46565. /**
  46566. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46567. */
  46568. outerGlow: boolean;
  46569. /**
  46570. * Specifies the horizontal size of the blur.
  46571. */
  46572. /**
  46573. * Gets the horizontal size of the blur.
  46574. */
  46575. blurHorizontalSize: number;
  46576. /**
  46577. * Specifies the vertical size of the blur.
  46578. */
  46579. /**
  46580. * Gets the vertical size of the blur.
  46581. */
  46582. blurVerticalSize: number;
  46583. /**
  46584. * An event triggered when the highlight layer is being blurred.
  46585. */
  46586. onBeforeBlurObservable: Observable<HighlightLayer>;
  46587. /**
  46588. * An event triggered when the highlight layer has been blurred.
  46589. */
  46590. onAfterBlurObservable: Observable<HighlightLayer>;
  46591. private _instanceGlowingMeshStencilReference;
  46592. private _options;
  46593. private _downSamplePostprocess;
  46594. private _horizontalBlurPostprocess;
  46595. private _verticalBlurPostprocess;
  46596. private _blurTexture;
  46597. private _meshes;
  46598. private _excludedMeshes;
  46599. /**
  46600. * Instantiates a new highlight Layer and references it to the scene..
  46601. * @param name The name of the layer
  46602. * @param scene The scene to use the layer in
  46603. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46604. */
  46605. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46606. /**
  46607. * Get the effect name of the layer.
  46608. * @return The effect name
  46609. */
  46610. getEffectName(): string;
  46611. /**
  46612. * Create the merge effect. This is the shader use to blit the information back
  46613. * to the main canvas at the end of the scene rendering.
  46614. */
  46615. protected _createMergeEffect(): Effect;
  46616. /**
  46617. * Creates the render target textures and post processes used in the highlight layer.
  46618. */
  46619. protected _createTextureAndPostProcesses(): void;
  46620. /**
  46621. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46622. */
  46623. needStencil(): boolean;
  46624. /**
  46625. * Checks for the readiness of the element composing the layer.
  46626. * @param subMesh the mesh to check for
  46627. * @param useInstances specify wether or not to use instances to render the mesh
  46628. * @param emissiveTexture the associated emissive texture used to generate the glow
  46629. * @return true if ready otherwise, false
  46630. */
  46631. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46632. /**
  46633. * Implementation specific of rendering the generating effect on the main canvas.
  46634. * @param effect The effect used to render through
  46635. */
  46636. protected _internalRender(effect: Effect): void;
  46637. /**
  46638. * Returns true if the layer contains information to display, otherwise false.
  46639. */
  46640. shouldRender(): boolean;
  46641. /**
  46642. * Returns true if the mesh should render, otherwise false.
  46643. * @param mesh The mesh to render
  46644. * @returns true if it should render otherwise false
  46645. */
  46646. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46647. /**
  46648. * Sets the required values for both the emissive texture and and the main color.
  46649. */
  46650. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46651. /**
  46652. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46653. * @param mesh The mesh to exclude from the highlight layer
  46654. */
  46655. addExcludedMesh(mesh: Mesh): void;
  46656. /**
  46657. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46658. * @param mesh The mesh to highlight
  46659. */
  46660. removeExcludedMesh(mesh: Mesh): void;
  46661. /**
  46662. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46663. * @param mesh mesh to test
  46664. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46665. */
  46666. hasMesh(mesh: AbstractMesh): boolean;
  46667. /**
  46668. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46669. * @param mesh The mesh to highlight
  46670. * @param color The color of the highlight
  46671. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46672. */
  46673. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46674. /**
  46675. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46676. * @param mesh The mesh to highlight
  46677. */
  46678. removeMesh(mesh: Mesh): void;
  46679. /**
  46680. * Force the stencil to the normal expected value for none glowing parts
  46681. */
  46682. private _defaultStencilReference;
  46683. /**
  46684. * Free any resources and references associated to a mesh.
  46685. * Internal use
  46686. * @param mesh The mesh to free.
  46687. * @hidden
  46688. */
  46689. _disposeMesh(mesh: Mesh): void;
  46690. /**
  46691. * Dispose the highlight layer and free resources.
  46692. */
  46693. dispose(): void;
  46694. /**
  46695. * Gets the class name of the effect layer
  46696. * @returns the string with the class name of the effect layer
  46697. */
  46698. getClassName(): string;
  46699. /**
  46700. * Serializes this Highlight layer
  46701. * @returns a serialized Highlight layer object
  46702. */
  46703. serialize(): any;
  46704. /**
  46705. * Creates a Highlight layer from parsed Highlight layer data
  46706. * @param parsedHightlightLayer defines the Highlight layer data
  46707. * @param scene defines the current scene
  46708. * @param rootUrl defines the root URL containing the Highlight layer information
  46709. * @returns a parsed Highlight layer
  46710. */
  46711. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46712. }
  46713. }
  46714. declare module "babylonjs/Layers/index" {
  46715. export * from "babylonjs/Layers/effectLayer";
  46716. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46717. export * from "babylonjs/Layers/glowLayer";
  46718. export * from "babylonjs/Layers/highlightLayer";
  46719. export * from "babylonjs/Layers/layer";
  46720. export * from "babylonjs/Layers/layerSceneComponent";
  46721. }
  46722. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46723. /** @hidden */
  46724. export var lensFlarePixelShader: {
  46725. name: string;
  46726. shader: string;
  46727. };
  46728. }
  46729. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46730. /** @hidden */
  46731. export var lensFlareVertexShader: {
  46732. name: string;
  46733. shader: string;
  46734. };
  46735. }
  46736. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46737. import { Scene } from "babylonjs/scene";
  46738. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46740. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46741. import "babylonjs/Shaders/lensFlare.fragment";
  46742. import "babylonjs/Shaders/lensFlare.vertex";
  46743. /**
  46744. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46745. * It is usually composed of several `lensFlare`.
  46746. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46747. */
  46748. export class LensFlareSystem {
  46749. /**
  46750. * Define the name of the lens flare system
  46751. */
  46752. name: string;
  46753. /**
  46754. * List of lens flares used in this system.
  46755. */
  46756. lensFlares: LensFlare[];
  46757. /**
  46758. * Define a limit from the border the lens flare can be visible.
  46759. */
  46760. borderLimit: number;
  46761. /**
  46762. * Define a viewport border we do not want to see the lens flare in.
  46763. */
  46764. viewportBorder: number;
  46765. /**
  46766. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46767. */
  46768. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46769. /**
  46770. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46771. */
  46772. layerMask: number;
  46773. /**
  46774. * Define the id of the lens flare system in the scene.
  46775. * (equal to name by default)
  46776. */
  46777. id: string;
  46778. private _scene;
  46779. private _emitter;
  46780. private _vertexBuffers;
  46781. private _indexBuffer;
  46782. private _effect;
  46783. private _positionX;
  46784. private _positionY;
  46785. private _isEnabled;
  46786. /** @hidden */
  46787. static _SceneComponentInitialization: (scene: Scene) => void;
  46788. /**
  46789. * Instantiates a lens flare system.
  46790. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46791. * It is usually composed of several `lensFlare`.
  46792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46793. * @param name Define the name of the lens flare system in the scene
  46794. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46795. * @param scene Define the scene the lens flare system belongs to
  46796. */
  46797. constructor(
  46798. /**
  46799. * Define the name of the lens flare system
  46800. */
  46801. name: string, emitter: any, scene: Scene);
  46802. /**
  46803. * Define if the lens flare system is enabled.
  46804. */
  46805. isEnabled: boolean;
  46806. /**
  46807. * Get the scene the effects belongs to.
  46808. * @returns the scene holding the lens flare system
  46809. */
  46810. getScene(): Scene;
  46811. /**
  46812. * Get the emitter of the lens flare system.
  46813. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46814. * @returns the emitter of the lens flare system
  46815. */
  46816. getEmitter(): any;
  46817. /**
  46818. * Set the emitter of the lens flare system.
  46819. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46820. * @param newEmitter Define the new emitter of the system
  46821. */
  46822. setEmitter(newEmitter: any): void;
  46823. /**
  46824. * Get the lens flare system emitter position.
  46825. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46826. * @returns the position
  46827. */
  46828. getEmitterPosition(): Vector3;
  46829. /**
  46830. * @hidden
  46831. */
  46832. computeEffectivePosition(globalViewport: Viewport): boolean;
  46833. /** @hidden */
  46834. _isVisible(): boolean;
  46835. /**
  46836. * @hidden
  46837. */
  46838. render(): boolean;
  46839. /**
  46840. * Dispose and release the lens flare with its associated resources.
  46841. */
  46842. dispose(): void;
  46843. /**
  46844. * Parse a lens flare system from a JSON repressentation
  46845. * @param parsedLensFlareSystem Define the JSON to parse
  46846. * @param scene Define the scene the parsed system should be instantiated in
  46847. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46848. * @returns the parsed system
  46849. */
  46850. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46851. /**
  46852. * Serialize the current Lens Flare System into a JSON representation.
  46853. * @returns the serialized JSON
  46854. */
  46855. serialize(): any;
  46856. }
  46857. }
  46858. declare module "babylonjs/LensFlares/lensFlare" {
  46859. import { Nullable } from "babylonjs/types";
  46860. import { Color3 } from "babylonjs/Maths/math";
  46861. import { Texture } from "babylonjs/Materials/Textures/texture";
  46862. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46863. /**
  46864. * This represents one of the lens effect in a `lensFlareSystem`.
  46865. * It controls one of the indiviual texture used in the effect.
  46866. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46867. */
  46868. export class LensFlare {
  46869. /**
  46870. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46871. */
  46872. size: number;
  46873. /**
  46874. * 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.
  46875. */
  46876. position: number;
  46877. /**
  46878. * Define the lens color.
  46879. */
  46880. color: Color3;
  46881. /**
  46882. * Define the lens texture.
  46883. */
  46884. texture: Nullable<Texture>;
  46885. /**
  46886. * Define the alpha mode to render this particular lens.
  46887. */
  46888. alphaMode: number;
  46889. private _system;
  46890. /**
  46891. * Creates a new Lens Flare.
  46892. * This represents one of the lens effect in a `lensFlareSystem`.
  46893. * It controls one of the indiviual texture used in the effect.
  46894. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46895. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46896. * @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.
  46897. * @param color Define the lens color
  46898. * @param imgUrl Define the lens texture url
  46899. * @param system Define the `lensFlareSystem` this flare is part of
  46900. * @returns The newly created Lens Flare
  46901. */
  46902. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46903. /**
  46904. * Instantiates a new Lens Flare.
  46905. * This represents one of the lens effect in a `lensFlareSystem`.
  46906. * It controls one of the indiviual texture used in the effect.
  46907. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46908. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46909. * @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.
  46910. * @param color Define the lens color
  46911. * @param imgUrl Define the lens texture url
  46912. * @param system Define the `lensFlareSystem` this flare is part of
  46913. */
  46914. constructor(
  46915. /**
  46916. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46917. */
  46918. size: number,
  46919. /**
  46920. * 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.
  46921. */
  46922. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46923. /**
  46924. * Dispose and release the lens flare with its associated resources.
  46925. */
  46926. dispose(): void;
  46927. }
  46928. }
  46929. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46930. import { Nullable } from "babylonjs/types";
  46931. import { Scene } from "babylonjs/scene";
  46932. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46933. import { AbstractScene } from "babylonjs/abstractScene";
  46934. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46935. module "babylonjs/abstractScene" {
  46936. interface AbstractScene {
  46937. /**
  46938. * The list of lens flare system added to the scene
  46939. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46940. */
  46941. lensFlareSystems: Array<LensFlareSystem>;
  46942. /**
  46943. * Removes the given lens flare system from this scene.
  46944. * @param toRemove The lens flare system to remove
  46945. * @returns The index of the removed lens flare system
  46946. */
  46947. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46948. /**
  46949. * Adds the given lens flare system to this scene
  46950. * @param newLensFlareSystem The lens flare system to add
  46951. */
  46952. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46953. /**
  46954. * Gets a lens flare system using its name
  46955. * @param name defines the name to look for
  46956. * @returns the lens flare system or null if not found
  46957. */
  46958. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46959. /**
  46960. * Gets a lens flare system using its id
  46961. * @param id defines the id to look for
  46962. * @returns the lens flare system or null if not found
  46963. */
  46964. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46965. }
  46966. }
  46967. /**
  46968. * Defines the lens flare scene component responsible to manage any lens flares
  46969. * in a given scene.
  46970. */
  46971. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46972. /**
  46973. * The component name helpfull to identify the component in the list of scene components.
  46974. */
  46975. readonly name: string;
  46976. /**
  46977. * The scene the component belongs to.
  46978. */
  46979. scene: Scene;
  46980. /**
  46981. * Creates a new instance of the component for the given scene
  46982. * @param scene Defines the scene to register the component in
  46983. */
  46984. constructor(scene: Scene);
  46985. /**
  46986. * Registers the component in a given scene
  46987. */
  46988. register(): void;
  46989. /**
  46990. * Rebuilds the elements related to this component in case of
  46991. * context lost for instance.
  46992. */
  46993. rebuild(): void;
  46994. /**
  46995. * Adds all the element from the container to the scene
  46996. * @param container the container holding the elements
  46997. */
  46998. addFromContainer(container: AbstractScene): void;
  46999. /**
  47000. * Removes all the elements in the container from the scene
  47001. * @param container contains the elements to remove
  47002. */
  47003. removeFromContainer(container: AbstractScene): void;
  47004. /**
  47005. * Serializes the component data to the specified json object
  47006. * @param serializationObject The object to serialize to
  47007. */
  47008. serialize(serializationObject: any): void;
  47009. /**
  47010. * Disposes the component and the associated ressources.
  47011. */
  47012. dispose(): void;
  47013. private _draw;
  47014. }
  47015. }
  47016. declare module "babylonjs/LensFlares/index" {
  47017. export * from "babylonjs/LensFlares/lensFlare";
  47018. export * from "babylonjs/LensFlares/lensFlareSystem";
  47019. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47020. }
  47021. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47022. import { Scene } from "babylonjs/scene";
  47023. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47024. import { AbstractScene } from "babylonjs/abstractScene";
  47025. /**
  47026. * Defines the shadow generator component responsible to manage any shadow generators
  47027. * in a given scene.
  47028. */
  47029. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47030. /**
  47031. * The component name helpfull to identify the component in the list of scene components.
  47032. */
  47033. readonly name: string;
  47034. /**
  47035. * The scene the component belongs to.
  47036. */
  47037. scene: Scene;
  47038. /**
  47039. * Creates a new instance of the component for the given scene
  47040. * @param scene Defines the scene to register the component in
  47041. */
  47042. constructor(scene: Scene);
  47043. /**
  47044. * Registers the component in a given scene
  47045. */
  47046. register(): void;
  47047. /**
  47048. * Rebuilds the elements related to this component in case of
  47049. * context lost for instance.
  47050. */
  47051. rebuild(): void;
  47052. /**
  47053. * Serializes the component data to the specified json object
  47054. * @param serializationObject The object to serialize to
  47055. */
  47056. serialize(serializationObject: any): void;
  47057. /**
  47058. * Adds all the element from the container to the scene
  47059. * @param container the container holding the elements
  47060. */
  47061. addFromContainer(container: AbstractScene): void;
  47062. /**
  47063. * Removes all the elements in the container from the scene
  47064. * @param container contains the elements to remove
  47065. */
  47066. removeFromContainer(container: AbstractScene): void;
  47067. /**
  47068. * Rebuilds the elements related to this component in case of
  47069. * context lost for instance.
  47070. */
  47071. dispose(): void;
  47072. private _gatherRenderTargets;
  47073. }
  47074. }
  47075. declare module "babylonjs/Lights/Shadows/index" {
  47076. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47077. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47078. }
  47079. declare module "babylonjs/Lights/directionalLight" {
  47080. import { Camera } from "babylonjs/Cameras/camera";
  47081. import { Scene } from "babylonjs/scene";
  47082. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47084. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47085. import { Effect } from "babylonjs/Materials/effect";
  47086. /**
  47087. * A directional light is defined by a direction (what a surprise!).
  47088. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47089. * 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.
  47090. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47091. */
  47092. export class DirectionalLight extends ShadowLight {
  47093. private _shadowFrustumSize;
  47094. /**
  47095. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47096. */
  47097. /**
  47098. * Specifies a fix frustum size for the shadow generation.
  47099. */
  47100. shadowFrustumSize: number;
  47101. private _shadowOrthoScale;
  47102. /**
  47103. * Gets the shadow projection scale against the optimal computed one.
  47104. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47105. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47106. */
  47107. /**
  47108. * Sets the shadow projection scale against the optimal computed one.
  47109. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47110. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47111. */
  47112. shadowOrthoScale: number;
  47113. /**
  47114. * Automatically compute the projection matrix to best fit (including all the casters)
  47115. * on each frame.
  47116. */
  47117. autoUpdateExtends: boolean;
  47118. private _orthoLeft;
  47119. private _orthoRight;
  47120. private _orthoTop;
  47121. private _orthoBottom;
  47122. /**
  47123. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47124. * The directional light is emitted from everywhere in the given direction.
  47125. * It can cast shadows.
  47126. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47127. * @param name The friendly name of the light
  47128. * @param direction The direction of the light
  47129. * @param scene The scene the light belongs to
  47130. */
  47131. constructor(name: string, direction: Vector3, scene: Scene);
  47132. /**
  47133. * Returns the string "DirectionalLight".
  47134. * @return The class name
  47135. */
  47136. getClassName(): string;
  47137. /**
  47138. * Returns the integer 1.
  47139. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47140. */
  47141. getTypeID(): number;
  47142. /**
  47143. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47144. * Returns the DirectionalLight Shadow projection matrix.
  47145. */
  47146. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47147. /**
  47148. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47149. * Returns the DirectionalLight Shadow projection matrix.
  47150. */
  47151. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47152. /**
  47153. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47154. * Returns the DirectionalLight Shadow projection matrix.
  47155. */
  47156. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47157. protected _buildUniformLayout(): void;
  47158. /**
  47159. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47160. * @param effect The effect to update
  47161. * @param lightIndex The index of the light in the effect to update
  47162. * @returns The directional light
  47163. */
  47164. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47165. /**
  47166. * Gets the minZ used for shadow according to both the scene and the light.
  47167. *
  47168. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47169. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47170. * @param activeCamera The camera we are returning the min for
  47171. * @returns the depth min z
  47172. */
  47173. getDepthMinZ(activeCamera: Camera): number;
  47174. /**
  47175. * Gets the maxZ used for shadow according to both the scene and the light.
  47176. *
  47177. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47178. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47179. * @param activeCamera The camera we are returning the max for
  47180. * @returns the depth max z
  47181. */
  47182. getDepthMaxZ(activeCamera: Camera): number;
  47183. /**
  47184. * Prepares the list of defines specific to the light type.
  47185. * @param defines the list of defines
  47186. * @param lightIndex defines the index of the light for the effect
  47187. */
  47188. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47189. }
  47190. }
  47191. declare module "babylonjs/Lights/pointLight" {
  47192. import { Scene } from "babylonjs/scene";
  47193. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47195. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47196. import { Effect } from "babylonjs/Materials/effect";
  47197. /**
  47198. * A point light is a light defined by an unique point in world space.
  47199. * The light is emitted in every direction from this point.
  47200. * A good example of a point light is a standard light bulb.
  47201. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47202. */
  47203. export class PointLight extends ShadowLight {
  47204. private _shadowAngle;
  47205. /**
  47206. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47207. * This specifies what angle the shadow will use to be created.
  47208. *
  47209. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47210. */
  47211. /**
  47212. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47213. * This specifies what angle the shadow will use to be created.
  47214. *
  47215. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47216. */
  47217. shadowAngle: number;
  47218. /**
  47219. * Gets the direction if it has been set.
  47220. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47221. */
  47222. /**
  47223. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47224. */
  47225. direction: Vector3;
  47226. /**
  47227. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47228. * A PointLight emits the light in every direction.
  47229. * It can cast shadows.
  47230. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47231. * ```javascript
  47232. * var pointLight = new PointLight("pl", camera.position, scene);
  47233. * ```
  47234. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47235. * @param name The light friendly name
  47236. * @param position The position of the point light in the scene
  47237. * @param scene The scene the lights belongs to
  47238. */
  47239. constructor(name: string, position: Vector3, scene: Scene);
  47240. /**
  47241. * Returns the string "PointLight"
  47242. * @returns the class name
  47243. */
  47244. getClassName(): string;
  47245. /**
  47246. * Returns the integer 0.
  47247. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47248. */
  47249. getTypeID(): number;
  47250. /**
  47251. * Specifies wether or not the shadowmap should be a cube texture.
  47252. * @returns true if the shadowmap needs to be a cube texture.
  47253. */
  47254. needCube(): boolean;
  47255. /**
  47256. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47257. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47258. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47259. */
  47260. getShadowDirection(faceIndex?: number): Vector3;
  47261. /**
  47262. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47263. * - fov = PI / 2
  47264. * - aspect ratio : 1.0
  47265. * - z-near and far equal to the active camera minZ and maxZ.
  47266. * Returns the PointLight.
  47267. */
  47268. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47269. protected _buildUniformLayout(): void;
  47270. /**
  47271. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47272. * @param effect The effect to update
  47273. * @param lightIndex The index of the light in the effect to update
  47274. * @returns The point light
  47275. */
  47276. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47277. /**
  47278. * Prepares the list of defines specific to the light type.
  47279. * @param defines the list of defines
  47280. * @param lightIndex defines the index of the light for the effect
  47281. */
  47282. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47283. }
  47284. }
  47285. declare module "babylonjs/Lights/spotLight" {
  47286. import { Nullable } from "babylonjs/types";
  47287. import { Scene } from "babylonjs/scene";
  47288. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47290. import { Effect } from "babylonjs/Materials/effect";
  47291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47292. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47293. /**
  47294. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47295. * These values define a cone of light starting from the position, emitting toward the direction.
  47296. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47297. * and the exponent defines the speed of the decay of the light with distance (reach).
  47298. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47299. */
  47300. export class SpotLight extends ShadowLight {
  47301. private _angle;
  47302. private _innerAngle;
  47303. private _cosHalfAngle;
  47304. private _lightAngleScale;
  47305. private _lightAngleOffset;
  47306. /**
  47307. * Gets the cone angle of the spot light in Radians.
  47308. */
  47309. /**
  47310. * Sets the cone angle of the spot light in Radians.
  47311. */
  47312. angle: number;
  47313. /**
  47314. * Only used in gltf falloff mode, this defines the angle where
  47315. * the directional falloff will start before cutting at angle which could be seen
  47316. * as outer angle.
  47317. */
  47318. /**
  47319. * Only used in gltf falloff mode, this defines the angle where
  47320. * the directional falloff will start before cutting at angle which could be seen
  47321. * as outer angle.
  47322. */
  47323. innerAngle: number;
  47324. private _shadowAngleScale;
  47325. /**
  47326. * Allows scaling the angle of the light for shadow generation only.
  47327. */
  47328. /**
  47329. * Allows scaling the angle of the light for shadow generation only.
  47330. */
  47331. shadowAngleScale: number;
  47332. /**
  47333. * The light decay speed with the distance from the emission spot.
  47334. */
  47335. exponent: number;
  47336. private _projectionTextureMatrix;
  47337. /**
  47338. * Allows reading the projecton texture
  47339. */
  47340. readonly projectionTextureMatrix: Matrix;
  47341. protected _projectionTextureLightNear: number;
  47342. /**
  47343. * Gets the near clip of the Spotlight for texture projection.
  47344. */
  47345. /**
  47346. * Sets the near clip of the Spotlight for texture projection.
  47347. */
  47348. projectionTextureLightNear: number;
  47349. protected _projectionTextureLightFar: number;
  47350. /**
  47351. * Gets the far clip of the Spotlight for texture projection.
  47352. */
  47353. /**
  47354. * Sets the far clip of the Spotlight for texture projection.
  47355. */
  47356. projectionTextureLightFar: number;
  47357. protected _projectionTextureUpDirection: Vector3;
  47358. /**
  47359. * Gets the Up vector of the Spotlight for texture projection.
  47360. */
  47361. /**
  47362. * Sets the Up vector of the Spotlight for texture projection.
  47363. */
  47364. projectionTextureUpDirection: Vector3;
  47365. private _projectionTexture;
  47366. /**
  47367. * Gets the projection texture of the light.
  47368. */
  47369. /**
  47370. * Sets the projection texture of the light.
  47371. */
  47372. projectionTexture: Nullable<BaseTexture>;
  47373. private _projectionTextureViewLightDirty;
  47374. private _projectionTextureProjectionLightDirty;
  47375. private _projectionTextureDirty;
  47376. private _projectionTextureViewTargetVector;
  47377. private _projectionTextureViewLightMatrix;
  47378. private _projectionTextureProjectionLightMatrix;
  47379. private _projectionTextureScalingMatrix;
  47380. /**
  47381. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47382. * It can cast shadows.
  47383. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47384. * @param name The light friendly name
  47385. * @param position The position of the spot light in the scene
  47386. * @param direction The direction of the light in the scene
  47387. * @param angle The cone angle of the light in Radians
  47388. * @param exponent The light decay speed with the distance from the emission spot
  47389. * @param scene The scene the lights belongs to
  47390. */
  47391. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47392. /**
  47393. * Returns the string "SpotLight".
  47394. * @returns the class name
  47395. */
  47396. getClassName(): string;
  47397. /**
  47398. * Returns the integer 2.
  47399. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47400. */
  47401. getTypeID(): number;
  47402. /**
  47403. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47404. */
  47405. protected _setDirection(value: Vector3): void;
  47406. /**
  47407. * Overrides the position setter to recompute the projection texture view light Matrix.
  47408. */
  47409. protected _setPosition(value: Vector3): void;
  47410. /**
  47411. * 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.
  47412. * Returns the SpotLight.
  47413. */
  47414. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47415. protected _computeProjectionTextureViewLightMatrix(): void;
  47416. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47417. /**
  47418. * Main function for light texture projection matrix computing.
  47419. */
  47420. protected _computeProjectionTextureMatrix(): void;
  47421. protected _buildUniformLayout(): void;
  47422. private _computeAngleValues;
  47423. /**
  47424. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47425. * @param effect The effect to update
  47426. * @param lightIndex The index of the light in the effect to update
  47427. * @returns The spot light
  47428. */
  47429. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47430. /**
  47431. * Disposes the light and the associated resources.
  47432. */
  47433. dispose(): void;
  47434. /**
  47435. * Prepares the list of defines specific to the light type.
  47436. * @param defines the list of defines
  47437. * @param lightIndex defines the index of the light for the effect
  47438. */
  47439. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47440. }
  47441. }
  47442. declare module "babylonjs/Lights/index" {
  47443. export * from "babylonjs/Lights/light";
  47444. export * from "babylonjs/Lights/shadowLight";
  47445. export * from "babylonjs/Lights/Shadows/index";
  47446. export * from "babylonjs/Lights/directionalLight";
  47447. export * from "babylonjs/Lights/hemisphericLight";
  47448. export * from "babylonjs/Lights/pointLight";
  47449. export * from "babylonjs/Lights/spotLight";
  47450. }
  47451. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47452. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47453. /**
  47454. * Header information of HDR texture files.
  47455. */
  47456. export interface HDRInfo {
  47457. /**
  47458. * The height of the texture in pixels.
  47459. */
  47460. height: number;
  47461. /**
  47462. * The width of the texture in pixels.
  47463. */
  47464. width: number;
  47465. /**
  47466. * The index of the beginning of the data in the binary file.
  47467. */
  47468. dataPosition: number;
  47469. }
  47470. /**
  47471. * This groups tools to convert HDR texture to native colors array.
  47472. */
  47473. export class HDRTools {
  47474. private static Ldexp;
  47475. private static Rgbe2float;
  47476. private static readStringLine;
  47477. /**
  47478. * Reads header information from an RGBE texture stored in a native array.
  47479. * More information on this format are available here:
  47480. * https://en.wikipedia.org/wiki/RGBE_image_format
  47481. *
  47482. * @param uint8array The binary file stored in native array.
  47483. * @return The header information.
  47484. */
  47485. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47486. /**
  47487. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47488. * This RGBE texture needs to store the information as a panorama.
  47489. *
  47490. * More information on this format are available here:
  47491. * https://en.wikipedia.org/wiki/RGBE_image_format
  47492. *
  47493. * @param buffer The binary file stored in an array buffer.
  47494. * @param size The expected size of the extracted cubemap.
  47495. * @return The Cube Map information.
  47496. */
  47497. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47498. /**
  47499. * Returns the pixels data extracted from an RGBE texture.
  47500. * This pixels will be stored left to right up to down in the R G B order in one array.
  47501. *
  47502. * More information on this format are available here:
  47503. * https://en.wikipedia.org/wiki/RGBE_image_format
  47504. *
  47505. * @param uint8array The binary file stored in an array buffer.
  47506. * @param hdrInfo The header information of the file.
  47507. * @return The pixels data in RGB right to left up to down order.
  47508. */
  47509. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47510. private static RGBE_ReadPixels_RLE;
  47511. }
  47512. }
  47513. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47514. import { Nullable } from "babylonjs/types";
  47515. import { Scene } from "babylonjs/scene";
  47516. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47517. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47518. /**
  47519. * This represents a texture coming from an HDR input.
  47520. *
  47521. * The only supported format is currently panorama picture stored in RGBE format.
  47522. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47523. */
  47524. export class HDRCubeTexture extends BaseTexture {
  47525. private static _facesMapping;
  47526. private _generateHarmonics;
  47527. private _noMipmap;
  47528. private _textureMatrix;
  47529. private _size;
  47530. private _onLoad;
  47531. private _onError;
  47532. /**
  47533. * The texture URL.
  47534. */
  47535. url: string;
  47536. /**
  47537. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47538. */
  47539. coordinatesMode: number;
  47540. protected _isBlocking: boolean;
  47541. /**
  47542. * Sets wether or not the texture is blocking during loading.
  47543. */
  47544. /**
  47545. * Gets wether or not the texture is blocking during loading.
  47546. */
  47547. isBlocking: boolean;
  47548. protected _rotationY: number;
  47549. /**
  47550. * Sets texture matrix rotation angle around Y axis in radians.
  47551. */
  47552. /**
  47553. * Gets texture matrix rotation angle around Y axis radians.
  47554. */
  47555. rotationY: number;
  47556. /**
  47557. * Gets or sets the center of the bounding box associated with the cube texture
  47558. * It must define where the camera used to render the texture was set
  47559. */
  47560. boundingBoxPosition: Vector3;
  47561. private _boundingBoxSize;
  47562. /**
  47563. * Gets or sets the size of the bounding box associated with the cube texture
  47564. * When defined, the cubemap will switch to local mode
  47565. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47566. * @example https://www.babylonjs-playground.com/#RNASML
  47567. */
  47568. boundingBoxSize: Vector3;
  47569. /**
  47570. * Instantiates an HDRTexture from the following parameters.
  47571. *
  47572. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47573. * @param scene The scene the texture will be used in
  47574. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47575. * @param noMipmap Forces to not generate the mipmap if true
  47576. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47577. * @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)
  47578. * @param reserved Reserved flag for internal use.
  47579. */
  47580. 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>);
  47581. /**
  47582. * Get the current class name of the texture useful for serialization or dynamic coding.
  47583. * @returns "HDRCubeTexture"
  47584. */
  47585. getClassName(): string;
  47586. /**
  47587. * Occurs when the file is raw .hdr file.
  47588. */
  47589. private loadTexture;
  47590. clone(): HDRCubeTexture;
  47591. delayLoad(): void;
  47592. /**
  47593. * Get the texture reflection matrix used to rotate/transform the reflection.
  47594. * @returns the reflection matrix
  47595. */
  47596. getReflectionTextureMatrix(): Matrix;
  47597. /**
  47598. * Set the texture reflection matrix used to rotate/transform the reflection.
  47599. * @param value Define the reflection matrix to set
  47600. */
  47601. setReflectionTextureMatrix(value: Matrix): void;
  47602. /**
  47603. * Parses a JSON representation of an HDR Texture in order to create the texture
  47604. * @param parsedTexture Define the JSON representation
  47605. * @param scene Define the scene the texture should be created in
  47606. * @param rootUrl Define the root url in case we need to load relative dependencies
  47607. * @returns the newly created texture after parsing
  47608. */
  47609. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47610. serialize(): any;
  47611. }
  47612. }
  47613. declare module "babylonjs/Physics/physicsEngine" {
  47614. import { Nullable } from "babylonjs/types";
  47615. import { Vector3 } from "babylonjs/Maths/math";
  47616. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47617. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47618. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47619. /**
  47620. * Class used to control physics engine
  47621. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47622. */
  47623. export class PhysicsEngine implements IPhysicsEngine {
  47624. private _physicsPlugin;
  47625. /**
  47626. * Global value used to control the smallest number supported by the simulation
  47627. */
  47628. static Epsilon: number;
  47629. private _impostors;
  47630. private _joints;
  47631. /**
  47632. * Gets the gravity vector used by the simulation
  47633. */
  47634. gravity: Vector3;
  47635. /**
  47636. * Factory used to create the default physics plugin.
  47637. * @returns The default physics plugin
  47638. */
  47639. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47640. /**
  47641. * Creates a new Physics Engine
  47642. * @param gravity defines the gravity vector used by the simulation
  47643. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47644. */
  47645. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47646. /**
  47647. * Sets the gravity vector used by the simulation
  47648. * @param gravity defines the gravity vector to use
  47649. */
  47650. setGravity(gravity: Vector3): void;
  47651. /**
  47652. * Set the time step of the physics engine.
  47653. * Default is 1/60.
  47654. * To slow it down, enter 1/600 for example.
  47655. * To speed it up, 1/30
  47656. * @param newTimeStep defines the new timestep to apply to this world.
  47657. */
  47658. setTimeStep(newTimeStep?: number): void;
  47659. /**
  47660. * Get the time step of the physics engine.
  47661. * @returns the current time step
  47662. */
  47663. getTimeStep(): number;
  47664. /**
  47665. * Release all resources
  47666. */
  47667. dispose(): void;
  47668. /**
  47669. * Gets the name of the current physics plugin
  47670. * @returns the name of the plugin
  47671. */
  47672. getPhysicsPluginName(): string;
  47673. /**
  47674. * Adding a new impostor for the impostor tracking.
  47675. * This will be done by the impostor itself.
  47676. * @param impostor the impostor to add
  47677. */
  47678. addImpostor(impostor: PhysicsImpostor): void;
  47679. /**
  47680. * Remove an impostor from the engine.
  47681. * This impostor and its mesh will not longer be updated by the physics engine.
  47682. * @param impostor the impostor to remove
  47683. */
  47684. removeImpostor(impostor: PhysicsImpostor): void;
  47685. /**
  47686. * Add a joint to the physics engine
  47687. * @param mainImpostor defines the main impostor to which the joint is added.
  47688. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47689. * @param joint defines the joint that will connect both impostors.
  47690. */
  47691. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47692. /**
  47693. * Removes a joint from the simulation
  47694. * @param mainImpostor defines the impostor used with the joint
  47695. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47696. * @param joint defines the joint to remove
  47697. */
  47698. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47699. /**
  47700. * Called by the scene. No need to call it.
  47701. * @param delta defines the timespam between frames
  47702. */
  47703. _step(delta: number): void;
  47704. /**
  47705. * Gets the current plugin used to run the simulation
  47706. * @returns current plugin
  47707. */
  47708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47709. /**
  47710. * Gets the list of physic impostors
  47711. * @returns an array of PhysicsImpostor
  47712. */
  47713. getImpostors(): Array<PhysicsImpostor>;
  47714. /**
  47715. * Gets the impostor for a physics enabled object
  47716. * @param object defines the object impersonated by the impostor
  47717. * @returns the PhysicsImpostor or null if not found
  47718. */
  47719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47720. /**
  47721. * Gets the impostor for a physics body object
  47722. * @param body defines physics body used by the impostor
  47723. * @returns the PhysicsImpostor or null if not found
  47724. */
  47725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47726. }
  47727. }
  47728. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47729. import { Nullable } from "babylonjs/types";
  47730. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47732. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47733. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47734. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47735. /** @hidden */
  47736. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47737. private _useDeltaForWorldStep;
  47738. world: any;
  47739. name: string;
  47740. private _physicsMaterials;
  47741. private _fixedTimeStep;
  47742. BJSCANNON: any;
  47743. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47744. setGravity(gravity: Vector3): void;
  47745. setTimeStep(timeStep: number): void;
  47746. getTimeStep(): number;
  47747. executeStep(delta: number): void;
  47748. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47749. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47750. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47751. private _processChildMeshes;
  47752. removePhysicsBody(impostor: PhysicsImpostor): void;
  47753. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47754. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47755. private _addMaterial;
  47756. private _checkWithEpsilon;
  47757. private _createShape;
  47758. private _createHeightmap;
  47759. private _minus90X;
  47760. private _plus90X;
  47761. private _tmpPosition;
  47762. private _tmpDeltaPosition;
  47763. private _tmpUnityRotation;
  47764. private _updatePhysicsBodyTransformation;
  47765. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47766. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47767. isSupported(): boolean;
  47768. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47769. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47770. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47771. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47772. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47773. getBodyMass(impostor: PhysicsImpostor): number;
  47774. getBodyFriction(impostor: PhysicsImpostor): number;
  47775. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47776. getBodyRestitution(impostor: PhysicsImpostor): number;
  47777. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47778. sleepBody(impostor: PhysicsImpostor): void;
  47779. wakeUpBody(impostor: PhysicsImpostor): void;
  47780. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47781. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47783. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47784. getRadius(impostor: PhysicsImpostor): number;
  47785. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47786. dispose(): void;
  47787. private _extendNamespace;
  47788. }
  47789. }
  47790. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47791. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47792. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47793. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47795. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47796. import { Nullable } from "babylonjs/types";
  47797. /** @hidden */
  47798. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47799. world: any;
  47800. name: string;
  47801. BJSOIMO: any;
  47802. constructor(iterations?: number, oimoInjection?: any);
  47803. setGravity(gravity: Vector3): void;
  47804. setTimeStep(timeStep: number): void;
  47805. getTimeStep(): number;
  47806. private _tmpImpostorsArray;
  47807. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47808. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47809. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47810. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47811. private _tmpPositionVector;
  47812. removePhysicsBody(impostor: PhysicsImpostor): void;
  47813. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47814. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47815. isSupported(): boolean;
  47816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47818. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47823. getBodyMass(impostor: PhysicsImpostor): number;
  47824. getBodyFriction(impostor: PhysicsImpostor): number;
  47825. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47826. getBodyRestitution(impostor: PhysicsImpostor): number;
  47827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47828. sleepBody(impostor: PhysicsImpostor): void;
  47829. wakeUpBody(impostor: PhysicsImpostor): void;
  47830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47831. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47833. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47834. getRadius(impostor: PhysicsImpostor): number;
  47835. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47836. dispose(): void;
  47837. }
  47838. }
  47839. declare module "babylonjs/Probes/reflectionProbe" {
  47840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47841. import { Vector3 } from "babylonjs/Maths/math";
  47842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47843. import { Nullable } from "babylonjs/types";
  47844. import { Scene } from "babylonjs/scene";
  47845. module "babylonjs/abstractScene" {
  47846. interface AbstractScene {
  47847. /**
  47848. * The list of reflection probes added to the scene
  47849. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47850. */
  47851. reflectionProbes: Array<ReflectionProbe>;
  47852. /**
  47853. * Removes the given reflection probe from this scene.
  47854. * @param toRemove The reflection probe to remove
  47855. * @returns The index of the removed reflection probe
  47856. */
  47857. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47858. /**
  47859. * Adds the given reflection probe to this scene.
  47860. * @param newReflectionProbe The reflection probe to add
  47861. */
  47862. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47863. }
  47864. }
  47865. /**
  47866. * Class used to generate realtime reflection / refraction cube textures
  47867. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47868. */
  47869. export class ReflectionProbe {
  47870. /** defines the name of the probe */
  47871. name: string;
  47872. private _scene;
  47873. private _renderTargetTexture;
  47874. private _projectionMatrix;
  47875. private _viewMatrix;
  47876. private _target;
  47877. private _add;
  47878. private _attachedMesh;
  47879. private _invertYAxis;
  47880. /** Gets or sets probe position (center of the cube map) */
  47881. position: Vector3;
  47882. /**
  47883. * Creates a new reflection probe
  47884. * @param name defines the name of the probe
  47885. * @param size defines the texture resolution (for each face)
  47886. * @param scene defines the hosting scene
  47887. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47888. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47889. */
  47890. constructor(
  47891. /** defines the name of the probe */
  47892. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47893. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47894. samples: number;
  47895. /** Gets or sets the refresh rate to use (on every frame by default) */
  47896. refreshRate: number;
  47897. /**
  47898. * Gets the hosting scene
  47899. * @returns a Scene
  47900. */
  47901. getScene(): Scene;
  47902. /** Gets the internal CubeTexture used to render to */
  47903. readonly cubeTexture: RenderTargetTexture;
  47904. /** Gets the list of meshes to render */
  47905. readonly renderList: Nullable<AbstractMesh[]>;
  47906. /**
  47907. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47908. * @param mesh defines the mesh to attach to
  47909. */
  47910. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47911. /**
  47912. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47913. * @param renderingGroupId The rendering group id corresponding to its index
  47914. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47915. */
  47916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47917. /**
  47918. * Clean all associated resources
  47919. */
  47920. dispose(): void;
  47921. /**
  47922. * Converts the reflection probe information to a readable string for debug purpose.
  47923. * @param fullDetails Supports for multiple levels of logging within scene loading
  47924. * @returns the human readable reflection probe info
  47925. */
  47926. toString(fullDetails?: boolean): string;
  47927. /**
  47928. * Get the class name of the relfection probe.
  47929. * @returns "ReflectionProbe"
  47930. */
  47931. getClassName(): string;
  47932. /**
  47933. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47934. * @returns The JSON representation of the texture
  47935. */
  47936. serialize(): any;
  47937. /**
  47938. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47939. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47940. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47941. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47942. * @returns The parsed reflection probe if successful
  47943. */
  47944. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47945. }
  47946. }
  47947. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47948. /** @hidden */
  47949. export var _BabylonLoaderRegistered: boolean;
  47950. }
  47951. declare module "babylonjs/Loading/Plugins/index" {
  47952. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47953. }
  47954. declare module "babylonjs/Loading/index" {
  47955. export * from "babylonjs/Loading/loadingScreen";
  47956. export * from "babylonjs/Loading/Plugins/index";
  47957. export * from "babylonjs/Loading/sceneLoader";
  47958. export * from "babylonjs/Loading/sceneLoaderFlags";
  47959. }
  47960. declare module "babylonjs/Materials/Background/index" {
  47961. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47962. }
  47963. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47964. import { Scene } from "babylonjs/scene";
  47965. import { Color3 } from "babylonjs/Maths/math";
  47966. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47968. /**
  47969. * The Physically based simple base material of BJS.
  47970. *
  47971. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47972. * It is used as the base class for both the specGloss and metalRough conventions.
  47973. */
  47974. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47975. /**
  47976. * Number of Simultaneous lights allowed on the material.
  47977. */
  47978. maxSimultaneousLights: number;
  47979. /**
  47980. * If sets to true, disables all the lights affecting the material.
  47981. */
  47982. disableLighting: boolean;
  47983. /**
  47984. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47985. */
  47986. environmentTexture: BaseTexture;
  47987. /**
  47988. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47989. */
  47990. invertNormalMapX: boolean;
  47991. /**
  47992. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47993. */
  47994. invertNormalMapY: boolean;
  47995. /**
  47996. * Normal map used in the model.
  47997. */
  47998. normalTexture: BaseTexture;
  47999. /**
  48000. * Emissivie color used to self-illuminate the model.
  48001. */
  48002. emissiveColor: Color3;
  48003. /**
  48004. * Emissivie texture used to self-illuminate the model.
  48005. */
  48006. emissiveTexture: BaseTexture;
  48007. /**
  48008. * Occlusion Channel Strenght.
  48009. */
  48010. occlusionStrength: number;
  48011. /**
  48012. * Occlusion Texture of the material (adding extra occlusion effects).
  48013. */
  48014. occlusionTexture: BaseTexture;
  48015. /**
  48016. * Defines the alpha limits in alpha test mode.
  48017. */
  48018. alphaCutOff: number;
  48019. /**
  48020. * Gets the current double sided mode.
  48021. */
  48022. /**
  48023. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48024. */
  48025. doubleSided: boolean;
  48026. /**
  48027. * Stores the pre-calculated light information of a mesh in a texture.
  48028. */
  48029. lightmapTexture: BaseTexture;
  48030. /**
  48031. * If true, the light map contains occlusion information instead of lighting info.
  48032. */
  48033. useLightmapAsShadowmap: boolean;
  48034. /**
  48035. * Return the active textures of the material.
  48036. */
  48037. getActiveTextures(): BaseTexture[];
  48038. hasTexture(texture: BaseTexture): boolean;
  48039. /**
  48040. * Instantiates a new PBRMaterial instance.
  48041. *
  48042. * @param name The material name
  48043. * @param scene The scene the material will be use in.
  48044. */
  48045. constructor(name: string, scene: Scene);
  48046. getClassName(): string;
  48047. }
  48048. }
  48049. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48050. import { Scene } from "babylonjs/scene";
  48051. import { Color3 } from "babylonjs/Maths/math";
  48052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48053. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48054. /**
  48055. * The PBR material of BJS following the metal roughness convention.
  48056. *
  48057. * This fits to the PBR convention in the GLTF definition:
  48058. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48059. */
  48060. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48061. /**
  48062. * The base color has two different interpretations depending on the value of metalness.
  48063. * When the material is a metal, the base color is the specific measured reflectance value
  48064. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48065. * of the material.
  48066. */
  48067. baseColor: Color3;
  48068. /**
  48069. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48070. * well as opacity information in the alpha channel.
  48071. */
  48072. baseTexture: BaseTexture;
  48073. /**
  48074. * Specifies the metallic scalar value of the material.
  48075. * Can also be used to scale the metalness values of the metallic texture.
  48076. */
  48077. metallic: number;
  48078. /**
  48079. * Specifies the roughness scalar value of the material.
  48080. * Can also be used to scale the roughness values of the metallic texture.
  48081. */
  48082. roughness: number;
  48083. /**
  48084. * Texture containing both the metallic value in the B channel and the
  48085. * roughness value in the G channel to keep better precision.
  48086. */
  48087. metallicRoughnessTexture: BaseTexture;
  48088. /**
  48089. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48090. *
  48091. * @param name The material name
  48092. * @param scene The scene the material will be use in.
  48093. */
  48094. constructor(name: string, scene: Scene);
  48095. /**
  48096. * Return the currrent class name of the material.
  48097. */
  48098. getClassName(): string;
  48099. /**
  48100. * Return the active textures of the material.
  48101. */
  48102. getActiveTextures(): BaseTexture[];
  48103. /**
  48104. * Checks to see if a texture is used in the material.
  48105. * @param texture - Base texture to use.
  48106. * @returns - Boolean specifying if a texture is used in the material.
  48107. */
  48108. hasTexture(texture: BaseTexture): boolean;
  48109. /**
  48110. * Makes a duplicate of the current material.
  48111. * @param name - name to use for the new material.
  48112. */
  48113. clone(name: string): PBRMetallicRoughnessMaterial;
  48114. /**
  48115. * Serialize the material to a parsable JSON object.
  48116. */
  48117. serialize(): any;
  48118. /**
  48119. * Parses a JSON object correponding to the serialize function.
  48120. */
  48121. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48122. }
  48123. }
  48124. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48125. import { Scene } from "babylonjs/scene";
  48126. import { Color3 } from "babylonjs/Maths/math";
  48127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48128. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48129. /**
  48130. * The PBR material of BJS following the specular glossiness convention.
  48131. *
  48132. * This fits to the PBR convention in the GLTF definition:
  48133. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48134. */
  48135. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48136. /**
  48137. * Specifies the diffuse color of the material.
  48138. */
  48139. diffuseColor: Color3;
  48140. /**
  48141. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48142. * channel.
  48143. */
  48144. diffuseTexture: BaseTexture;
  48145. /**
  48146. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48147. */
  48148. specularColor: Color3;
  48149. /**
  48150. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48151. */
  48152. glossiness: number;
  48153. /**
  48154. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48155. */
  48156. specularGlossinessTexture: BaseTexture;
  48157. /**
  48158. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48159. *
  48160. * @param name The material name
  48161. * @param scene The scene the material will be use in.
  48162. */
  48163. constructor(name: string, scene: Scene);
  48164. /**
  48165. * Return the currrent class name of the material.
  48166. */
  48167. getClassName(): string;
  48168. /**
  48169. * Return the active textures of the material.
  48170. */
  48171. getActiveTextures(): BaseTexture[];
  48172. /**
  48173. * Checks to see if a texture is used in the material.
  48174. * @param texture - Base texture to use.
  48175. * @returns - Boolean specifying if a texture is used in the material.
  48176. */
  48177. hasTexture(texture: BaseTexture): boolean;
  48178. /**
  48179. * Makes a duplicate of the current material.
  48180. * @param name - name to use for the new material.
  48181. */
  48182. clone(name: string): PBRSpecularGlossinessMaterial;
  48183. /**
  48184. * Serialize the material to a parsable JSON object.
  48185. */
  48186. serialize(): any;
  48187. /**
  48188. * Parses a JSON object correponding to the serialize function.
  48189. */
  48190. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48191. }
  48192. }
  48193. declare module "babylonjs/Materials/PBR/index" {
  48194. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48195. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48196. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48197. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48198. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48199. }
  48200. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48201. import { Nullable } from "babylonjs/types";
  48202. import { Scene } from "babylonjs/scene";
  48203. import { Matrix } from "babylonjs/Maths/math";
  48204. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48205. /**
  48206. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48207. * It can help converting any input color in a desired output one. This can then be used to create effects
  48208. * from sepia, black and white to sixties or futuristic rendering...
  48209. *
  48210. * The only supported format is currently 3dl.
  48211. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48212. */
  48213. export class ColorGradingTexture extends BaseTexture {
  48214. /**
  48215. * The current texture matrix. (will always be identity in color grading texture)
  48216. */
  48217. private _textureMatrix;
  48218. /**
  48219. * The texture URL.
  48220. */
  48221. url: string;
  48222. /**
  48223. * Empty line regex stored for GC.
  48224. */
  48225. private static _noneEmptyLineRegex;
  48226. private _engine;
  48227. /**
  48228. * Instantiates a ColorGradingTexture from the following parameters.
  48229. *
  48230. * @param url The location of the color gradind data (currently only supporting 3dl)
  48231. * @param scene The scene the texture will be used in
  48232. */
  48233. constructor(url: string, scene: Scene);
  48234. /**
  48235. * Returns the texture matrix used in most of the material.
  48236. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48237. */
  48238. getTextureMatrix(): Matrix;
  48239. /**
  48240. * Occurs when the file being loaded is a .3dl LUT file.
  48241. */
  48242. private load3dlTexture;
  48243. /**
  48244. * Starts the loading process of the texture.
  48245. */
  48246. private loadTexture;
  48247. /**
  48248. * Clones the color gradind texture.
  48249. */
  48250. clone(): ColorGradingTexture;
  48251. /**
  48252. * Called during delayed load for textures.
  48253. */
  48254. delayLoad(): void;
  48255. /**
  48256. * Parses a color grading texture serialized by Babylon.
  48257. * @param parsedTexture The texture information being parsedTexture
  48258. * @param scene The scene to load the texture in
  48259. * @param rootUrl The root url of the data assets to load
  48260. * @return A color gradind texture
  48261. */
  48262. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48263. /**
  48264. * Serializes the LUT texture to json format.
  48265. */
  48266. serialize(): any;
  48267. }
  48268. }
  48269. declare module "babylonjs/Misc/dds" {
  48270. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48271. import { Engine } from "babylonjs/Engines/engine";
  48272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48273. import { Nullable } from "babylonjs/types";
  48274. import { Scene } from "babylonjs/scene";
  48275. /**
  48276. * Direct draw surface info
  48277. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48278. */
  48279. export interface DDSInfo {
  48280. /**
  48281. * Width of the texture
  48282. */
  48283. width: number;
  48284. /**
  48285. * Width of the texture
  48286. */
  48287. height: number;
  48288. /**
  48289. * Number of Mipmaps for the texture
  48290. * @see https://en.wikipedia.org/wiki/Mipmap
  48291. */
  48292. mipmapCount: number;
  48293. /**
  48294. * If the textures format is a known fourCC format
  48295. * @see https://www.fourcc.org/
  48296. */
  48297. isFourCC: boolean;
  48298. /**
  48299. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48300. */
  48301. isRGB: boolean;
  48302. /**
  48303. * If the texture is a lumincance format
  48304. */
  48305. isLuminance: boolean;
  48306. /**
  48307. * If this is a cube texture
  48308. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48309. */
  48310. isCube: boolean;
  48311. /**
  48312. * If the texture is a compressed format eg. FOURCC_DXT1
  48313. */
  48314. isCompressed: boolean;
  48315. /**
  48316. * The dxgiFormat of the texture
  48317. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48318. */
  48319. dxgiFormat: number;
  48320. /**
  48321. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48322. */
  48323. textureType: number;
  48324. /**
  48325. * Sphericle polynomial created for the dds texture
  48326. */
  48327. sphericalPolynomial?: SphericalPolynomial;
  48328. }
  48329. /**
  48330. * Class used to provide DDS decompression tools
  48331. */
  48332. export class DDSTools {
  48333. /**
  48334. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48335. */
  48336. static StoreLODInAlphaChannel: boolean;
  48337. /**
  48338. * Gets DDS information from an array buffer
  48339. * @param arrayBuffer defines the array buffer to read data from
  48340. * @returns the DDS information
  48341. */
  48342. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48343. private static _FloatView;
  48344. private static _Int32View;
  48345. private static _ToHalfFloat;
  48346. private static _FromHalfFloat;
  48347. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48348. private static _GetHalfFloatRGBAArrayBuffer;
  48349. private static _GetFloatRGBAArrayBuffer;
  48350. private static _GetFloatAsUIntRGBAArrayBuffer;
  48351. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48352. private static _GetRGBAArrayBuffer;
  48353. private static _ExtractLongWordOrder;
  48354. private static _GetRGBArrayBuffer;
  48355. private static _GetLuminanceArrayBuffer;
  48356. /**
  48357. * Uploads DDS Levels to a Babylon Texture
  48358. * @hidden
  48359. */
  48360. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48361. }
  48362. module "babylonjs/Engines/engine" {
  48363. interface Engine {
  48364. /**
  48365. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48366. * @param rootUrl defines the url where the file to load is located
  48367. * @param scene defines the current scene
  48368. * @param lodScale defines scale to apply to the mip map selection
  48369. * @param lodOffset defines offset to apply to the mip map selection
  48370. * @param onLoad defines an optional callback raised when the texture is loaded
  48371. * @param onError defines an optional callback raised if there is an issue to load the texture
  48372. * @param format defines the format of the data
  48373. * @param forcedExtension defines the extension to use to pick the right loader
  48374. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48375. * @returns the cube texture as an InternalTexture
  48376. */
  48377. 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;
  48378. }
  48379. }
  48380. }
  48381. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48382. import { Nullable } from "babylonjs/types";
  48383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48384. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48385. /**
  48386. * Implementation of the DDS Texture Loader.
  48387. * @hidden
  48388. */
  48389. export class _DDSTextureLoader implements IInternalTextureLoader {
  48390. /**
  48391. * Defines wether the loader supports cascade loading the different faces.
  48392. */
  48393. readonly supportCascades: boolean;
  48394. /**
  48395. * This returns if the loader support the current file information.
  48396. * @param extension defines the file extension of the file being loaded
  48397. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48398. * @param fallback defines the fallback internal texture if any
  48399. * @param isBase64 defines whether the texture is encoded as a base64
  48400. * @param isBuffer defines whether the texture data are stored as a buffer
  48401. * @returns true if the loader can load the specified file
  48402. */
  48403. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48404. /**
  48405. * Transform the url before loading if required.
  48406. * @param rootUrl the url of the texture
  48407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48408. * @returns the transformed texture
  48409. */
  48410. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48411. /**
  48412. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48413. * @param rootUrl the url of the texture
  48414. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48415. * @returns the fallback texture
  48416. */
  48417. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48418. /**
  48419. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48420. * @param data contains the texture data
  48421. * @param texture defines the BabylonJS internal texture
  48422. * @param createPolynomials will be true if polynomials have been requested
  48423. * @param onLoad defines the callback to trigger once the texture is ready
  48424. * @param onError defines the callback to trigger in case of error
  48425. */
  48426. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48427. /**
  48428. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48429. * @param data contains the texture data
  48430. * @param texture defines the BabylonJS internal texture
  48431. * @param callback defines the method to call once ready to upload
  48432. */
  48433. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48434. }
  48435. }
  48436. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48437. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48438. /** @hidden */
  48439. export var rgbdEncodePixelShader: {
  48440. name: string;
  48441. shader: string;
  48442. };
  48443. }
  48444. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48446. /** @hidden */
  48447. export var rgbdDecodePixelShader: {
  48448. name: string;
  48449. shader: string;
  48450. };
  48451. }
  48452. declare module "babylonjs/Misc/environmentTextureTools" {
  48453. import { Nullable } from "babylonjs/types";
  48454. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48456. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48457. import "babylonjs/Shaders/rgbdEncode.fragment";
  48458. import "babylonjs/Shaders/rgbdDecode.fragment";
  48459. /**
  48460. * Raw texture data and descriptor sufficient for WebGL texture upload
  48461. */
  48462. export interface EnvironmentTextureInfo {
  48463. /**
  48464. * Version of the environment map
  48465. */
  48466. version: number;
  48467. /**
  48468. * Width of image
  48469. */
  48470. width: number;
  48471. /**
  48472. * Irradiance information stored in the file.
  48473. */
  48474. irradiance: any;
  48475. /**
  48476. * Specular information stored in the file.
  48477. */
  48478. specular: any;
  48479. }
  48480. /**
  48481. * Sets of helpers addressing the serialization and deserialization of environment texture
  48482. * stored in a BabylonJS env file.
  48483. * Those files are usually stored as .env files.
  48484. */
  48485. export class EnvironmentTextureTools {
  48486. /**
  48487. * Magic number identifying the env file.
  48488. */
  48489. private static _MagicBytes;
  48490. /**
  48491. * Gets the environment info from an env file.
  48492. * @param data The array buffer containing the .env bytes.
  48493. * @returns the environment file info (the json header) if successfully parsed.
  48494. */
  48495. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48496. /**
  48497. * Creates an environment texture from a loaded cube texture.
  48498. * @param texture defines the cube texture to convert in env file
  48499. * @return a promise containing the environment data if succesfull.
  48500. */
  48501. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48502. /**
  48503. * Creates a JSON representation of the spherical data.
  48504. * @param texture defines the texture containing the polynomials
  48505. * @return the JSON representation of the spherical info
  48506. */
  48507. private static _CreateEnvTextureIrradiance;
  48508. /**
  48509. * Uploads the texture info contained in the env file to the GPU.
  48510. * @param texture defines the internal texture to upload to
  48511. * @param arrayBuffer defines the buffer cotaining the data to load
  48512. * @param info defines the texture info retrieved through the GetEnvInfo method
  48513. * @returns a promise
  48514. */
  48515. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48516. /**
  48517. * Uploads the levels of image data to the GPU.
  48518. * @param texture defines the internal texture to upload to
  48519. * @param imageData defines the array buffer views of image data [mipmap][face]
  48520. * @returns a promise
  48521. */
  48522. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48523. /**
  48524. * Uploads spherical polynomials information to the texture.
  48525. * @param texture defines the texture we are trying to upload the information to
  48526. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48527. */
  48528. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48529. /** @hidden */
  48530. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48531. }
  48532. }
  48533. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48534. import { Nullable } from "babylonjs/types";
  48535. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48536. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48537. /**
  48538. * Implementation of the ENV Texture Loader.
  48539. * @hidden
  48540. */
  48541. export class _ENVTextureLoader implements IInternalTextureLoader {
  48542. /**
  48543. * Defines wether the loader supports cascade loading the different faces.
  48544. */
  48545. readonly supportCascades: boolean;
  48546. /**
  48547. * This returns if the loader support the current file information.
  48548. * @param extension defines the file extension of the file being loaded
  48549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48550. * @param fallback defines the fallback internal texture if any
  48551. * @param isBase64 defines whether the texture is encoded as a base64
  48552. * @param isBuffer defines whether the texture data are stored as a buffer
  48553. * @returns true if the loader can load the specified file
  48554. */
  48555. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48556. /**
  48557. * Transform the url before loading if required.
  48558. * @param rootUrl the url of the texture
  48559. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48560. * @returns the transformed texture
  48561. */
  48562. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48563. /**
  48564. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48565. * @param rootUrl the url of the texture
  48566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48567. * @returns the fallback texture
  48568. */
  48569. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48570. /**
  48571. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48572. * @param data contains the texture data
  48573. * @param texture defines the BabylonJS internal texture
  48574. * @param createPolynomials will be true if polynomials have been requested
  48575. * @param onLoad defines the callback to trigger once the texture is ready
  48576. * @param onError defines the callback to trigger in case of error
  48577. */
  48578. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48579. /**
  48580. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48581. * @param data contains the texture data
  48582. * @param texture defines the BabylonJS internal texture
  48583. * @param callback defines the method to call once ready to upload
  48584. */
  48585. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48586. }
  48587. }
  48588. declare module "babylonjs/Misc/khronosTextureContainer" {
  48589. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48590. /**
  48591. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48592. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48593. */
  48594. export class KhronosTextureContainer {
  48595. /** contents of the KTX container file */
  48596. arrayBuffer: any;
  48597. private static HEADER_LEN;
  48598. private static COMPRESSED_2D;
  48599. private static COMPRESSED_3D;
  48600. private static TEX_2D;
  48601. private static TEX_3D;
  48602. /**
  48603. * Gets the openGL type
  48604. */
  48605. glType: number;
  48606. /**
  48607. * Gets the openGL type size
  48608. */
  48609. glTypeSize: number;
  48610. /**
  48611. * Gets the openGL format
  48612. */
  48613. glFormat: number;
  48614. /**
  48615. * Gets the openGL internal format
  48616. */
  48617. glInternalFormat: number;
  48618. /**
  48619. * Gets the base internal format
  48620. */
  48621. glBaseInternalFormat: number;
  48622. /**
  48623. * Gets image width in pixel
  48624. */
  48625. pixelWidth: number;
  48626. /**
  48627. * Gets image height in pixel
  48628. */
  48629. pixelHeight: number;
  48630. /**
  48631. * Gets image depth in pixels
  48632. */
  48633. pixelDepth: number;
  48634. /**
  48635. * Gets the number of array elements
  48636. */
  48637. numberOfArrayElements: number;
  48638. /**
  48639. * Gets the number of faces
  48640. */
  48641. numberOfFaces: number;
  48642. /**
  48643. * Gets the number of mipmap levels
  48644. */
  48645. numberOfMipmapLevels: number;
  48646. /**
  48647. * Gets the bytes of key value data
  48648. */
  48649. bytesOfKeyValueData: number;
  48650. /**
  48651. * Gets the load type
  48652. */
  48653. loadType: number;
  48654. /**
  48655. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48656. */
  48657. isInvalid: boolean;
  48658. /**
  48659. * Creates a new KhronosTextureContainer
  48660. * @param arrayBuffer contents of the KTX container file
  48661. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48662. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48663. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48664. */
  48665. constructor(
  48666. /** contents of the KTX container file */
  48667. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48668. /**
  48669. * Uploads KTX content to a Babylon Texture.
  48670. * It is assumed that the texture has already been created & is currently bound
  48671. * @hidden
  48672. */
  48673. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48674. private _upload2DCompressedLevels;
  48675. }
  48676. }
  48677. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48678. import { Nullable } from "babylonjs/types";
  48679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48680. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48681. /**
  48682. * Implementation of the KTX Texture Loader.
  48683. * @hidden
  48684. */
  48685. export class _KTXTextureLoader implements IInternalTextureLoader {
  48686. /**
  48687. * Defines wether the loader supports cascade loading the different faces.
  48688. */
  48689. readonly supportCascades: boolean;
  48690. /**
  48691. * This returns if the loader support the current file information.
  48692. * @param extension defines the file extension of the file being loaded
  48693. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48694. * @param fallback defines the fallback internal texture if any
  48695. * @param isBase64 defines whether the texture is encoded as a base64
  48696. * @param isBuffer defines whether the texture data are stored as a buffer
  48697. * @returns true if the loader can load the specified file
  48698. */
  48699. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48700. /**
  48701. * Transform the url before loading if required.
  48702. * @param rootUrl the url of the texture
  48703. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48704. * @returns the transformed texture
  48705. */
  48706. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48707. /**
  48708. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48709. * @param rootUrl the url of the texture
  48710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48711. * @returns the fallback texture
  48712. */
  48713. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48714. /**
  48715. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48716. * @param data contains the texture data
  48717. * @param texture defines the BabylonJS internal texture
  48718. * @param createPolynomials will be true if polynomials have been requested
  48719. * @param onLoad defines the callback to trigger once the texture is ready
  48720. * @param onError defines the callback to trigger in case of error
  48721. */
  48722. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48723. /**
  48724. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48725. * @param data contains the texture data
  48726. * @param texture defines the BabylonJS internal texture
  48727. * @param callback defines the method to call once ready to upload
  48728. */
  48729. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48730. }
  48731. }
  48732. declare module "babylonjs/Misc/tga" {
  48733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48734. /**
  48735. * Based on jsTGALoader - Javascript loader for TGA file
  48736. * By Vincent Thibault
  48737. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48738. */
  48739. export class TGATools {
  48740. private static _TYPE_INDEXED;
  48741. private static _TYPE_RGB;
  48742. private static _TYPE_GREY;
  48743. private static _TYPE_RLE_INDEXED;
  48744. private static _TYPE_RLE_RGB;
  48745. private static _TYPE_RLE_GREY;
  48746. private static _ORIGIN_MASK;
  48747. private static _ORIGIN_SHIFT;
  48748. private static _ORIGIN_BL;
  48749. private static _ORIGIN_BR;
  48750. private static _ORIGIN_UL;
  48751. private static _ORIGIN_UR;
  48752. /**
  48753. * Gets the header of a TGA file
  48754. * @param data defines the TGA data
  48755. * @returns the header
  48756. */
  48757. static GetTGAHeader(data: Uint8Array): any;
  48758. /**
  48759. * Uploads TGA content to a Babylon Texture
  48760. * @hidden
  48761. */
  48762. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48763. /** @hidden */
  48764. 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;
  48765. /** @hidden */
  48766. 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;
  48767. /** @hidden */
  48768. 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;
  48769. /** @hidden */
  48770. 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;
  48771. /** @hidden */
  48772. 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;
  48773. /** @hidden */
  48774. 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;
  48775. }
  48776. }
  48777. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48778. import { Nullable } from "babylonjs/types";
  48779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48780. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48781. /**
  48782. * Implementation of the TGA Texture Loader.
  48783. * @hidden
  48784. */
  48785. export class _TGATextureLoader implements IInternalTextureLoader {
  48786. /**
  48787. * Defines wether the loader supports cascade loading the different faces.
  48788. */
  48789. readonly supportCascades: boolean;
  48790. /**
  48791. * This returns if the loader support the current file information.
  48792. * @param extension defines the file extension of the file being loaded
  48793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48794. * @param fallback defines the fallback internal texture if any
  48795. * @param isBase64 defines whether the texture is encoded as a base64
  48796. * @param isBuffer defines whether the texture data are stored as a buffer
  48797. * @returns true if the loader can load the specified file
  48798. */
  48799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48800. /**
  48801. * Transform the url before loading if required.
  48802. * @param rootUrl the url of the texture
  48803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48804. * @returns the transformed texture
  48805. */
  48806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48807. /**
  48808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48809. * @param rootUrl the url of the texture
  48810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48811. * @returns the fallback texture
  48812. */
  48813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48814. /**
  48815. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48816. * @param data contains the texture data
  48817. * @param texture defines the BabylonJS internal texture
  48818. * @param createPolynomials will be true if polynomials have been requested
  48819. * @param onLoad defines the callback to trigger once the texture is ready
  48820. * @param onError defines the callback to trigger in case of error
  48821. */
  48822. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48823. /**
  48824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48825. * @param data contains the texture data
  48826. * @param texture defines the BabylonJS internal texture
  48827. * @param callback defines the method to call once ready to upload
  48828. */
  48829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48830. }
  48831. }
  48832. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48833. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48834. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48835. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48836. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48837. }
  48838. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48839. import { Scene } from "babylonjs/scene";
  48840. import { Texture } from "babylonjs/Materials/Textures/texture";
  48841. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48842. /**
  48843. * 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.
  48844. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48845. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48846. */
  48847. export class CustomProceduralTexture extends ProceduralTexture {
  48848. private _animate;
  48849. private _time;
  48850. private _config;
  48851. private _texturePath;
  48852. /**
  48853. * Instantiates a new Custom Procedural Texture.
  48854. * 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.
  48855. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48856. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48857. * @param name Define the name of the texture
  48858. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48859. * @param size Define the size of the texture to create
  48860. * @param scene Define the scene the texture belongs to
  48861. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48862. * @param generateMipMaps Define if the texture should creates mip maps or not
  48863. */
  48864. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48865. private _loadJson;
  48866. /**
  48867. * Is the texture ready to be used ? (rendered at least once)
  48868. * @returns true if ready, otherwise, false.
  48869. */
  48870. isReady(): boolean;
  48871. /**
  48872. * Render the texture to its associated render target.
  48873. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48874. */
  48875. render(useCameraPostProcess?: boolean): void;
  48876. /**
  48877. * Update the list of dependant textures samplers in the shader.
  48878. */
  48879. updateTextures(): void;
  48880. /**
  48881. * Update the uniform values of the procedural texture in the shader.
  48882. */
  48883. updateShaderUniforms(): void;
  48884. /**
  48885. * Define if the texture animates or not.
  48886. */
  48887. animate: boolean;
  48888. }
  48889. }
  48890. declare module "babylonjs/Shaders/noise.fragment" {
  48891. /** @hidden */
  48892. export var noisePixelShader: {
  48893. name: string;
  48894. shader: string;
  48895. };
  48896. }
  48897. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48898. import { Nullable } from "babylonjs/types";
  48899. import { Scene } from "babylonjs/scene";
  48900. import { Texture } from "babylonjs/Materials/Textures/texture";
  48901. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48902. import "babylonjs/Shaders/noise.fragment";
  48903. /**
  48904. * Class used to generate noise procedural textures
  48905. */
  48906. export class NoiseProceduralTexture extends ProceduralTexture {
  48907. private _time;
  48908. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48909. brightness: number;
  48910. /** Defines the number of octaves to process */
  48911. octaves: number;
  48912. /** Defines the level of persistence (0.8 by default) */
  48913. persistence: number;
  48914. /** Gets or sets animation speed factor (default is 1) */
  48915. animationSpeedFactor: number;
  48916. /**
  48917. * Creates a new NoiseProceduralTexture
  48918. * @param name defines the name fo the texture
  48919. * @param size defines the size of the texture (default is 256)
  48920. * @param scene defines the hosting scene
  48921. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48922. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48923. */
  48924. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48925. private _updateShaderUniforms;
  48926. protected _getDefines(): string;
  48927. /** Generate the current state of the procedural texture */
  48928. render(useCameraPostProcess?: boolean): void;
  48929. /**
  48930. * Serializes this noise procedural texture
  48931. * @returns a serialized noise procedural texture object
  48932. */
  48933. serialize(): any;
  48934. /**
  48935. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48936. * @param parsedTexture defines parsed texture data
  48937. * @param scene defines the current scene
  48938. * @param rootUrl defines the root URL containing noise procedural texture information
  48939. * @returns a parsed NoiseProceduralTexture
  48940. */
  48941. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48942. }
  48943. }
  48944. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48945. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48946. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48947. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48948. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48949. }
  48950. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48951. import { Nullable } from "babylonjs/types";
  48952. import { Scene } from "babylonjs/scene";
  48953. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48954. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48955. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48956. /**
  48957. * Raw cube texture where the raw buffers are passed in
  48958. */
  48959. export class RawCubeTexture extends CubeTexture {
  48960. /**
  48961. * Creates a cube texture where the raw buffers are passed in.
  48962. * @param scene defines the scene the texture is attached to
  48963. * @param data defines the array of data to use to create each face
  48964. * @param size defines the size of the textures
  48965. * @param format defines the format of the data
  48966. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48967. * @param generateMipMaps defines if the engine should generate the mip levels
  48968. * @param invertY defines if data must be stored with Y axis inverted
  48969. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48970. * @param compression defines the compression used (null by default)
  48971. */
  48972. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48973. /**
  48974. * Updates the raw cube texture.
  48975. * @param data defines the data to store
  48976. * @param format defines the data format
  48977. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48978. * @param invertY defines if data must be stored with Y axis inverted
  48979. * @param compression defines the compression used (null by default)
  48980. * @param level defines which level of the texture to update
  48981. */
  48982. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48983. /**
  48984. * Updates a raw cube texture with RGBD encoded data.
  48985. * @param data defines the array of data [mipmap][face] to use to create each face
  48986. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48987. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48988. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48989. * @returns a promsie that resolves when the operation is complete
  48990. */
  48991. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48992. /**
  48993. * Clones the raw cube texture.
  48994. * @return a new cube texture
  48995. */
  48996. clone(): CubeTexture;
  48997. /** @hidden */
  48998. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48999. }
  49000. }
  49001. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49002. import { Scene } from "babylonjs/scene";
  49003. import { Texture } from "babylonjs/Materials/Textures/texture";
  49004. /**
  49005. * Class used to store 3D textures containing user data
  49006. */
  49007. export class RawTexture3D extends Texture {
  49008. /** Gets or sets the texture format to use */
  49009. format: number;
  49010. private _engine;
  49011. /**
  49012. * Create a new RawTexture3D
  49013. * @param data defines the data of the texture
  49014. * @param width defines the width of the texture
  49015. * @param height defines the height of the texture
  49016. * @param depth defines the depth of the texture
  49017. * @param format defines the texture format to use
  49018. * @param scene defines the hosting scene
  49019. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49020. * @param invertY defines if texture must be stored with Y axis inverted
  49021. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49022. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49023. */
  49024. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49025. /** Gets or sets the texture format to use */
  49026. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49027. /**
  49028. * Update the texture with new data
  49029. * @param data defines the data to store in the texture
  49030. */
  49031. update(data: ArrayBufferView): void;
  49032. }
  49033. }
  49034. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49035. import { Scene } from "babylonjs/scene";
  49036. import { Plane } from "babylonjs/Maths/math";
  49037. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49038. /**
  49039. * Creates a refraction texture used by refraction channel of the standard material.
  49040. * It is like a mirror but to see through a material.
  49041. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49042. */
  49043. export class RefractionTexture extends RenderTargetTexture {
  49044. /**
  49045. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49046. * 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.
  49047. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49048. */
  49049. refractionPlane: Plane;
  49050. /**
  49051. * Define how deep under the surface we should see.
  49052. */
  49053. depth: number;
  49054. /**
  49055. * Creates a refraction texture used by refraction channel of the standard material.
  49056. * It is like a mirror but to see through a material.
  49057. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49058. * @param name Define the texture name
  49059. * @param size Define the size of the underlying texture
  49060. * @param scene Define the scene the refraction belongs to
  49061. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49062. */
  49063. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49064. /**
  49065. * Clone the refraction texture.
  49066. * @returns the cloned texture
  49067. */
  49068. clone(): RefractionTexture;
  49069. /**
  49070. * Serialize the texture to a JSON representation you could use in Parse later on
  49071. * @returns the serialized JSON representation
  49072. */
  49073. serialize(): any;
  49074. }
  49075. }
  49076. declare module "babylonjs/Materials/Textures/index" {
  49077. export * from "babylonjs/Materials/Textures/baseTexture";
  49078. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49079. export * from "babylonjs/Materials/Textures/cubeTexture";
  49080. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49081. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49082. export * from "babylonjs/Materials/Textures/internalTexture";
  49083. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49084. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49085. export * from "babylonjs/Materials/Textures/Loaders/index";
  49086. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49087. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49088. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49089. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49090. export * from "babylonjs/Materials/Textures/rawTexture";
  49091. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49092. export * from "babylonjs/Materials/Textures/refractionTexture";
  49093. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49094. export * from "babylonjs/Materials/Textures/texture";
  49095. export * from "babylonjs/Materials/Textures/videoTexture";
  49096. }
  49097. declare module "babylonjs/Materials/index" {
  49098. export * from "babylonjs/Materials/Background/index";
  49099. export * from "babylonjs/Materials/colorCurves";
  49100. export * from "babylonjs/Materials/effect";
  49101. export * from "babylonjs/Materials/fresnelParameters";
  49102. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49103. export * from "babylonjs/Materials/material";
  49104. export * from "babylonjs/Materials/materialDefines";
  49105. export * from "babylonjs/Materials/materialHelper";
  49106. export * from "babylonjs/Materials/multiMaterial";
  49107. export * from "babylonjs/Materials/PBR/index";
  49108. export * from "babylonjs/Materials/pushMaterial";
  49109. export * from "babylonjs/Materials/shaderMaterial";
  49110. export * from "babylonjs/Materials/standardMaterial";
  49111. export * from "babylonjs/Materials/Textures/index";
  49112. export * from "babylonjs/Materials/uniformBuffer";
  49113. export * from "babylonjs/Materials/materialFlags";
  49114. }
  49115. declare module "babylonjs/Maths/index" {
  49116. export * from "babylonjs/Maths/math.scalar";
  49117. export * from "babylonjs/Maths/math";
  49118. export * from "babylonjs/Maths/sphericalPolynomial";
  49119. }
  49120. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49121. import { IDisposable } from "babylonjs/scene";
  49122. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49123. /**
  49124. * Configuration for Draco compression
  49125. */
  49126. export interface IDracoCompressionConfiguration {
  49127. /**
  49128. * Configuration for the decoder.
  49129. */
  49130. decoder?: {
  49131. /**
  49132. * The url to the WebAssembly module.
  49133. */
  49134. wasmUrl?: string;
  49135. /**
  49136. * The url to the WebAssembly binary.
  49137. */
  49138. wasmBinaryUrl?: string;
  49139. /**
  49140. * The url to the fallback JavaScript module.
  49141. */
  49142. fallbackUrl?: string;
  49143. };
  49144. }
  49145. /**
  49146. * Draco compression (https://google.github.io/draco/)
  49147. *
  49148. * This class wraps the Draco module.
  49149. *
  49150. * **Encoder**
  49151. *
  49152. * The encoder is not currently implemented.
  49153. *
  49154. * **Decoder**
  49155. *
  49156. * 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.
  49157. *
  49158. * To update the configuration, use the following code:
  49159. * ```javascript
  49160. * DracoCompression.Configuration = {
  49161. * decoder: {
  49162. * wasmUrl: "<url to the WebAssembly library>",
  49163. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49164. * fallbackUrl: "<url to the fallback JavaScript library>",
  49165. * }
  49166. * };
  49167. * ```
  49168. *
  49169. * 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.
  49170. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49171. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49172. *
  49173. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49174. * ```javascript
  49175. * var dracoCompression = new DracoCompression();
  49176. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49177. * [VertexBuffer.PositionKind]: 0
  49178. * });
  49179. * ```
  49180. *
  49181. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49182. */
  49183. export class DracoCompression implements IDisposable {
  49184. private static _DecoderModulePromise;
  49185. /**
  49186. * The configuration. Defaults to the following urls:
  49187. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49188. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49189. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49190. */
  49191. static Configuration: IDracoCompressionConfiguration;
  49192. /**
  49193. * Returns true if the decoder is available.
  49194. */
  49195. static readonly DecoderAvailable: boolean;
  49196. /**
  49197. * Constructor
  49198. */
  49199. constructor();
  49200. /**
  49201. * Stop all async operations and release resources.
  49202. */
  49203. dispose(): void;
  49204. /**
  49205. * Decode Draco compressed mesh data to vertex data.
  49206. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49207. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49208. * @returns A promise that resolves with the decoded vertex data
  49209. */
  49210. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49211. [kind: string]: number;
  49212. }): Promise<VertexData>;
  49213. private static _GetDecoderModule;
  49214. private static _LoadScriptAsync;
  49215. private static _LoadFileAsync;
  49216. }
  49217. }
  49218. declare module "babylonjs/Meshes/Compression/index" {
  49219. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49220. }
  49221. declare module "babylonjs/Meshes/csg" {
  49222. import { Nullable } from "babylonjs/types";
  49223. import { Scene } from "babylonjs/scene";
  49224. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49225. import { Mesh } from "babylonjs/Meshes/mesh";
  49226. import { Material } from "babylonjs/Materials/material";
  49227. /**
  49228. * Class for building Constructive Solid Geometry
  49229. */
  49230. export class CSG {
  49231. private polygons;
  49232. /**
  49233. * The world matrix
  49234. */
  49235. matrix: Matrix;
  49236. /**
  49237. * Stores the position
  49238. */
  49239. position: Vector3;
  49240. /**
  49241. * Stores the rotation
  49242. */
  49243. rotation: Vector3;
  49244. /**
  49245. * Stores the rotation quaternion
  49246. */
  49247. rotationQuaternion: Nullable<Quaternion>;
  49248. /**
  49249. * Stores the scaling vector
  49250. */
  49251. scaling: Vector3;
  49252. /**
  49253. * Convert the Mesh to CSG
  49254. * @param mesh The Mesh to convert to CSG
  49255. * @returns A new CSG from the Mesh
  49256. */
  49257. static FromMesh(mesh: Mesh): CSG;
  49258. /**
  49259. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49260. * @param polygons Polygons used to construct a CSG solid
  49261. */
  49262. private static FromPolygons;
  49263. /**
  49264. * Clones, or makes a deep copy, of the CSG
  49265. * @returns A new CSG
  49266. */
  49267. clone(): CSG;
  49268. /**
  49269. * Unions this CSG with another CSG
  49270. * @param csg The CSG to union against this CSG
  49271. * @returns The unioned CSG
  49272. */
  49273. union(csg: CSG): CSG;
  49274. /**
  49275. * Unions this CSG with another CSG in place
  49276. * @param csg The CSG to union against this CSG
  49277. */
  49278. unionInPlace(csg: CSG): void;
  49279. /**
  49280. * Subtracts this CSG with another CSG
  49281. * @param csg The CSG to subtract against this CSG
  49282. * @returns A new CSG
  49283. */
  49284. subtract(csg: CSG): CSG;
  49285. /**
  49286. * Subtracts this CSG with another CSG in place
  49287. * @param csg The CSG to subtact against this CSG
  49288. */
  49289. subtractInPlace(csg: CSG): void;
  49290. /**
  49291. * Intersect this CSG with another CSG
  49292. * @param csg The CSG to intersect against this CSG
  49293. * @returns A new CSG
  49294. */
  49295. intersect(csg: CSG): CSG;
  49296. /**
  49297. * Intersects this CSG with another CSG in place
  49298. * @param csg The CSG to intersect against this CSG
  49299. */
  49300. intersectInPlace(csg: CSG): void;
  49301. /**
  49302. * Return a new CSG solid with solid and empty space switched. This solid is
  49303. * not modified.
  49304. * @returns A new CSG solid with solid and empty space switched
  49305. */
  49306. inverse(): CSG;
  49307. /**
  49308. * Inverses the CSG in place
  49309. */
  49310. inverseInPlace(): void;
  49311. /**
  49312. * This is used to keep meshes transformations so they can be restored
  49313. * when we build back a Babylon Mesh
  49314. * NB : All CSG operations are performed in world coordinates
  49315. * @param csg The CSG to copy the transform attributes from
  49316. * @returns This CSG
  49317. */
  49318. copyTransformAttributes(csg: CSG): CSG;
  49319. /**
  49320. * Build Raw mesh from CSG
  49321. * Coordinates here are in world space
  49322. * @param name The name of the mesh geometry
  49323. * @param scene The Scene
  49324. * @param keepSubMeshes Specifies if the submeshes should be kept
  49325. * @returns A new Mesh
  49326. */
  49327. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49328. /**
  49329. * Build Mesh from CSG taking material and transforms into account
  49330. * @param name The name of the Mesh
  49331. * @param material The material of the Mesh
  49332. * @param scene The Scene
  49333. * @param keepSubMeshes Specifies if submeshes should be kept
  49334. * @returns The new Mesh
  49335. */
  49336. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49337. }
  49338. }
  49339. declare module "babylonjs/Meshes/meshSimplification" {
  49340. import { Mesh } from "babylonjs/Meshes/mesh";
  49341. /**
  49342. * A simplifier interface for future simplification implementations
  49343. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49344. */
  49345. export interface ISimplifier {
  49346. /**
  49347. * Simplification of a given mesh according to the given settings.
  49348. * Since this requires computation, it is assumed that the function runs async.
  49349. * @param settings The settings of the simplification, including quality and distance
  49350. * @param successCallback A callback that will be called after the mesh was simplified.
  49351. * @param errorCallback in case of an error, this callback will be called. optional.
  49352. */
  49353. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49354. }
  49355. /**
  49356. * Expected simplification settings.
  49357. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49358. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49359. */
  49360. export interface ISimplificationSettings {
  49361. /**
  49362. * Gets or sets the expected quality
  49363. */
  49364. quality: number;
  49365. /**
  49366. * Gets or sets the distance when this optimized version should be used
  49367. */
  49368. distance: number;
  49369. /**
  49370. * Gets an already optimized mesh
  49371. */
  49372. optimizeMesh?: boolean;
  49373. }
  49374. /**
  49375. * Class used to specify simplification options
  49376. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49377. */
  49378. export class SimplificationSettings implements ISimplificationSettings {
  49379. /** expected quality */
  49380. quality: number;
  49381. /** distance when this optimized version should be used */
  49382. distance: number;
  49383. /** already optimized mesh */
  49384. optimizeMesh?: boolean | undefined;
  49385. /**
  49386. * Creates a SimplificationSettings
  49387. * @param quality expected quality
  49388. * @param distance distance when this optimized version should be used
  49389. * @param optimizeMesh already optimized mesh
  49390. */
  49391. constructor(
  49392. /** expected quality */
  49393. quality: number,
  49394. /** distance when this optimized version should be used */
  49395. distance: number,
  49396. /** already optimized mesh */
  49397. optimizeMesh?: boolean | undefined);
  49398. }
  49399. /**
  49400. * Interface used to define a simplification task
  49401. */
  49402. export interface ISimplificationTask {
  49403. /**
  49404. * Array of settings
  49405. */
  49406. settings: Array<ISimplificationSettings>;
  49407. /**
  49408. * Simplification type
  49409. */
  49410. simplificationType: SimplificationType;
  49411. /**
  49412. * Mesh to simplify
  49413. */
  49414. mesh: Mesh;
  49415. /**
  49416. * Callback called on success
  49417. */
  49418. successCallback?: () => void;
  49419. /**
  49420. * Defines if parallel processing can be used
  49421. */
  49422. parallelProcessing: boolean;
  49423. }
  49424. /**
  49425. * Queue used to order the simplification tasks
  49426. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49427. */
  49428. export class SimplificationQueue {
  49429. private _simplificationArray;
  49430. /**
  49431. * Gets a boolean indicating that the process is still running
  49432. */
  49433. running: boolean;
  49434. /**
  49435. * Creates a new queue
  49436. */
  49437. constructor();
  49438. /**
  49439. * Adds a new simplification task
  49440. * @param task defines a task to add
  49441. */
  49442. addTask(task: ISimplificationTask): void;
  49443. /**
  49444. * Execute next task
  49445. */
  49446. executeNext(): void;
  49447. /**
  49448. * Execute a simplification task
  49449. * @param task defines the task to run
  49450. */
  49451. runSimplification(task: ISimplificationTask): void;
  49452. private getSimplifier;
  49453. }
  49454. /**
  49455. * The implemented types of simplification
  49456. * At the moment only Quadratic Error Decimation is implemented
  49457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49458. */
  49459. export enum SimplificationType {
  49460. /** Quadratic error decimation */
  49461. QUADRATIC = 0
  49462. }
  49463. }
  49464. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49465. import { Scene } from "babylonjs/scene";
  49466. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49467. import { ISceneComponent } from "babylonjs/sceneComponent";
  49468. module "babylonjs/scene" {
  49469. interface Scene {
  49470. /** @hidden (Backing field) */
  49471. _simplificationQueue: SimplificationQueue;
  49472. /**
  49473. * Gets or sets the simplification queue attached to the scene
  49474. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49475. */
  49476. simplificationQueue: SimplificationQueue;
  49477. }
  49478. }
  49479. module "babylonjs/Meshes/mesh" {
  49480. interface Mesh {
  49481. /**
  49482. * Simplify the mesh according to the given array of settings.
  49483. * Function will return immediately and will simplify async
  49484. * @param settings a collection of simplification settings
  49485. * @param parallelProcessing should all levels calculate parallel or one after the other
  49486. * @param simplificationType the type of simplification to run
  49487. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49488. * @returns the current mesh
  49489. */
  49490. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49491. }
  49492. }
  49493. /**
  49494. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49495. * created in a scene
  49496. */
  49497. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49498. /**
  49499. * The component name helpfull to identify the component in the list of scene components.
  49500. */
  49501. readonly name: string;
  49502. /**
  49503. * The scene the component belongs to.
  49504. */
  49505. scene: Scene;
  49506. /**
  49507. * Creates a new instance of the component for the given scene
  49508. * @param scene Defines the scene to register the component in
  49509. */
  49510. constructor(scene: Scene);
  49511. /**
  49512. * Registers the component in a given scene
  49513. */
  49514. register(): void;
  49515. /**
  49516. * Rebuilds the elements related to this component in case of
  49517. * context lost for instance.
  49518. */
  49519. rebuild(): void;
  49520. /**
  49521. * Disposes the component and the associated ressources
  49522. */
  49523. dispose(): void;
  49524. private _beforeCameraUpdate;
  49525. }
  49526. }
  49527. declare module "babylonjs/Meshes/index" {
  49528. export * from "babylonjs/Meshes/abstractMesh";
  49529. export * from "babylonjs/Meshes/buffer";
  49530. export * from "babylonjs/Meshes/Compression/index";
  49531. export * from "babylonjs/Meshes/csg";
  49532. export * from "babylonjs/Meshes/geometry";
  49533. export * from "babylonjs/Meshes/groundMesh";
  49534. export * from "babylonjs/Meshes/instancedMesh";
  49535. export * from "babylonjs/Meshes/linesMesh";
  49536. export * from "babylonjs/Meshes/mesh";
  49537. export * from "babylonjs/Meshes/mesh.vertexData";
  49538. export * from "babylonjs/Meshes/meshBuilder";
  49539. export * from "babylonjs/Meshes/meshSimplification";
  49540. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  49541. export * from "babylonjs/Meshes/polygonMesh";
  49542. export * from "babylonjs/Meshes/subMesh";
  49543. export * from "babylonjs/Meshes/transformNode";
  49544. }
  49545. declare module "babylonjs/Morph/index" {
  49546. export * from "babylonjs/Morph/morphTarget";
  49547. export * from "babylonjs/Morph/morphTargetManager";
  49548. }
  49549. declare module "babylonjs/Offline/database" {
  49550. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  49551. /**
  49552. * Class used to enable access to IndexedDB
  49553. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49554. */
  49555. export class Database implements IOfflineProvider {
  49556. private _callbackManifestChecked;
  49557. private _currentSceneUrl;
  49558. private _db;
  49559. private _enableSceneOffline;
  49560. private _enableTexturesOffline;
  49561. private _manifestVersionFound;
  49562. private _mustUpdateRessources;
  49563. private _hasReachedQuota;
  49564. private _isSupported;
  49565. private _idbFactory;
  49566. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49567. private static IsUASupportingBlobStorage;
  49568. /**
  49569. * Gets a boolean indicating if Database storate is enabled (off by default)
  49570. */
  49571. static IDBStorageEnabled: boolean;
  49572. /**
  49573. * Gets a boolean indicating if scene must be saved in the database
  49574. */
  49575. readonly enableSceneOffline: boolean;
  49576. /**
  49577. * Gets a boolean indicating if textures must be saved in the database
  49578. */
  49579. readonly enableTexturesOffline: boolean;
  49580. /**
  49581. * Creates a new Database
  49582. * @param urlToScene defines the url to load the scene
  49583. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49584. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49585. */
  49586. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49587. private static _ParseURL;
  49588. private static _ReturnFullUrlLocation;
  49589. private _checkManifestFile;
  49590. /**
  49591. * Open the database and make it available
  49592. * @param successCallback defines the callback to call on success
  49593. * @param errorCallback defines the callback to call on error
  49594. */
  49595. open(successCallback: () => void, errorCallback: () => void): void;
  49596. /**
  49597. * Loads an image from the database
  49598. * @param url defines the url to load from
  49599. * @param image defines the target DOM image
  49600. */
  49601. loadImage(url: string, image: HTMLImageElement): void;
  49602. private _loadImageFromDBAsync;
  49603. private _saveImageIntoDBAsync;
  49604. private _checkVersionFromDB;
  49605. private _loadVersionFromDBAsync;
  49606. private _saveVersionIntoDBAsync;
  49607. /**
  49608. * Loads a file from database
  49609. * @param url defines the URL to load from
  49610. * @param sceneLoaded defines a callback to call on success
  49611. * @param progressCallBack defines a callback to call when progress changed
  49612. * @param errorCallback defines a callback to call on error
  49613. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49614. */
  49615. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49616. private _loadFileAsync;
  49617. private _saveFileAsync;
  49618. /**
  49619. * Validates if xhr data is correct
  49620. * @param xhr defines the request to validate
  49621. * @param dataType defines the expected data type
  49622. * @returns true if data is correct
  49623. */
  49624. private static _ValidateXHRData;
  49625. }
  49626. }
  49627. declare module "babylonjs/Offline/index" {
  49628. export * from "babylonjs/Offline/database";
  49629. export * from "babylonjs/Offline/IOfflineProvider";
  49630. }
  49631. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  49632. /** @hidden */
  49633. export var gpuUpdateParticlesPixelShader: {
  49634. name: string;
  49635. shader: string;
  49636. };
  49637. }
  49638. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  49639. /** @hidden */
  49640. export var gpuUpdateParticlesVertexShader: {
  49641. name: string;
  49642. shader: string;
  49643. };
  49644. }
  49645. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  49646. /** @hidden */
  49647. export var clipPlaneFragmentDeclaration2: {
  49648. name: string;
  49649. shader: string;
  49650. };
  49651. }
  49652. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  49653. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  49654. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49655. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49656. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49658. /** @hidden */
  49659. export var gpuRenderParticlesPixelShader: {
  49660. name: string;
  49661. shader: string;
  49662. };
  49663. }
  49664. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  49665. /** @hidden */
  49666. export var clipPlaneVertexDeclaration2: {
  49667. name: string;
  49668. shader: string;
  49669. };
  49670. }
  49671. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  49672. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  49673. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49674. /** @hidden */
  49675. export var gpuRenderParticlesVertexShader: {
  49676. name: string;
  49677. shader: string;
  49678. };
  49679. }
  49680. declare module "babylonjs/Particles/gpuParticleSystem" {
  49681. import { Nullable } from "babylonjs/types";
  49682. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  49683. import { Observable } from "babylonjs/Misc/observable";
  49684. import { Color4, Color3 } from "babylonjs/Maths/math";
  49685. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49686. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  49687. import { Scene, IDisposable } from "babylonjs/scene";
  49688. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  49689. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  49690. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  49691. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  49692. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  49693. /**
  49694. * This represents a GPU particle system in Babylon
  49695. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49696. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49697. */
  49698. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49699. /**
  49700. * The layer mask we are rendering the particles through.
  49701. */
  49702. layerMask: number;
  49703. private _capacity;
  49704. private _activeCount;
  49705. private _currentActiveCount;
  49706. private _accumulatedCount;
  49707. private _renderEffect;
  49708. private _updateEffect;
  49709. private _buffer0;
  49710. private _buffer1;
  49711. private _spriteBuffer;
  49712. private _updateVAO;
  49713. private _renderVAO;
  49714. private _targetIndex;
  49715. private _sourceBuffer;
  49716. private _targetBuffer;
  49717. private _engine;
  49718. private _currentRenderId;
  49719. private _started;
  49720. private _stopped;
  49721. private _timeDelta;
  49722. private _randomTexture;
  49723. private _randomTexture2;
  49724. private _attributesStrideSize;
  49725. private _updateEffectOptions;
  49726. private _randomTextureSize;
  49727. private _actualFrame;
  49728. private readonly _rawTextureWidth;
  49729. /**
  49730. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49731. */
  49732. static readonly IsSupported: boolean;
  49733. /**
  49734. * An event triggered when the system is disposed.
  49735. */
  49736. onDisposeObservable: Observable<GPUParticleSystem>;
  49737. /**
  49738. * Gets the maximum number of particles active at the same time.
  49739. * @returns The max number of active particles.
  49740. */
  49741. getCapacity(): number;
  49742. /**
  49743. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49744. * to override the particles.
  49745. */
  49746. forceDepthWrite: boolean;
  49747. /**
  49748. * Gets or set the number of active particles
  49749. */
  49750. activeParticleCount: number;
  49751. private _preWarmDone;
  49752. /**
  49753. * Is this system ready to be used/rendered
  49754. * @return true if the system is ready
  49755. */
  49756. isReady(): boolean;
  49757. /**
  49758. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49759. * @returns True if it has been started, otherwise false.
  49760. */
  49761. isStarted(): boolean;
  49762. /**
  49763. * Starts the particle system and begins to emit
  49764. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49765. */
  49766. start(delay?: number): void;
  49767. /**
  49768. * Stops the particle system.
  49769. */
  49770. stop(): void;
  49771. /**
  49772. * Remove all active particles
  49773. */
  49774. reset(): void;
  49775. /**
  49776. * Returns the string "GPUParticleSystem"
  49777. * @returns a string containing the class name
  49778. */
  49779. getClassName(): string;
  49780. private _colorGradientsTexture;
  49781. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49782. /**
  49783. * Adds a new color gradient
  49784. * @param gradient defines the gradient to use (between 0 and 1)
  49785. * @param color1 defines the color to affect to the specified gradient
  49786. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49787. * @returns the current particle system
  49788. */
  49789. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49790. /**
  49791. * Remove a specific color gradient
  49792. * @param gradient defines the gradient to remove
  49793. * @returns the current particle system
  49794. */
  49795. removeColorGradient(gradient: number): GPUParticleSystem;
  49796. private _angularSpeedGradientsTexture;
  49797. private _sizeGradientsTexture;
  49798. private _velocityGradientsTexture;
  49799. private _limitVelocityGradientsTexture;
  49800. private _dragGradientsTexture;
  49801. private _addFactorGradient;
  49802. /**
  49803. * Adds a new size gradient
  49804. * @param gradient defines the gradient to use (between 0 and 1)
  49805. * @param factor defines the size factor to affect to the specified gradient
  49806. * @returns the current particle system
  49807. */
  49808. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49809. /**
  49810. * Remove a specific size gradient
  49811. * @param gradient defines the gradient to remove
  49812. * @returns the current particle system
  49813. */
  49814. removeSizeGradient(gradient: number): GPUParticleSystem;
  49815. /**
  49816. * Adds a new angular speed gradient
  49817. * @param gradient defines the gradient to use (between 0 and 1)
  49818. * @param factor defines the angular speed to affect to the specified gradient
  49819. * @returns the current particle system
  49820. */
  49821. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49822. /**
  49823. * Remove a specific angular speed gradient
  49824. * @param gradient defines the gradient to remove
  49825. * @returns the current particle system
  49826. */
  49827. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49828. /**
  49829. * Adds a new velocity gradient
  49830. * @param gradient defines the gradient to use (between 0 and 1)
  49831. * @param factor defines the velocity to affect to the specified gradient
  49832. * @returns the current particle system
  49833. */
  49834. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49835. /**
  49836. * Remove a specific velocity gradient
  49837. * @param gradient defines the gradient to remove
  49838. * @returns the current particle system
  49839. */
  49840. removeVelocityGradient(gradient: number): GPUParticleSystem;
  49841. /**
  49842. * Adds a new limit velocity gradient
  49843. * @param gradient defines the gradient to use (between 0 and 1)
  49844. * @param factor defines the limit velocity value to affect to the specified gradient
  49845. * @returns the current particle system
  49846. */
  49847. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49848. /**
  49849. * Remove a specific limit velocity gradient
  49850. * @param gradient defines the gradient to remove
  49851. * @returns the current particle system
  49852. */
  49853. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  49854. /**
  49855. * Adds a new drag gradient
  49856. * @param gradient defines the gradient to use (between 0 and 1)
  49857. * @param factor defines the drag value to affect to the specified gradient
  49858. * @returns the current particle system
  49859. */
  49860. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  49861. /**
  49862. * Remove a specific drag gradient
  49863. * @param gradient defines the gradient to remove
  49864. * @returns the current particle system
  49865. */
  49866. removeDragGradient(gradient: number): GPUParticleSystem;
  49867. /**
  49868. * Not supported by GPUParticleSystem
  49869. * @param gradient defines the gradient to use (between 0 and 1)
  49870. * @param factor defines the emit rate value to affect to the specified gradient
  49871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49872. * @returns the current particle system
  49873. */
  49874. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49875. /**
  49876. * Not supported by GPUParticleSystem
  49877. * @param gradient defines the gradient to remove
  49878. * @returns the current particle system
  49879. */
  49880. removeEmitRateGradient(gradient: number): IParticleSystem;
  49881. /**
  49882. * Not supported by GPUParticleSystem
  49883. * @param gradient defines the gradient to use (between 0 and 1)
  49884. * @param factor defines the start size value to affect to the specified gradient
  49885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49886. * @returns the current particle system
  49887. */
  49888. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49889. /**
  49890. * Not supported by GPUParticleSystem
  49891. * @param gradient defines the gradient to remove
  49892. * @returns the current particle system
  49893. */
  49894. removeStartSizeGradient(gradient: number): IParticleSystem;
  49895. /**
  49896. * Not supported by GPUParticleSystem
  49897. * @param gradient defines the gradient to use (between 0 and 1)
  49898. * @param min defines the color remap minimal range
  49899. * @param max defines the color remap maximal range
  49900. * @returns the current particle system
  49901. */
  49902. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49903. /**
  49904. * Not supported by GPUParticleSystem
  49905. * @param gradient defines the gradient to remove
  49906. * @returns the current particle system
  49907. */
  49908. removeColorRemapGradient(): IParticleSystem;
  49909. /**
  49910. * Not supported by GPUParticleSystem
  49911. * @param gradient defines the gradient to use (between 0 and 1)
  49912. * @param min defines the alpha remap minimal range
  49913. * @param max defines the alpha remap maximal range
  49914. * @returns the current particle system
  49915. */
  49916. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49917. /**
  49918. * Not supported by GPUParticleSystem
  49919. * @param gradient defines the gradient to remove
  49920. * @returns the current particle system
  49921. */
  49922. removeAlphaRemapGradient(): IParticleSystem;
  49923. /**
  49924. * Not supported by GPUParticleSystem
  49925. * @param gradient defines the gradient to use (between 0 and 1)
  49926. * @param color defines the color to affect to the specified gradient
  49927. * @returns the current particle system
  49928. */
  49929. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  49930. /**
  49931. * Not supported by GPUParticleSystem
  49932. * @param gradient defines the gradient to remove
  49933. * @returns the current particle system
  49934. */
  49935. removeRampGradient(): IParticleSystem;
  49936. /**
  49937. * Not supported by GPUParticleSystem
  49938. * @returns the list of ramp gradients
  49939. */
  49940. getRampGradients(): Nullable<Array<Color3Gradient>>;
  49941. /**
  49942. * Not supported by GPUParticleSystem
  49943. * Gets or sets a boolean indicating that ramp gradients must be used
  49944. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  49945. */
  49946. useRampGradients: boolean;
  49947. /**
  49948. * Not supported by GPUParticleSystem
  49949. * @param gradient defines the gradient to use (between 0 and 1)
  49950. * @param factor defines the life time factor to affect to the specified gradient
  49951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49952. * @returns the current particle system
  49953. */
  49954. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49955. /**
  49956. * Not supported by GPUParticleSystem
  49957. * @param gradient defines the gradient to remove
  49958. * @returns the current particle system
  49959. */
  49960. removeLifeTimeGradient(gradient: number): IParticleSystem;
  49961. /**
  49962. * Instantiates a GPU particle system.
  49963. * 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.
  49964. * @param name The name of the particle system
  49965. * @param options The options used to create the system
  49966. * @param scene The scene the particle system belongs to
  49967. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  49968. */
  49969. constructor(name: string, options: Partial<{
  49970. capacity: number;
  49971. randomTextureSize: number;
  49972. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  49973. protected _reset(): void;
  49974. private _createUpdateVAO;
  49975. private _createRenderVAO;
  49976. private _initialize;
  49977. /** @hidden */
  49978. _recreateUpdateEffect(): void;
  49979. /** @hidden */
  49980. _recreateRenderEffect(): void;
  49981. /**
  49982. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  49983. * @param preWarm defines if we are in the pre-warmimg phase
  49984. */
  49985. animate(preWarm?: boolean): void;
  49986. private _createFactorGradientTexture;
  49987. private _createSizeGradientTexture;
  49988. private _createAngularSpeedGradientTexture;
  49989. private _createVelocityGradientTexture;
  49990. private _createLimitVelocityGradientTexture;
  49991. private _createDragGradientTexture;
  49992. private _createColorGradientTexture;
  49993. /**
  49994. * Renders the particle system in its current state
  49995. * @param preWarm defines if the system should only update the particles but not render them
  49996. * @returns the current number of particles
  49997. */
  49998. render(preWarm?: boolean): number;
  49999. /**
  50000. * Rebuilds the particle system
  50001. */
  50002. rebuild(): void;
  50003. private _releaseBuffers;
  50004. private _releaseVAOs;
  50005. /**
  50006. * Disposes the particle system and free the associated resources
  50007. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50008. */
  50009. dispose(disposeTexture?: boolean): void;
  50010. /**
  50011. * Clones the particle system.
  50012. * @param name The name of the cloned object
  50013. * @param newEmitter The new emitter to use
  50014. * @returns the cloned particle system
  50015. */
  50016. clone(name: string, newEmitter: any): GPUParticleSystem;
  50017. /**
  50018. * Serializes the particle system to a JSON object.
  50019. * @returns the JSON object
  50020. */
  50021. serialize(): any;
  50022. /**
  50023. * Parses a JSON object to create a GPU particle system.
  50024. * @param parsedParticleSystem The JSON object to parse
  50025. * @param scene The scene to create the particle system in
  50026. * @param rootUrl The root url to use to load external dependencies like texture
  50027. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50028. * @returns the parsed GPU particle system
  50029. */
  50030. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50031. }
  50032. }
  50033. declare module "babylonjs/Particles/particleSystemSet" {
  50034. import { Nullable } from "babylonjs/types";
  50035. import { Color3 } from "babylonjs/Maths/math";
  50036. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50038. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50039. import { Scene, IDisposable } from "babylonjs/scene";
  50040. /**
  50041. * Represents a set of particle systems working together to create a specific effect
  50042. */
  50043. export class ParticleSystemSet implements IDisposable {
  50044. private _emitterCreationOptions;
  50045. private _emitterNode;
  50046. /**
  50047. * Gets the particle system list
  50048. */
  50049. systems: IParticleSystem[];
  50050. /**
  50051. * Gets the emitter node used with this set
  50052. */
  50053. readonly emitterNode: Nullable<TransformNode>;
  50054. /**
  50055. * Creates a new emitter mesh as a sphere
  50056. * @param options defines the options used to create the sphere
  50057. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50058. * @param scene defines the hosting scene
  50059. */
  50060. setEmitterAsSphere(options: {
  50061. diameter: number;
  50062. segments: number;
  50063. color: Color3;
  50064. }, renderingGroupId: number, scene: Scene): void;
  50065. /**
  50066. * Starts all particle systems of the set
  50067. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50068. */
  50069. start(emitter?: AbstractMesh): void;
  50070. /**
  50071. * Release all associated resources
  50072. */
  50073. dispose(): void;
  50074. /**
  50075. * Serialize the set into a JSON compatible object
  50076. * @returns a JSON compatible representation of the set
  50077. */
  50078. serialize(): any;
  50079. /**
  50080. * Parse a new ParticleSystemSet from a serialized source
  50081. * @param data defines a JSON compatible representation of the set
  50082. * @param scene defines the hosting scene
  50083. * @param gpu defines if we want GPU particles or CPU particles
  50084. * @returns a new ParticleSystemSet
  50085. */
  50086. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50087. }
  50088. }
  50089. declare module "babylonjs/Particles/particleHelper" {
  50090. import { Nullable } from "babylonjs/types";
  50091. import { Scene } from "babylonjs/scene";
  50092. import { Vector3 } from "babylonjs/Maths/math";
  50093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50094. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50095. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50096. /**
  50097. * This class is made for on one-liner static method to help creating particle system set.
  50098. */
  50099. export class ParticleHelper {
  50100. /**
  50101. * Gets or sets base Assets URL
  50102. */
  50103. static BaseAssetsUrl: string;
  50104. /**
  50105. * Create a default particle system that you can tweak
  50106. * @param emitter defines the emitter to use
  50107. * @param capacity defines the system capacity (default is 500 particles)
  50108. * @param scene defines the hosting scene
  50109. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50110. * @returns the new Particle system
  50111. */
  50112. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50113. /**
  50114. * This is the main static method (one-liner) of this helper to create different particle systems
  50115. * @param type This string represents the type to the particle system to create
  50116. * @param scene The scene where the particle system should live
  50117. * @param gpu If the system will use gpu
  50118. * @returns the ParticleSystemSet created
  50119. */
  50120. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50121. /**
  50122. * Static function used to export a particle system to a ParticleSystemSet variable.
  50123. * Please note that the emitter shape is not exported
  50124. * @param systems defines the particle systems to export
  50125. * @returns the created particle system set
  50126. */
  50127. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50128. }
  50129. }
  50130. declare module "babylonjs/Particles/particleSystemComponent" {
  50131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50132. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50133. import "babylonjs/Shaders/particles.vertex";
  50134. module "babylonjs/Engines/engine" {
  50135. interface Engine {
  50136. /**
  50137. * Create an effect to use with particle systems.
  50138. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50139. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50140. * @param uniformsNames defines a list of attribute names
  50141. * @param samplers defines an array of string used to represent textures
  50142. * @param defines defines the string containing the defines to use to compile the shaders
  50143. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50144. * @param onCompiled defines a function to call when the effect creation is successful
  50145. * @param onError defines a function to call when the effect creation has failed
  50146. * @returns the new Effect
  50147. */
  50148. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50149. }
  50150. }
  50151. module "babylonjs/Meshes/mesh" {
  50152. interface Mesh {
  50153. /**
  50154. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50155. * @returns an array of IParticleSystem
  50156. */
  50157. getEmittedParticleSystems(): IParticleSystem[];
  50158. /**
  50159. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50160. * @returns an array of IParticleSystem
  50161. */
  50162. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50163. }
  50164. }
  50165. /**
  50166. * @hidden
  50167. */
  50168. export var _IDoNeedToBeInTheBuild: number;
  50169. }
  50170. declare module "babylonjs/Particles/index" {
  50171. export * from "babylonjs/Particles/baseParticleSystem";
  50172. export * from "babylonjs/Particles/EmitterTypes/index";
  50173. export * from "babylonjs/Particles/gpuParticleSystem";
  50174. export * from "babylonjs/Particles/IParticleSystem";
  50175. export * from "babylonjs/Particles/particle";
  50176. export * from "babylonjs/Particles/particleHelper";
  50177. export * from "babylonjs/Particles/particleSystem";
  50178. export * from "babylonjs/Particles/particleSystemComponent";
  50179. export * from "babylonjs/Particles/particleSystemSet";
  50180. export * from "babylonjs/Particles/solidParticle";
  50181. export * from "babylonjs/Particles/solidParticleSystem";
  50182. export * from "babylonjs/Particles/subEmitter";
  50183. }
  50184. declare module "babylonjs/Physics/physicsEngineComponent" {
  50185. import { Nullable } from "babylonjs/types";
  50186. import { Observable, Observer } from "babylonjs/Misc/observable";
  50187. import { Vector3 } from "babylonjs/Maths/math";
  50188. import { Mesh } from "babylonjs/Meshes/mesh";
  50189. import { ISceneComponent } from "babylonjs/sceneComponent";
  50190. import { Scene } from "babylonjs/scene";
  50191. import { Node } from "babylonjs/node";
  50192. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50193. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50194. module "babylonjs/scene" {
  50195. interface Scene {
  50196. /** @hidden (Backing field) */
  50197. _physicsEngine: Nullable<IPhysicsEngine>;
  50198. /**
  50199. * Gets the current physics engine
  50200. * @returns a IPhysicsEngine or null if none attached
  50201. */
  50202. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50203. /**
  50204. * Enables physics to the current scene
  50205. * @param gravity defines the scene's gravity for the physics engine
  50206. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50207. * @return a boolean indicating if the physics engine was initialized
  50208. */
  50209. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50210. /**
  50211. * Disables and disposes the physics engine associated with the scene
  50212. */
  50213. disablePhysicsEngine(): void;
  50214. /**
  50215. * Gets a boolean indicating if there is an active physics engine
  50216. * @returns a boolean indicating if there is an active physics engine
  50217. */
  50218. isPhysicsEnabled(): boolean;
  50219. /**
  50220. * Deletes a physics compound impostor
  50221. * @param compound defines the compound to delete
  50222. */
  50223. deleteCompoundImpostor(compound: any): void;
  50224. /**
  50225. * An event triggered when physic simulation is about to be run
  50226. */
  50227. onBeforePhysicsObservable: Observable<Scene>;
  50228. /**
  50229. * An event triggered when physic simulation has been done
  50230. */
  50231. onAfterPhysicsObservable: Observable<Scene>;
  50232. }
  50233. }
  50234. module "babylonjs/Meshes/abstractMesh" {
  50235. interface AbstractMesh {
  50236. /** @hidden */
  50237. _physicsImpostor: Nullable<PhysicsImpostor>;
  50238. /**
  50239. * Gets or sets impostor used for physic simulation
  50240. * @see http://doc.babylonjs.com/features/physics_engine
  50241. */
  50242. physicsImpostor: Nullable<PhysicsImpostor>;
  50243. /**
  50244. * Gets the current physics impostor
  50245. * @see http://doc.babylonjs.com/features/physics_engine
  50246. * @returns a physics impostor or null
  50247. */
  50248. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50249. /** Apply a physic impulse to the mesh
  50250. * @param force defines the force to apply
  50251. * @param contactPoint defines where to apply the force
  50252. * @returns the current mesh
  50253. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50254. */
  50255. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50256. /**
  50257. * Creates a physic joint between two meshes
  50258. * @param otherMesh defines the other mesh to use
  50259. * @param pivot1 defines the pivot to use on this mesh
  50260. * @param pivot2 defines the pivot to use on the other mesh
  50261. * @param options defines additional options (can be plugin dependent)
  50262. * @returns the current mesh
  50263. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50264. */
  50265. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50266. /** @hidden */
  50267. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50268. }
  50269. }
  50270. /**
  50271. * Defines the physics engine scene component responsible to manage a physics engine
  50272. */
  50273. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50274. /**
  50275. * The component name helpful to identify the component in the list of scene components.
  50276. */
  50277. readonly name: string;
  50278. /**
  50279. * The scene the component belongs to.
  50280. */
  50281. scene: Scene;
  50282. /**
  50283. * Creates a new instance of the component for the given scene
  50284. * @param scene Defines the scene to register the component in
  50285. */
  50286. constructor(scene: Scene);
  50287. /**
  50288. * Registers the component in a given scene
  50289. */
  50290. register(): void;
  50291. /**
  50292. * Rebuilds the elements related to this component in case of
  50293. * context lost for instance.
  50294. */
  50295. rebuild(): void;
  50296. /**
  50297. * Disposes the component and the associated ressources
  50298. */
  50299. dispose(): void;
  50300. }
  50301. }
  50302. declare module "babylonjs/Physics/physicsHelper" {
  50303. import { Nullable } from "babylonjs/types";
  50304. import { Vector3 } from "babylonjs/Maths/math";
  50305. import { Mesh } from "babylonjs/Meshes/mesh";
  50306. import { Ray } from "babylonjs/Culling/ray";
  50307. import { Scene } from "babylonjs/scene";
  50308. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50309. /**
  50310. * A helper for physics simulations
  50311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50312. */
  50313. export class PhysicsHelper {
  50314. private _scene;
  50315. private _physicsEngine;
  50316. /**
  50317. * Initializes the Physics helper
  50318. * @param scene Babylon.js scene
  50319. */
  50320. constructor(scene: Scene);
  50321. /**
  50322. * Applies a radial explosion impulse
  50323. * @param origin the origin of the explosion
  50324. * @param radius the explosion radius
  50325. * @param strength the explosion strength
  50326. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50327. * @returns A physics radial explosion event, or null
  50328. */
  50329. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50330. /**
  50331. * Applies a radial explosion force
  50332. * @param origin the origin of the explosion
  50333. * @param radius the explosion radius
  50334. * @param strength the explosion strength
  50335. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50336. * @returns A physics radial explosion event, or null
  50337. */
  50338. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50339. /**
  50340. * Creates a gravitational field
  50341. * @param origin the origin of the explosion
  50342. * @param radius the explosion radius
  50343. * @param strength the explosion strength
  50344. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50345. * @returns A physics gravitational field event, or null
  50346. */
  50347. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50348. /**
  50349. * Creates a physics updraft event
  50350. * @param origin the origin of the updraft
  50351. * @param radius the radius of the updraft
  50352. * @param strength the strength of the updraft
  50353. * @param height the height of the updraft
  50354. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50355. * @returns A physics updraft event, or null
  50356. */
  50357. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50358. /**
  50359. * Creates a physics vortex event
  50360. * @param origin the of the vortex
  50361. * @param radius the radius of the vortex
  50362. * @param strength the strength of the vortex
  50363. * @param height the height of the vortex
  50364. * @returns a Physics vortex event, or null
  50365. * A physics vortex event or null
  50366. */
  50367. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50368. }
  50369. /**
  50370. * Represents a physics radial explosion event
  50371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50372. */
  50373. export class PhysicsRadialExplosionEvent {
  50374. private _scene;
  50375. private _sphere;
  50376. private _sphereOptions;
  50377. private _rays;
  50378. private _dataFetched;
  50379. /**
  50380. * Initializes a radial explosioin event
  50381. * @param scene BabylonJS scene
  50382. */
  50383. constructor(scene: Scene);
  50384. /**
  50385. * Returns the data related to the radial explosion event (sphere & rays).
  50386. * @returns The radial explosion event data
  50387. */
  50388. getData(): PhysicsRadialExplosionEventData;
  50389. /**
  50390. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50391. * @param impostor A physics imposter
  50392. * @param origin the origin of the explosion
  50393. * @param radius the explosion radius
  50394. * @param strength the explosion strength
  50395. * @param falloff possible options: Constant & Linear
  50396. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50397. */
  50398. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50399. /**
  50400. * Disposes the sphere.
  50401. * @param force Specifies if the sphere should be disposed by force
  50402. */
  50403. dispose(force?: boolean): void;
  50404. /*** Helpers ***/
  50405. private _prepareSphere;
  50406. private _intersectsWithSphere;
  50407. }
  50408. /**
  50409. * Represents a gravitational field event
  50410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50411. */
  50412. export class PhysicsGravitationalFieldEvent {
  50413. private _physicsHelper;
  50414. private _scene;
  50415. private _origin;
  50416. private _radius;
  50417. private _strength;
  50418. private _falloff;
  50419. private _tickCallback;
  50420. private _sphere;
  50421. private _dataFetched;
  50422. /**
  50423. * Initializes the physics gravitational field event
  50424. * @param physicsHelper A physics helper
  50425. * @param scene BabylonJS scene
  50426. * @param origin The origin position of the gravitational field event
  50427. * @param radius The radius of the gravitational field event
  50428. * @param strength The strength of the gravitational field event
  50429. * @param falloff The falloff for the gravitational field event
  50430. */
  50431. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50432. /**
  50433. * Returns the data related to the gravitational field event (sphere).
  50434. * @returns A gravitational field event
  50435. */
  50436. getData(): PhysicsGravitationalFieldEventData;
  50437. /**
  50438. * Enables the gravitational field.
  50439. */
  50440. enable(): void;
  50441. /**
  50442. * Disables the gravitational field.
  50443. */
  50444. disable(): void;
  50445. /**
  50446. * Disposes the sphere.
  50447. * @param force The force to dispose from the gravitational field event
  50448. */
  50449. dispose(force?: boolean): void;
  50450. private _tick;
  50451. }
  50452. /**
  50453. * Represents a physics updraft event
  50454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50455. */
  50456. export class PhysicsUpdraftEvent {
  50457. private _scene;
  50458. private _origin;
  50459. private _radius;
  50460. private _strength;
  50461. private _height;
  50462. private _updraftMode;
  50463. private _physicsEngine;
  50464. private _originTop;
  50465. private _originDirection;
  50466. private _tickCallback;
  50467. private _cylinder;
  50468. private _cylinderPosition;
  50469. private _dataFetched;
  50470. /**
  50471. * Initializes the physics updraft event
  50472. * @param _scene BabylonJS scene
  50473. * @param _origin The origin position of the updraft
  50474. * @param _radius The radius of the updraft
  50475. * @param _strength The strength of the updraft
  50476. * @param _height The height of the updraft
  50477. * @param _updraftMode The mode of the updraft
  50478. */
  50479. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50480. /**
  50481. * Returns the data related to the updraft event (cylinder).
  50482. * @returns A physics updraft event
  50483. */
  50484. getData(): PhysicsUpdraftEventData;
  50485. /**
  50486. * Enables the updraft.
  50487. */
  50488. enable(): void;
  50489. /**
  50490. * Disables the cortex.
  50491. */
  50492. disable(): void;
  50493. /**
  50494. * Disposes the sphere.
  50495. * @param force Specifies if the updraft should be disposed by force
  50496. */
  50497. dispose(force?: boolean): void;
  50498. private getImpostorForceAndContactPoint;
  50499. private _tick;
  50500. /*** Helpers ***/
  50501. private _prepareCylinder;
  50502. private _intersectsWithCylinder;
  50503. }
  50504. /**
  50505. * Represents a physics vortex event
  50506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50507. */
  50508. export class PhysicsVortexEvent {
  50509. private _scene;
  50510. private _origin;
  50511. private _radius;
  50512. private _strength;
  50513. private _height;
  50514. private _physicsEngine;
  50515. private _originTop;
  50516. private _centripetalForceThreshold;
  50517. private _updraftMultiplier;
  50518. private _tickCallback;
  50519. private _cylinder;
  50520. private _cylinderPosition;
  50521. private _dataFetched;
  50522. /**
  50523. * Initializes the physics vortex event
  50524. * @param _scene The BabylonJS scene
  50525. * @param _origin The origin position of the vortex
  50526. * @param _radius The radius of the vortex
  50527. * @param _strength The strength of the vortex
  50528. * @param _height The height of the vortex
  50529. */
  50530. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  50531. /**
  50532. * Returns the data related to the vortex event (cylinder).
  50533. * @returns The physics vortex event data
  50534. */
  50535. getData(): PhysicsVortexEventData;
  50536. /**
  50537. * Enables the vortex.
  50538. */
  50539. enable(): void;
  50540. /**
  50541. * Disables the cortex.
  50542. */
  50543. disable(): void;
  50544. /**
  50545. * Disposes the sphere.
  50546. * @param force
  50547. */
  50548. dispose(force?: boolean): void;
  50549. private getImpostorForceAndContactPoint;
  50550. private _tick;
  50551. /*** Helpers ***/
  50552. private _prepareCylinder;
  50553. private _intersectsWithCylinder;
  50554. }
  50555. /**
  50556. * The strenght of the force in correspondence to the distance of the affected object
  50557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50558. */
  50559. export enum PhysicsRadialImpulseFalloff {
  50560. /** Defines that impulse is constant in strength across it's whole radius */
  50561. Constant = 0,
  50562. /** DEfines that impulse gets weaker if it's further from the origin */
  50563. Linear = 1
  50564. }
  50565. /**
  50566. * The strength of the force in correspondence to the distance of the affected object
  50567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50568. */
  50569. export enum PhysicsUpdraftMode {
  50570. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50571. Center = 0,
  50572. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50573. Perpendicular = 1
  50574. }
  50575. /**
  50576. * Interface for a physics force and contact point
  50577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50578. */
  50579. export interface PhysicsForceAndContactPoint {
  50580. /**
  50581. * The force applied at the contact point
  50582. */
  50583. force: Vector3;
  50584. /**
  50585. * The contact point
  50586. */
  50587. contactPoint: Vector3;
  50588. }
  50589. /**
  50590. * Interface for radial explosion event data
  50591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50592. */
  50593. export interface PhysicsRadialExplosionEventData {
  50594. /**
  50595. * A sphere used for the radial explosion event
  50596. */
  50597. sphere: Mesh;
  50598. /**
  50599. * An array of rays for the radial explosion event
  50600. */
  50601. rays: Array<Ray>;
  50602. }
  50603. /**
  50604. * Interface for gravitational field event data
  50605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50606. */
  50607. export interface PhysicsGravitationalFieldEventData {
  50608. /**
  50609. * A sphere mesh used for the gravitational field event
  50610. */
  50611. sphere: Mesh;
  50612. }
  50613. /**
  50614. * Interface for updraft event data
  50615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50616. */
  50617. export interface PhysicsUpdraftEventData {
  50618. /**
  50619. * A cylinder used for the updraft event
  50620. */
  50621. cylinder: Mesh;
  50622. }
  50623. /**
  50624. * Interface for vortex event data
  50625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50626. */
  50627. export interface PhysicsVortexEventData {
  50628. /**
  50629. * A cylinder used for the vortex event
  50630. */
  50631. cylinder: Mesh;
  50632. }
  50633. }
  50634. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50635. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50636. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50637. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50638. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50639. import { Nullable } from "babylonjs/types";
  50640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50641. /**
  50642. * AmmoJS Physics plugin
  50643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50644. * @see https://github.com/kripken/ammo.js/
  50645. */
  50646. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50647. private _useDeltaForWorldStep;
  50648. /**
  50649. * Reference to the Ammo library
  50650. */
  50651. bjsAMMO: any;
  50652. /**
  50653. * Created ammoJS world which physics bodies are added to
  50654. */
  50655. world: any;
  50656. /**
  50657. * Name of the plugin
  50658. */
  50659. name: string;
  50660. private _timeStep;
  50661. private _fixedTimeStep;
  50662. private _maxSteps;
  50663. private _tmpQuaternion;
  50664. private _tmpAmmoTransform;
  50665. private _tmpAmmoQuaternion;
  50666. private _tmpAmmoConcreteContactResultCallback;
  50667. private _collisionConfiguration;
  50668. private _dispatcher;
  50669. private _overlappingPairCache;
  50670. private _solver;
  50671. private _tmpAmmoVectorA;
  50672. private _tmpAmmoVectorB;
  50673. private _tmpAmmoVectorC;
  50674. private _tmpContactCallbackResult;
  50675. private static readonly DISABLE_COLLISION_FLAG;
  50676. private static readonly KINEMATIC_FLAG;
  50677. private static readonly DISABLE_DEACTIVATION_FLAG;
  50678. /**
  50679. * Initializes the ammoJS plugin
  50680. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50681. * @param ammoInjection can be used to inject your own ammo reference
  50682. */
  50683. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50684. /**
  50685. * Sets the gravity of the physics world (m/(s^2))
  50686. * @param gravity Gravity to set
  50687. */
  50688. setGravity(gravity: Vector3): void;
  50689. /**
  50690. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50691. * @param timeStep timestep to use in seconds
  50692. */
  50693. setTimeStep(timeStep: number): void;
  50694. /**
  50695. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  50696. * @param fixedTimeStep fixedTimeStep to use in seconds
  50697. */
  50698. setFixedTimeStep(fixedTimeStep: number): void;
  50699. /**
  50700. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50701. * @param maxSteps the maximum number of steps by the physics engine per frame
  50702. */
  50703. setMaxSteps(maxSteps: number): void;
  50704. /**
  50705. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50706. * @returns the current timestep in seconds
  50707. */
  50708. getTimeStep(): number;
  50709. private _isImpostorInContact;
  50710. private _isImpostorPairInContact;
  50711. private _stepSimulation;
  50712. /**
  50713. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50714. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50715. * After the step the babylon meshes are set to the position of the physics imposters
  50716. * @param delta amount of time to step forward
  50717. * @param impostors array of imposters to update before/after the step
  50718. */
  50719. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50720. private _tmpVector;
  50721. private _tmpMatrix;
  50722. /**
  50723. * Applies an implulse on the imposter
  50724. * @param impostor imposter to apply impulse
  50725. * @param force amount of force to be applied to the imposter
  50726. * @param contactPoint the location to apply the impulse on the imposter
  50727. */
  50728. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50729. /**
  50730. * Applies a force on the imposter
  50731. * @param impostor imposter to apply force
  50732. * @param force amount of force to be applied to the imposter
  50733. * @param contactPoint the location to apply the force on the imposter
  50734. */
  50735. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50736. /**
  50737. * Creates a physics body using the plugin
  50738. * @param impostor the imposter to create the physics body on
  50739. */
  50740. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50741. /**
  50742. * Removes the physics body from the imposter and disposes of the body's memory
  50743. * @param impostor imposter to remove the physics body from
  50744. */
  50745. removePhysicsBody(impostor: PhysicsImpostor): void;
  50746. /**
  50747. * Generates a joint
  50748. * @param impostorJoint the imposter joint to create the joint with
  50749. */
  50750. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50751. /**
  50752. * Removes a joint
  50753. * @param impostorJoint the imposter joint to remove the joint from
  50754. */
  50755. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50756. private _addMeshVerts;
  50757. private _createShape;
  50758. /**
  50759. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50760. * @param impostor imposter containing the physics body and babylon object
  50761. */
  50762. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50763. /**
  50764. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50765. * @param impostor imposter containing the physics body and babylon object
  50766. * @param newPosition new position
  50767. * @param newRotation new rotation
  50768. */
  50769. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50770. /**
  50771. * If this plugin is supported
  50772. * @returns true if its supported
  50773. */
  50774. isSupported(): boolean;
  50775. /**
  50776. * Sets the linear velocity of the physics body
  50777. * @param impostor imposter to set the velocity on
  50778. * @param velocity velocity to set
  50779. */
  50780. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50781. /**
  50782. * Sets the angular velocity of the physics body
  50783. * @param impostor imposter to set the velocity on
  50784. * @param velocity velocity to set
  50785. */
  50786. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50787. /**
  50788. * gets the linear velocity
  50789. * @param impostor imposter to get linear velocity from
  50790. * @returns linear velocity
  50791. */
  50792. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50793. /**
  50794. * gets the angular velocity
  50795. * @param impostor imposter to get angular velocity from
  50796. * @returns angular velocity
  50797. */
  50798. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50799. /**
  50800. * Sets the mass of physics body
  50801. * @param impostor imposter to set the mass on
  50802. * @param mass mass to set
  50803. */
  50804. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50805. /**
  50806. * Gets the mass of the physics body
  50807. * @param impostor imposter to get the mass from
  50808. * @returns mass
  50809. */
  50810. getBodyMass(impostor: PhysicsImpostor): number;
  50811. /**
  50812. * Gets friction of the impostor
  50813. * @param impostor impostor to get friction from
  50814. * @returns friction value
  50815. */
  50816. getBodyFriction(impostor: PhysicsImpostor): number;
  50817. /**
  50818. * Sets friction of the impostor
  50819. * @param impostor impostor to set friction on
  50820. * @param friction friction value
  50821. */
  50822. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50823. /**
  50824. * Gets restitution of the impostor
  50825. * @param impostor impostor to get restitution from
  50826. * @returns restitution value
  50827. */
  50828. getBodyRestitution(impostor: PhysicsImpostor): number;
  50829. /**
  50830. * Sets resitution of the impostor
  50831. * @param impostor impostor to set resitution on
  50832. * @param restitution resitution value
  50833. */
  50834. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50835. /**
  50836. * Sleeps the physics body and stops it from being active
  50837. * @param impostor impostor to sleep
  50838. */
  50839. sleepBody(impostor: PhysicsImpostor): void;
  50840. /**
  50841. * Activates the physics body
  50842. * @param impostor impostor to activate
  50843. */
  50844. wakeUpBody(impostor: PhysicsImpostor): void;
  50845. /**
  50846. * Updates the distance parameters of the joint
  50847. * @param joint joint to update
  50848. * @param maxDistance maximum distance of the joint
  50849. * @param minDistance minimum distance of the joint
  50850. */
  50851. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50852. /**
  50853. * Sets a motor on the joint
  50854. * @param joint joint to set motor on
  50855. * @param speed speed of the motor
  50856. * @param maxForce maximum force of the motor
  50857. * @param motorIndex index of the motor
  50858. */
  50859. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50860. /**
  50861. * Sets the motors limit
  50862. * @param joint joint to set limit on
  50863. * @param upperLimit upper limit
  50864. * @param lowerLimit lower limit
  50865. */
  50866. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50867. /**
  50868. * Syncs the position and rotation of a mesh with the impostor
  50869. * @param mesh mesh to sync
  50870. * @param impostor impostor to update the mesh with
  50871. */
  50872. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50873. /**
  50874. * Gets the radius of the impostor
  50875. * @param impostor impostor to get radius from
  50876. * @returns the radius
  50877. */
  50878. getRadius(impostor: PhysicsImpostor): number;
  50879. /**
  50880. * Gets the box size of the impostor
  50881. * @param impostor impostor to get box size from
  50882. * @param result the resulting box size
  50883. */
  50884. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50885. /**
  50886. * Disposes of the impostor
  50887. */
  50888. dispose(): void;
  50889. }
  50890. }
  50891. declare module "babylonjs/Physics/Plugins/index" {
  50892. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  50893. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  50894. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  50895. }
  50896. declare module "babylonjs/Physics/index" {
  50897. export * from "babylonjs/Physics/IPhysicsEngine";
  50898. export * from "babylonjs/Physics/physicsEngine";
  50899. export * from "babylonjs/Physics/physicsEngineComponent";
  50900. export * from "babylonjs/Physics/physicsHelper";
  50901. export * from "babylonjs/Physics/physicsImpostor";
  50902. export * from "babylonjs/Physics/physicsJoint";
  50903. export * from "babylonjs/Physics/Plugins/index";
  50904. }
  50905. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  50906. /** @hidden */
  50907. export var blackAndWhitePixelShader: {
  50908. name: string;
  50909. shader: string;
  50910. };
  50911. }
  50912. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  50913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50914. import { Camera } from "babylonjs/Cameras/camera";
  50915. import { Engine } from "babylonjs/Engines/engine";
  50916. import "babylonjs/Shaders/blackAndWhite.fragment";
  50917. /**
  50918. * Post process used to render in black and white
  50919. */
  50920. export class BlackAndWhitePostProcess extends PostProcess {
  50921. /**
  50922. * Linear about to convert he result to black and white (default: 1)
  50923. */
  50924. degree: number;
  50925. /**
  50926. * Creates a black and white post process
  50927. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  50928. * @param name The name of the effect.
  50929. * @param options The required width/height ratio to downsize to before computing the render pass.
  50930. * @param camera The camera to apply the render pass to.
  50931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50932. * @param engine The engine which the post process will be applied. (default: current engine)
  50933. * @param reusable If the post process can be reused on the same frame. (default: false)
  50934. */
  50935. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50936. }
  50937. }
  50938. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  50939. import { Nullable } from "babylonjs/types";
  50940. import { Camera } from "babylonjs/Cameras/camera";
  50941. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50942. import { Engine } from "babylonjs/Engines/engine";
  50943. /**
  50944. * This represents a set of one or more post processes in Babylon.
  50945. * A post process can be used to apply a shader to a texture after it is rendered.
  50946. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50947. */
  50948. export class PostProcessRenderEffect {
  50949. private _postProcesses;
  50950. private _getPostProcesses;
  50951. private _singleInstance;
  50952. private _cameras;
  50953. private _indicesForCamera;
  50954. /**
  50955. * Name of the effect
  50956. * @hidden
  50957. */
  50958. _name: string;
  50959. /**
  50960. * Instantiates a post process render effect.
  50961. * A post process can be used to apply a shader to a texture after it is rendered.
  50962. * @param engine The engine the effect is tied to
  50963. * @param name The name of the effect
  50964. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  50965. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  50966. */
  50967. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  50968. /**
  50969. * Checks if all the post processes in the effect are supported.
  50970. */
  50971. readonly isSupported: boolean;
  50972. /**
  50973. * Updates the current state of the effect
  50974. * @hidden
  50975. */
  50976. _update(): void;
  50977. /**
  50978. * Attaches the effect on cameras
  50979. * @param cameras The camera to attach to.
  50980. * @hidden
  50981. */
  50982. _attachCameras(cameras: Camera): void;
  50983. /**
  50984. * Attaches the effect on cameras
  50985. * @param cameras The camera to attach to.
  50986. * @hidden
  50987. */
  50988. _attachCameras(cameras: Camera[]): void;
  50989. /**
  50990. * Detatches the effect on cameras
  50991. * @param cameras The camera to detatch from.
  50992. * @hidden
  50993. */
  50994. _detachCameras(cameras: Camera): void;
  50995. /**
  50996. * Detatches the effect on cameras
  50997. * @param cameras The camera to detatch from.
  50998. * @hidden
  50999. */
  51000. _detachCameras(cameras: Camera[]): void;
  51001. /**
  51002. * Enables the effect on given cameras
  51003. * @param cameras The camera to enable.
  51004. * @hidden
  51005. */
  51006. _enable(cameras: Camera): void;
  51007. /**
  51008. * Enables the effect on given cameras
  51009. * @param cameras The camera to enable.
  51010. * @hidden
  51011. */
  51012. _enable(cameras: Nullable<Camera[]>): void;
  51013. /**
  51014. * Disables the effect on the given cameras
  51015. * @param cameras The camera to disable.
  51016. * @hidden
  51017. */
  51018. _disable(cameras: Camera): void;
  51019. /**
  51020. * Disables the effect on the given cameras
  51021. * @param cameras The camera to disable.
  51022. * @hidden
  51023. */
  51024. _disable(cameras: Nullable<Camera[]>): void;
  51025. /**
  51026. * Gets a list of the post processes contained in the effect.
  51027. * @param camera The camera to get the post processes on.
  51028. * @returns The list of the post processes in the effect.
  51029. */
  51030. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51031. }
  51032. }
  51033. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51035. /** @hidden */
  51036. export var extractHighlightsPixelShader: {
  51037. name: string;
  51038. shader: string;
  51039. };
  51040. }
  51041. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51042. import { Nullable } from "babylonjs/types";
  51043. import { Camera } from "babylonjs/Cameras/camera";
  51044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51045. import { Engine } from "babylonjs/Engines/engine";
  51046. import "babylonjs/Shaders/extractHighlights.fragment";
  51047. /**
  51048. * 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.
  51049. */
  51050. export class ExtractHighlightsPostProcess extends PostProcess {
  51051. /**
  51052. * The luminance threshold, pixels below this value will be set to black.
  51053. */
  51054. threshold: number;
  51055. /** @hidden */
  51056. _exposure: number;
  51057. /**
  51058. * Post process which has the input texture to be used when performing highlight extraction
  51059. * @hidden
  51060. */
  51061. _inputPostProcess: Nullable<PostProcess>;
  51062. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51063. }
  51064. }
  51065. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51066. /** @hidden */
  51067. export var bloomMergePixelShader: {
  51068. name: string;
  51069. shader: string;
  51070. };
  51071. }
  51072. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51074. import { Nullable } from "babylonjs/types";
  51075. import { Engine } from "babylonjs/Engines/engine";
  51076. import { Camera } from "babylonjs/Cameras/camera";
  51077. import "babylonjs/Shaders/bloomMerge.fragment";
  51078. /**
  51079. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51080. */
  51081. export class BloomMergePostProcess extends PostProcess {
  51082. /** Weight of the bloom to be added to the original input. */
  51083. weight: number;
  51084. /**
  51085. * Creates a new instance of @see BloomMergePostProcess
  51086. * @param name The name of the effect.
  51087. * @param originalFromInput Post process which's input will be used for the merge.
  51088. * @param blurred Blurred highlights post process which's output will be used.
  51089. * @param weight Weight of the bloom to be added to the original input.
  51090. * @param options The required width/height ratio to downsize to before computing the render pass.
  51091. * @param camera The camera to apply the render pass to.
  51092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51093. * @param engine The engine which the post process will be applied. (default: current engine)
  51094. * @param reusable If the post process can be reused on the same frame. (default: false)
  51095. * @param textureType Type of textures used when performing the post process. (default: 0)
  51096. * @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)
  51097. */
  51098. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51099. /** Weight of the bloom to be added to the original input. */
  51100. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51101. }
  51102. }
  51103. declare module "babylonjs/PostProcesses/bloomEffect" {
  51104. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51105. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51106. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51107. import { Camera } from "babylonjs/Cameras/camera";
  51108. import { Scene } from "babylonjs/scene";
  51109. /**
  51110. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51111. */
  51112. export class BloomEffect extends PostProcessRenderEffect {
  51113. private bloomScale;
  51114. /**
  51115. * @hidden Internal
  51116. */
  51117. _effects: Array<PostProcess>;
  51118. /**
  51119. * @hidden Internal
  51120. */
  51121. _downscale: ExtractHighlightsPostProcess;
  51122. private _blurX;
  51123. private _blurY;
  51124. private _merge;
  51125. /**
  51126. * The luminance threshold to find bright areas of the image to bloom.
  51127. */
  51128. threshold: number;
  51129. /**
  51130. * The strength of the bloom.
  51131. */
  51132. weight: number;
  51133. /**
  51134. * Specifies the size of the bloom blur kernel, relative to the final output size
  51135. */
  51136. kernel: number;
  51137. /**
  51138. * Creates a new instance of @see BloomEffect
  51139. * @param scene The scene the effect belongs to.
  51140. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51141. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51142. * @param bloomWeight The the strength of bloom.
  51143. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51144. * @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)
  51145. */
  51146. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51147. /**
  51148. * Disposes each of the internal effects for a given camera.
  51149. * @param camera The camera to dispose the effect on.
  51150. */
  51151. disposeEffects(camera: Camera): void;
  51152. /**
  51153. * @hidden Internal
  51154. */
  51155. _updateEffects(): void;
  51156. /**
  51157. * Internal
  51158. * @returns if all the contained post processes are ready.
  51159. * @hidden
  51160. */
  51161. _isReady(): boolean;
  51162. }
  51163. }
  51164. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51165. /** @hidden */
  51166. export var chromaticAberrationPixelShader: {
  51167. name: string;
  51168. shader: string;
  51169. };
  51170. }
  51171. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51172. import { Vector2 } from "babylonjs/Maths/math";
  51173. import { Nullable } from "babylonjs/types";
  51174. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51175. import { Camera } from "babylonjs/Cameras/camera";
  51176. import { Engine } from "babylonjs/Engines/engine";
  51177. import "babylonjs/Shaders/chromaticAberration.fragment";
  51178. /**
  51179. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51180. */
  51181. export class ChromaticAberrationPostProcess extends PostProcess {
  51182. /**
  51183. * The amount of seperation of rgb channels (default: 30)
  51184. */
  51185. aberrationAmount: number;
  51186. /**
  51187. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51188. */
  51189. radialIntensity: number;
  51190. /**
  51191. * 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))
  51192. */
  51193. direction: Vector2;
  51194. /**
  51195. * 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))
  51196. */
  51197. centerPosition: Vector2;
  51198. /**
  51199. * Creates a new instance ChromaticAberrationPostProcess
  51200. * @param name The name of the effect.
  51201. * @param screenWidth The width of the screen to apply the effect on.
  51202. * @param screenHeight The height of the screen to apply the effect on.
  51203. * @param options The required width/height ratio to downsize to before computing the render pass.
  51204. * @param camera The camera to apply the render pass to.
  51205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51206. * @param engine The engine which the post process will be applied. (default: current engine)
  51207. * @param reusable If the post process can be reused on the same frame. (default: false)
  51208. * @param textureType Type of textures used when performing the post process. (default: 0)
  51209. * @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)
  51210. */
  51211. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51212. }
  51213. }
  51214. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51215. /** @hidden */
  51216. export var circleOfConfusionPixelShader: {
  51217. name: string;
  51218. shader: string;
  51219. };
  51220. }
  51221. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51222. import { Nullable } from "babylonjs/types";
  51223. import { Engine } from "babylonjs/Engines/engine";
  51224. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51226. import { Camera } from "babylonjs/Cameras/camera";
  51227. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51228. /**
  51229. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51230. */
  51231. export class CircleOfConfusionPostProcess extends PostProcess {
  51232. /**
  51233. * 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.
  51234. */
  51235. lensSize: number;
  51236. /**
  51237. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51238. */
  51239. fStop: number;
  51240. /**
  51241. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51242. */
  51243. focusDistance: number;
  51244. /**
  51245. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51246. */
  51247. focalLength: number;
  51248. private _depthTexture;
  51249. /**
  51250. * Creates a new instance CircleOfConfusionPostProcess
  51251. * @param name The name of the effect.
  51252. * @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.
  51253. * @param options The required width/height ratio to downsize to before computing the render pass.
  51254. * @param camera The camera to apply the render pass to.
  51255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51256. * @param engine The engine which the post process will be applied. (default: current engine)
  51257. * @param reusable If the post process can be reused on the same frame. (default: false)
  51258. * @param textureType Type of textures used when performing the post process. (default: 0)
  51259. * @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)
  51260. */
  51261. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51262. /**
  51263. * 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.
  51264. */
  51265. depthTexture: RenderTargetTexture;
  51266. }
  51267. }
  51268. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51269. /** @hidden */
  51270. export var colorCorrectionPixelShader: {
  51271. name: string;
  51272. shader: string;
  51273. };
  51274. }
  51275. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51277. import { Engine } from "babylonjs/Engines/engine";
  51278. import { Camera } from "babylonjs/Cameras/camera";
  51279. import "babylonjs/Shaders/colorCorrection.fragment";
  51280. /**
  51281. *
  51282. * This post-process allows the modification of rendered colors by using
  51283. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51284. *
  51285. * The object needs to be provided an url to a texture containing the color
  51286. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51287. * Use an image editing software to tweak the LUT to match your needs.
  51288. *
  51289. * For an example of a color LUT, see here:
  51290. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51291. * For explanations on color grading, see here:
  51292. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51293. *
  51294. */
  51295. export class ColorCorrectionPostProcess extends PostProcess {
  51296. private _colorTableTexture;
  51297. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51298. }
  51299. }
  51300. declare module "babylonjs/Shaders/convolution.fragment" {
  51301. /** @hidden */
  51302. export var convolutionPixelShader: {
  51303. name: string;
  51304. shader: string;
  51305. };
  51306. }
  51307. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51308. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51309. import { Nullable } from "babylonjs/types";
  51310. import { Camera } from "babylonjs/Cameras/camera";
  51311. import { Engine } from "babylonjs/Engines/engine";
  51312. import "babylonjs/Shaders/convolution.fragment";
  51313. /**
  51314. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51315. * input texture to perform effects such as edge detection or sharpening
  51316. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51317. */
  51318. export class ConvolutionPostProcess extends PostProcess {
  51319. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51320. kernel: number[];
  51321. /**
  51322. * Creates a new instance ConvolutionPostProcess
  51323. * @param name The name of the effect.
  51324. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51325. * @param options The required width/height ratio to downsize to before computing the render pass.
  51326. * @param camera The camera to apply the render pass to.
  51327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51328. * @param engine The engine which the post process will be applied. (default: current engine)
  51329. * @param reusable If the post process can be reused on the same frame. (default: false)
  51330. * @param textureType Type of textures used when performing the post process. (default: 0)
  51331. */
  51332. constructor(name: string,
  51333. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51334. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51335. /**
  51336. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51337. */
  51338. static EdgeDetect0Kernel: number[];
  51339. /**
  51340. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51341. */
  51342. static EdgeDetect1Kernel: number[];
  51343. /**
  51344. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51345. */
  51346. static EdgeDetect2Kernel: number[];
  51347. /**
  51348. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51349. */
  51350. static SharpenKernel: number[];
  51351. /**
  51352. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51353. */
  51354. static EmbossKernel: number[];
  51355. /**
  51356. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51357. */
  51358. static GaussianKernel: number[];
  51359. }
  51360. }
  51361. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51362. import { Nullable } from "babylonjs/types";
  51363. import { Vector2 } from "babylonjs/Maths/math";
  51364. import { Camera } from "babylonjs/Cameras/camera";
  51365. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51366. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51367. import { Engine } from "babylonjs/Engines/engine";
  51368. import { Scene } from "babylonjs/scene";
  51369. /**
  51370. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51371. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51372. * based on samples that have a large difference in distance than the center pixel.
  51373. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51374. */
  51375. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51376. direction: Vector2;
  51377. /**
  51378. * Creates a new instance CircleOfConfusionPostProcess
  51379. * @param name The name of the effect.
  51380. * @param scene The scene the effect belongs to.
  51381. * @param direction The direction the blur should be applied.
  51382. * @param kernel The size of the kernel used to blur.
  51383. * @param options The required width/height ratio to downsize to before computing the render pass.
  51384. * @param camera The camera to apply the render pass to.
  51385. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51386. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51388. * @param engine The engine which the post process will be applied. (default: current engine)
  51389. * @param reusable If the post process can be reused on the same frame. (default: false)
  51390. * @param textureType Type of textures used when performing the post process. (default: 0)
  51391. * @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)
  51392. */
  51393. 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);
  51394. }
  51395. }
  51396. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51397. /** @hidden */
  51398. export var depthOfFieldMergePixelShader: {
  51399. name: string;
  51400. shader: string;
  51401. };
  51402. }
  51403. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51404. import { Nullable } from "babylonjs/types";
  51405. import { Camera } from "babylonjs/Cameras/camera";
  51406. import { Effect } from "babylonjs/Materials/effect";
  51407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51408. import { Engine } from "babylonjs/Engines/engine";
  51409. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51410. /**
  51411. * Options to be set when merging outputs from the default pipeline.
  51412. */
  51413. export class DepthOfFieldMergePostProcessOptions {
  51414. /**
  51415. * The original image to merge on top of
  51416. */
  51417. originalFromInput: PostProcess;
  51418. /**
  51419. * Parameters to perform the merge of the depth of field effect
  51420. */
  51421. depthOfField?: {
  51422. circleOfConfusion: PostProcess;
  51423. blurSteps: Array<PostProcess>;
  51424. };
  51425. /**
  51426. * Parameters to perform the merge of bloom effect
  51427. */
  51428. bloom?: {
  51429. blurred: PostProcess;
  51430. weight: number;
  51431. };
  51432. }
  51433. /**
  51434. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51435. */
  51436. export class DepthOfFieldMergePostProcess extends PostProcess {
  51437. private blurSteps;
  51438. /**
  51439. * Creates a new instance of DepthOfFieldMergePostProcess
  51440. * @param name The name of the effect.
  51441. * @param originalFromInput Post process which's input will be used for the merge.
  51442. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51443. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51444. * @param options The required width/height ratio to downsize to before computing the render pass.
  51445. * @param camera The camera to apply the render pass to.
  51446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51447. * @param engine The engine which the post process will be applied. (default: current engine)
  51448. * @param reusable If the post process can be reused on the same frame. (default: false)
  51449. * @param textureType Type of textures used when performing the post process. (default: 0)
  51450. * @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)
  51451. */
  51452. 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);
  51453. /**
  51454. * Updates the effect with the current post process compile time values and recompiles the shader.
  51455. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51456. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51457. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51458. * @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
  51459. * @param onCompiled Called when the shader has been compiled.
  51460. * @param onError Called if there is an error when compiling a shader.
  51461. */
  51462. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51463. }
  51464. }
  51465. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51466. import { Nullable } from "babylonjs/types";
  51467. import { Camera } from "babylonjs/Cameras/camera";
  51468. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51470. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51471. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51472. import { Scene } from "babylonjs/scene";
  51473. /**
  51474. * Specifies the level of max blur that should be applied when using the depth of field effect
  51475. */
  51476. export enum DepthOfFieldEffectBlurLevel {
  51477. /**
  51478. * Subtle blur
  51479. */
  51480. Low = 0,
  51481. /**
  51482. * Medium blur
  51483. */
  51484. Medium = 1,
  51485. /**
  51486. * Large blur
  51487. */
  51488. High = 2
  51489. }
  51490. /**
  51491. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51492. */
  51493. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51494. private _circleOfConfusion;
  51495. /**
  51496. * @hidden Internal, blurs from high to low
  51497. */
  51498. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51499. private _depthOfFieldBlurY;
  51500. private _dofMerge;
  51501. /**
  51502. * @hidden Internal post processes in depth of field effect
  51503. */
  51504. _effects: Array<PostProcess>;
  51505. /**
  51506. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51507. */
  51508. focalLength: number;
  51509. /**
  51510. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51511. */
  51512. fStop: number;
  51513. /**
  51514. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51515. */
  51516. focusDistance: number;
  51517. /**
  51518. * 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.
  51519. */
  51520. lensSize: number;
  51521. /**
  51522. * Creates a new instance DepthOfFieldEffect
  51523. * @param scene The scene the effect belongs to.
  51524. * @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.
  51525. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51526. * @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)
  51527. */
  51528. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51529. /**
  51530. * 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.
  51531. */
  51532. depthTexture: RenderTargetTexture;
  51533. /**
  51534. * Disposes each of the internal effects for a given camera.
  51535. * @param camera The camera to dispose the effect on.
  51536. */
  51537. disposeEffects(camera: Camera): void;
  51538. /**
  51539. * @hidden Internal
  51540. */
  51541. _updateEffects(): void;
  51542. /**
  51543. * Internal
  51544. * @returns if all the contained post processes are ready.
  51545. * @hidden
  51546. */
  51547. _isReady(): boolean;
  51548. }
  51549. }
  51550. declare module "babylonjs/Shaders/displayPass.fragment" {
  51551. /** @hidden */
  51552. export var displayPassPixelShader: {
  51553. name: string;
  51554. shader: string;
  51555. };
  51556. }
  51557. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  51558. import { Nullable } from "babylonjs/types";
  51559. import { Camera } from "babylonjs/Cameras/camera";
  51560. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51561. import { Engine } from "babylonjs/Engines/engine";
  51562. import "babylonjs/Shaders/displayPass.fragment";
  51563. /**
  51564. * DisplayPassPostProcess which produces an output the same as it's input
  51565. */
  51566. export class DisplayPassPostProcess extends PostProcess {
  51567. /**
  51568. * Creates the DisplayPassPostProcess
  51569. * @param name The name of the effect.
  51570. * @param options The required width/height ratio to downsize to before computing the render pass.
  51571. * @param camera The camera to apply the render pass to.
  51572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51573. * @param engine The engine which the post process will be applied. (default: current engine)
  51574. * @param reusable If the post process can be reused on the same frame. (default: false)
  51575. */
  51576. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51577. }
  51578. }
  51579. declare module "babylonjs/Shaders/filter.fragment" {
  51580. /** @hidden */
  51581. export var filterPixelShader: {
  51582. name: string;
  51583. shader: string;
  51584. };
  51585. }
  51586. declare module "babylonjs/PostProcesses/filterPostProcess" {
  51587. import { Nullable } from "babylonjs/types";
  51588. import { Matrix } from "babylonjs/Maths/math";
  51589. import { Camera } from "babylonjs/Cameras/camera";
  51590. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51591. import { Engine } from "babylonjs/Engines/engine";
  51592. import "babylonjs/Shaders/filter.fragment";
  51593. /**
  51594. * Applies a kernel filter to the image
  51595. */
  51596. export class FilterPostProcess extends PostProcess {
  51597. /** The matrix to be applied to the image */
  51598. kernelMatrix: Matrix;
  51599. /**
  51600. *
  51601. * @param name The name of the effect.
  51602. * @param kernelMatrix The matrix to be applied to the image
  51603. * @param options The required width/height ratio to downsize to before computing the render pass.
  51604. * @param camera The camera to apply the render pass to.
  51605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51606. * @param engine The engine which the post process will be applied. (default: current engine)
  51607. * @param reusable If the post process can be reused on the same frame. (default: false)
  51608. */
  51609. constructor(name: string,
  51610. /** The matrix to be applied to the image */
  51611. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51612. }
  51613. }
  51614. declare module "babylonjs/Shaders/fxaa.fragment" {
  51615. /** @hidden */
  51616. export var fxaaPixelShader: {
  51617. name: string;
  51618. shader: string;
  51619. };
  51620. }
  51621. declare module "babylonjs/Shaders/fxaa.vertex" {
  51622. /** @hidden */
  51623. export var fxaaVertexShader: {
  51624. name: string;
  51625. shader: string;
  51626. };
  51627. }
  51628. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  51629. import { Nullable } from "babylonjs/types";
  51630. import { Camera } from "babylonjs/Cameras/camera";
  51631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51632. import { Engine } from "babylonjs/Engines/engine";
  51633. import "babylonjs/Shaders/fxaa.fragment";
  51634. import "babylonjs/Shaders/fxaa.vertex";
  51635. /**
  51636. * Fxaa post process
  51637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51638. */
  51639. export class FxaaPostProcess extends PostProcess {
  51640. /** @hidden */
  51641. texelWidth: number;
  51642. /** @hidden */
  51643. texelHeight: number;
  51644. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51645. private _getDefines;
  51646. }
  51647. }
  51648. declare module "babylonjs/Shaders/grain.fragment" {
  51649. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51650. /** @hidden */
  51651. export var grainPixelShader: {
  51652. name: string;
  51653. shader: string;
  51654. };
  51655. }
  51656. declare module "babylonjs/PostProcesses/grainPostProcess" {
  51657. import { Nullable } from "babylonjs/types";
  51658. import { Camera } from "babylonjs/Cameras/camera";
  51659. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51660. import { Engine } from "babylonjs/Engines/engine";
  51661. import "babylonjs/Shaders/grain.fragment";
  51662. /**
  51663. * The GrainPostProcess adds noise to the image at mid luminance levels
  51664. */
  51665. export class GrainPostProcess extends PostProcess {
  51666. /**
  51667. * The intensity of the grain added (default: 30)
  51668. */
  51669. intensity: number;
  51670. /**
  51671. * If the grain should be randomized on every frame
  51672. */
  51673. animated: boolean;
  51674. /**
  51675. * Creates a new instance of @see GrainPostProcess
  51676. * @param name The name of the effect.
  51677. * @param options The required width/height ratio to downsize to before computing the render pass.
  51678. * @param camera The camera to apply the render pass to.
  51679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51680. * @param engine The engine which the post process will be applied. (default: current engine)
  51681. * @param reusable If the post process can be reused on the same frame. (default: false)
  51682. * @param textureType Type of textures used when performing the post process. (default: 0)
  51683. * @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)
  51684. */
  51685. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51686. }
  51687. }
  51688. declare module "babylonjs/Shaders/highlights.fragment" {
  51689. /** @hidden */
  51690. export var highlightsPixelShader: {
  51691. name: string;
  51692. shader: string;
  51693. };
  51694. }
  51695. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  51696. import { Nullable } from "babylonjs/types";
  51697. import { Camera } from "babylonjs/Cameras/camera";
  51698. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51699. import { Engine } from "babylonjs/Engines/engine";
  51700. import "babylonjs/Shaders/highlights.fragment";
  51701. /**
  51702. * Extracts highlights from the image
  51703. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51704. */
  51705. export class HighlightsPostProcess extends PostProcess {
  51706. /**
  51707. * Extracts highlights from the image
  51708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51709. * @param name The name of the effect.
  51710. * @param options The required width/height ratio to downsize to before computing the render pass.
  51711. * @param camera The camera to apply the render pass to.
  51712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51713. * @param engine The engine which the post process will be applied. (default: current engine)
  51714. * @param reusable If the post process can be reused on the same frame. (default: false)
  51715. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51716. */
  51717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51718. }
  51719. }
  51720. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  51721. /** @hidden */
  51722. export var mrtFragmentDeclaration: {
  51723. name: string;
  51724. shader: string;
  51725. };
  51726. }
  51727. declare module "babylonjs/Shaders/geometry.fragment" {
  51728. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  51729. /** @hidden */
  51730. export var geometryPixelShader: {
  51731. name: string;
  51732. shader: string;
  51733. };
  51734. }
  51735. declare module "babylonjs/Shaders/geometry.vertex" {
  51736. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51737. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51738. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51739. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51740. /** @hidden */
  51741. export var geometryVertexShader: {
  51742. name: string;
  51743. shader: string;
  51744. };
  51745. }
  51746. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  51747. import { Matrix } from "babylonjs/Maths/math";
  51748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51749. import { Mesh } from "babylonjs/Meshes/mesh";
  51750. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  51751. import { Effect } from "babylonjs/Materials/effect";
  51752. import { Scene } from "babylonjs/scene";
  51753. import "babylonjs/Shaders/geometry.fragment";
  51754. import "babylonjs/Shaders/geometry.vertex";
  51755. /**
  51756. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51757. */
  51758. export class GeometryBufferRenderer {
  51759. /**
  51760. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51761. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51762. */
  51763. static readonly POSITION_TEXTURE_TYPE: number;
  51764. /**
  51765. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51766. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51767. */
  51768. static readonly VELOCITY_TEXTURE_TYPE: number;
  51769. /**
  51770. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51771. * in order to compute objects velocities when enableVelocity is set to "true"
  51772. * @hidden
  51773. */
  51774. _previousTransformationMatrices: {
  51775. [index: number]: Matrix;
  51776. };
  51777. private _scene;
  51778. private _multiRenderTarget;
  51779. private _ratio;
  51780. private _enablePosition;
  51781. private _enableVelocity;
  51782. private _positionIndex;
  51783. private _velocityIndex;
  51784. protected _effect: Effect;
  51785. protected _cachedDefines: string;
  51786. /**
  51787. * Set the render list (meshes to be rendered) used in the G buffer.
  51788. */
  51789. renderList: Mesh[];
  51790. /**
  51791. * Gets wether or not G buffer are supported by the running hardware.
  51792. * This requires draw buffer supports
  51793. */
  51794. readonly isSupported: boolean;
  51795. /**
  51796. * Returns the index of the given texture type in the G-Buffer textures array
  51797. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51798. * @returns the index of the given texture type in the G-Buffer textures array
  51799. */
  51800. getTextureIndex(textureType: number): number;
  51801. /**
  51802. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51803. */
  51804. /**
  51805. * Sets whether or not objects positions are enabled for the G buffer.
  51806. */
  51807. enablePosition: boolean;
  51808. /**
  51809. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51810. */
  51811. /**
  51812. * Sets wether or not objects velocities are enabled for the G buffer.
  51813. */
  51814. enableVelocity: boolean;
  51815. /**
  51816. * Gets the scene associated with the buffer.
  51817. */
  51818. readonly scene: Scene;
  51819. /**
  51820. * Gets the ratio used by the buffer during its creation.
  51821. * How big is the buffer related to the main canvas.
  51822. */
  51823. readonly ratio: number;
  51824. /** @hidden */
  51825. static _SceneComponentInitialization: (scene: Scene) => void;
  51826. /**
  51827. * Creates a new G Buffer for the scene
  51828. * @param scene The scene the buffer belongs to
  51829. * @param ratio How big is the buffer related to the main canvas.
  51830. */
  51831. constructor(scene: Scene, ratio?: number);
  51832. /**
  51833. * Checks wether everything is ready to render a submesh to the G buffer.
  51834. * @param subMesh the submesh to check readiness for
  51835. * @param useInstances is the mesh drawn using instance or not
  51836. * @returns true if ready otherwise false
  51837. */
  51838. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51839. /**
  51840. * Gets the current underlying G Buffer.
  51841. * @returns the buffer
  51842. */
  51843. getGBuffer(): MultiRenderTarget;
  51844. /**
  51845. * Gets the number of samples used to render the buffer (anti aliasing).
  51846. */
  51847. /**
  51848. * Sets the number of samples used to render the buffer (anti aliasing).
  51849. */
  51850. samples: number;
  51851. /**
  51852. * Disposes the renderer and frees up associated resources.
  51853. */
  51854. dispose(): void;
  51855. protected _createRenderTargets(): void;
  51856. }
  51857. }
  51858. declare module "babylonjs/Shaders/motionBlur.fragment" {
  51859. /** @hidden */
  51860. export var motionBlurPixelShader: {
  51861. name: string;
  51862. shader: string;
  51863. };
  51864. }
  51865. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  51866. import { Nullable } from "babylonjs/types";
  51867. import { Camera } from "babylonjs/Cameras/camera";
  51868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51869. import { Scene } from "babylonjs/scene";
  51870. import "babylonjs/Shaders/motionBlur.fragment";
  51871. import { Engine } from "babylonjs/Engines/engine";
  51872. /**
  51873. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51874. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51875. * As an example, all you have to do is to create the post-process:
  51876. * var mb = new BABYLON.MotionBlurPostProcess(
  51877. * 'mb', // The name of the effect.
  51878. * scene, // The scene containing the objects to blur according to their velocity.
  51879. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51880. * camera // The camera to apply the render pass to.
  51881. * );
  51882. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51883. */
  51884. export class MotionBlurPostProcess extends PostProcess {
  51885. /**
  51886. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51887. */
  51888. motionStrength: number;
  51889. /**
  51890. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51891. */
  51892. /**
  51893. * Sets the number of iterations to be used for motion blur quality
  51894. */
  51895. motionBlurSamples: number;
  51896. private _motionBlurSamples;
  51897. private _geometryBufferRenderer;
  51898. /**
  51899. * Creates a new instance MotionBlurPostProcess
  51900. * @param name The name of the effect.
  51901. * @param scene The scene containing the objects to blur according to their velocity.
  51902. * @param options The required width/height ratio to downsize to before computing the render pass.
  51903. * @param camera The camera to apply the render pass to.
  51904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51905. * @param engine The engine which the post process will be applied. (default: current engine)
  51906. * @param reusable If the post process can be reused on the same frame. (default: false)
  51907. * @param textureType Type of textures used when performing the post process. (default: 0)
  51908. * @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)
  51909. */
  51910. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51911. /**
  51912. * Disposes the post process.
  51913. * @param camera The camera to dispose the post process on.
  51914. */
  51915. dispose(camera?: Camera): void;
  51916. }
  51917. }
  51918. declare module "babylonjs/Shaders/refraction.fragment" {
  51919. /** @hidden */
  51920. export var refractionPixelShader: {
  51921. name: string;
  51922. shader: string;
  51923. };
  51924. }
  51925. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  51926. import { Color3 } from "babylonjs/Maths/math";
  51927. import { Camera } from "babylonjs/Cameras/camera";
  51928. import { Texture } from "babylonjs/Materials/Textures/texture";
  51929. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51930. import { Engine } from "babylonjs/Engines/engine";
  51931. import "babylonjs/Shaders/refraction.fragment";
  51932. /**
  51933. * Post process which applies a refractin texture
  51934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51935. */
  51936. export class RefractionPostProcess extends PostProcess {
  51937. /** the base color of the refraction (used to taint the rendering) */
  51938. color: Color3;
  51939. /** simulated refraction depth */
  51940. depth: number;
  51941. /** the coefficient of the base color (0 to remove base color tainting) */
  51942. colorLevel: number;
  51943. private _refTexture;
  51944. private _ownRefractionTexture;
  51945. /**
  51946. * Gets or sets the refraction texture
  51947. * Please note that you are responsible for disposing the texture if you set it manually
  51948. */
  51949. refractionTexture: Texture;
  51950. /**
  51951. * Initializes the RefractionPostProcess
  51952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51953. * @param name The name of the effect.
  51954. * @param refractionTextureUrl Url of the refraction texture to use
  51955. * @param color the base color of the refraction (used to taint the rendering)
  51956. * @param depth simulated refraction depth
  51957. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  51958. * @param camera The camera to apply the render pass to.
  51959. * @param options The required width/height ratio to downsize to before computing the render pass.
  51960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51961. * @param engine The engine which the post process will be applied. (default: current engine)
  51962. * @param reusable If the post process can be reused on the same frame. (default: false)
  51963. */
  51964. constructor(name: string, refractionTextureUrl: string,
  51965. /** the base color of the refraction (used to taint the rendering) */
  51966. color: Color3,
  51967. /** simulated refraction depth */
  51968. depth: number,
  51969. /** the coefficient of the base color (0 to remove base color tainting) */
  51970. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51971. /**
  51972. * Disposes of the post process
  51973. * @param camera Camera to dispose post process on
  51974. */
  51975. dispose(camera: Camera): void;
  51976. }
  51977. }
  51978. declare module "babylonjs/Shaders/sharpen.fragment" {
  51979. /** @hidden */
  51980. export var sharpenPixelShader: {
  51981. name: string;
  51982. shader: string;
  51983. };
  51984. }
  51985. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  51986. import { Nullable } from "babylonjs/types";
  51987. import { Camera } from "babylonjs/Cameras/camera";
  51988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51989. import "babylonjs/Shaders/sharpen.fragment";
  51990. import { Engine } from "babylonjs/Engines/engine";
  51991. /**
  51992. * The SharpenPostProcess applies a sharpen kernel to every pixel
  51993. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51994. */
  51995. export class SharpenPostProcess extends PostProcess {
  51996. /**
  51997. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  51998. */
  51999. colorAmount: number;
  52000. /**
  52001. * How much sharpness should be applied (default: 0.3)
  52002. */
  52003. edgeAmount: number;
  52004. /**
  52005. * Creates a new instance ConvolutionPostProcess
  52006. * @param name The name of the effect.
  52007. * @param options The required width/height ratio to downsize to before computing the render pass.
  52008. * @param camera The camera to apply the render pass to.
  52009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52010. * @param engine The engine which the post process will be applied. (default: current engine)
  52011. * @param reusable If the post process can be reused on the same frame. (default: false)
  52012. * @param textureType Type of textures used when performing the post process. (default: 0)
  52013. * @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)
  52014. */
  52015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52016. }
  52017. }
  52018. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52019. import { Nullable } from "babylonjs/types";
  52020. import { Camera } from "babylonjs/Cameras/camera";
  52021. import { Engine } from "babylonjs/Engines/engine";
  52022. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52023. /**
  52024. * PostProcessRenderPipeline
  52025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52026. */
  52027. export class PostProcessRenderPipeline {
  52028. private engine;
  52029. private _renderEffects;
  52030. private _renderEffectsForIsolatedPass;
  52031. /**
  52032. * @hidden
  52033. */
  52034. protected _cameras: Camera[];
  52035. /** @hidden */
  52036. _name: string;
  52037. /**
  52038. * Initializes a PostProcessRenderPipeline
  52039. * @param engine engine to add the pipeline to
  52040. * @param name name of the pipeline
  52041. */
  52042. constructor(engine: Engine, name: string);
  52043. /**
  52044. * "PostProcessRenderPipeline"
  52045. * @returns "PostProcessRenderPipeline"
  52046. */
  52047. getClassName(): string;
  52048. /**
  52049. * If all the render effects in the pipeline are support
  52050. */
  52051. readonly isSupported: boolean;
  52052. /**
  52053. * Adds an effect to the pipeline
  52054. * @param renderEffect the effect to add
  52055. */
  52056. addEffect(renderEffect: PostProcessRenderEffect): void;
  52057. /** @hidden */
  52058. _rebuild(): void;
  52059. /** @hidden */
  52060. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52061. /** @hidden */
  52062. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52063. /** @hidden */
  52064. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52065. /** @hidden */
  52066. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52067. /** @hidden */
  52068. _attachCameras(cameras: Camera, unique: boolean): void;
  52069. /** @hidden */
  52070. _attachCameras(cameras: Camera[], unique: boolean): void;
  52071. /** @hidden */
  52072. _detachCameras(cameras: Camera): void;
  52073. /** @hidden */
  52074. _detachCameras(cameras: Nullable<Camera[]>): void;
  52075. /** @hidden */
  52076. _update(): void;
  52077. /** @hidden */
  52078. _reset(): void;
  52079. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52080. /**
  52081. * Disposes of the pipeline
  52082. */
  52083. dispose(): void;
  52084. }
  52085. }
  52086. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52087. import { IAnimatable } from "babylonjs/Misc/tools";
  52088. import { Camera } from "babylonjs/Cameras/camera";
  52089. import { IDisposable } from "babylonjs/scene";
  52090. import { Scene } from "babylonjs/scene";
  52091. import { Animation } from "babylonjs/Animations/animation";
  52092. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52093. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52094. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52095. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52096. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52097. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52098. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52099. /**
  52100. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52101. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52102. */
  52103. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52104. private _scene;
  52105. private _camerasToBeAttached;
  52106. /**
  52107. * ID of the sharpen post process,
  52108. */
  52109. private readonly SharpenPostProcessId;
  52110. /**
  52111. * @ignore
  52112. * ID of the image processing post process;
  52113. */
  52114. readonly ImageProcessingPostProcessId: string;
  52115. /**
  52116. * @ignore
  52117. * ID of the Fast Approximate Anti-Aliasing post process;
  52118. */
  52119. readonly FxaaPostProcessId: string;
  52120. /**
  52121. * ID of the chromatic aberration post process,
  52122. */
  52123. private readonly ChromaticAberrationPostProcessId;
  52124. /**
  52125. * ID of the grain post process
  52126. */
  52127. private readonly GrainPostProcessId;
  52128. /**
  52129. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52130. */
  52131. sharpen: SharpenPostProcess;
  52132. private _sharpenEffect;
  52133. private bloom;
  52134. /**
  52135. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52136. */
  52137. depthOfField: DepthOfFieldEffect;
  52138. /**
  52139. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52140. */
  52141. fxaa: FxaaPostProcess;
  52142. /**
  52143. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52144. */
  52145. imageProcessing: ImageProcessingPostProcess;
  52146. /**
  52147. * Chromatic aberration post process which will shift rgb colors in the image
  52148. */
  52149. chromaticAberration: ChromaticAberrationPostProcess;
  52150. private _chromaticAberrationEffect;
  52151. /**
  52152. * Grain post process which add noise to the image
  52153. */
  52154. grain: GrainPostProcess;
  52155. private _grainEffect;
  52156. /**
  52157. * Glow post process which adds a glow to emmisive areas of the image
  52158. */
  52159. private _glowLayer;
  52160. /**
  52161. * Animations which can be used to tweak settings over a period of time
  52162. */
  52163. animations: Animation[];
  52164. private _imageProcessingConfigurationObserver;
  52165. private _sharpenEnabled;
  52166. private _bloomEnabled;
  52167. private _depthOfFieldEnabled;
  52168. private _depthOfFieldBlurLevel;
  52169. private _fxaaEnabled;
  52170. private _imageProcessingEnabled;
  52171. private _defaultPipelineTextureType;
  52172. private _bloomScale;
  52173. private _chromaticAberrationEnabled;
  52174. private _grainEnabled;
  52175. private _buildAllowed;
  52176. /**
  52177. * Enable or disable the sharpen process from the pipeline
  52178. */
  52179. sharpenEnabled: boolean;
  52180. private _resizeObserver;
  52181. private _hardwareScaleLevel;
  52182. private _bloomKernel;
  52183. /**
  52184. * Specifies the size of the bloom blur kernel, relative to the final output size
  52185. */
  52186. bloomKernel: number;
  52187. /**
  52188. * Specifies the weight of the bloom in the final rendering
  52189. */
  52190. private _bloomWeight;
  52191. /**
  52192. * Specifies the luma threshold for the area that will be blurred by the bloom
  52193. */
  52194. private _bloomThreshold;
  52195. private _hdr;
  52196. /**
  52197. * The strength of the bloom.
  52198. */
  52199. bloomWeight: number;
  52200. /**
  52201. * The strength of the bloom.
  52202. */
  52203. bloomThreshold: number;
  52204. /**
  52205. * The scale of the bloom, lower value will provide better performance.
  52206. */
  52207. bloomScale: number;
  52208. /**
  52209. * Enable or disable the bloom from the pipeline
  52210. */
  52211. bloomEnabled: boolean;
  52212. private _rebuildBloom;
  52213. /**
  52214. * If the depth of field is enabled.
  52215. */
  52216. depthOfFieldEnabled: boolean;
  52217. /**
  52218. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52219. */
  52220. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52221. /**
  52222. * If the anti aliasing is enabled.
  52223. */
  52224. fxaaEnabled: boolean;
  52225. private _samples;
  52226. /**
  52227. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52228. */
  52229. samples: number;
  52230. /**
  52231. * If image processing is enabled.
  52232. */
  52233. imageProcessingEnabled: boolean;
  52234. /**
  52235. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52236. */
  52237. glowLayerEnabled: boolean;
  52238. /**
  52239. * Enable or disable the chromaticAberration process from the pipeline
  52240. */
  52241. chromaticAberrationEnabled: boolean;
  52242. /**
  52243. * Enable or disable the grain process from the pipeline
  52244. */
  52245. grainEnabled: boolean;
  52246. /**
  52247. * @constructor
  52248. * @param name - The rendering pipeline name (default: "")
  52249. * @param hdr - If high dynamic range textures should be used (default: true)
  52250. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52251. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52252. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52253. */
  52254. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52255. /**
  52256. * Force the compilation of the entire pipeline.
  52257. */
  52258. prepare(): void;
  52259. private _hasCleared;
  52260. private _prevPostProcess;
  52261. private _prevPrevPostProcess;
  52262. private _setAutoClearAndTextureSharing;
  52263. private _depthOfFieldSceneObserver;
  52264. private _buildPipeline;
  52265. private _disposePostProcesses;
  52266. /**
  52267. * Adds a camera to the pipeline
  52268. * @param camera the camera to be added
  52269. */
  52270. addCamera(camera: Camera): void;
  52271. /**
  52272. * Removes a camera from the pipeline
  52273. * @param camera the camera to remove
  52274. */
  52275. removeCamera(camera: Camera): void;
  52276. /**
  52277. * Dispose of the pipeline and stop all post processes
  52278. */
  52279. dispose(): void;
  52280. /**
  52281. * Serialize the rendering pipeline (Used when exporting)
  52282. * @returns the serialized object
  52283. */
  52284. serialize(): any;
  52285. /**
  52286. * Parse the serialized pipeline
  52287. * @param source Source pipeline.
  52288. * @param scene The scene to load the pipeline to.
  52289. * @param rootUrl The URL of the serialized pipeline.
  52290. * @returns An instantiated pipeline from the serialized object.
  52291. */
  52292. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52293. }
  52294. }
  52295. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52296. /** @hidden */
  52297. export var lensHighlightsPixelShader: {
  52298. name: string;
  52299. shader: string;
  52300. };
  52301. }
  52302. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52303. /** @hidden */
  52304. export var depthOfFieldPixelShader: {
  52305. name: string;
  52306. shader: string;
  52307. };
  52308. }
  52309. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52310. import { Camera } from "babylonjs/Cameras/camera";
  52311. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52312. import { Scene } from "babylonjs/scene";
  52313. import "babylonjs/Shaders/chromaticAberration.fragment";
  52314. import "babylonjs/Shaders/lensHighlights.fragment";
  52315. import "babylonjs/Shaders/depthOfField.fragment";
  52316. /**
  52317. * BABYLON.JS Chromatic Aberration GLSL Shader
  52318. * Author: Olivier Guyot
  52319. * Separates very slightly R, G and B colors on the edges of the screen
  52320. * Inspired by Francois Tarlier & Martins Upitis
  52321. */
  52322. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52323. /**
  52324. * @ignore
  52325. * The chromatic aberration PostProcess id in the pipeline
  52326. */
  52327. LensChromaticAberrationEffect: string;
  52328. /**
  52329. * @ignore
  52330. * The highlights enhancing PostProcess id in the pipeline
  52331. */
  52332. HighlightsEnhancingEffect: string;
  52333. /**
  52334. * @ignore
  52335. * The depth-of-field PostProcess id in the pipeline
  52336. */
  52337. LensDepthOfFieldEffect: string;
  52338. private _scene;
  52339. private _depthTexture;
  52340. private _grainTexture;
  52341. private _chromaticAberrationPostProcess;
  52342. private _highlightsPostProcess;
  52343. private _depthOfFieldPostProcess;
  52344. private _edgeBlur;
  52345. private _grainAmount;
  52346. private _chromaticAberration;
  52347. private _distortion;
  52348. private _highlightsGain;
  52349. private _highlightsThreshold;
  52350. private _dofDistance;
  52351. private _dofAperture;
  52352. private _dofDarken;
  52353. private _dofPentagon;
  52354. private _blurNoise;
  52355. /**
  52356. * @constructor
  52357. *
  52358. * Effect parameters are as follow:
  52359. * {
  52360. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52361. * edge_blur: number; // from 0 to x (1 for realism)
  52362. * distortion: number; // from 0 to x (1 for realism)
  52363. * grain_amount: number; // from 0 to 1
  52364. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52365. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52366. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52367. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52368. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52369. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52370. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52371. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52372. * }
  52373. * Note: if an effect parameter is unset, effect is disabled
  52374. *
  52375. * @param name The rendering pipeline name
  52376. * @param parameters - An object containing all parameters (see above)
  52377. * @param scene The scene linked to this pipeline
  52378. * @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)
  52379. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52380. */
  52381. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52382. /**
  52383. * Sets the amount of blur at the edges
  52384. * @param amount blur amount
  52385. */
  52386. setEdgeBlur(amount: number): void;
  52387. /**
  52388. * Sets edge blur to 0
  52389. */
  52390. disableEdgeBlur(): void;
  52391. /**
  52392. * Sets the amout of grain
  52393. * @param amount Amount of grain
  52394. */
  52395. setGrainAmount(amount: number): void;
  52396. /**
  52397. * Set grain amount to 0
  52398. */
  52399. disableGrain(): void;
  52400. /**
  52401. * Sets the chromatic aberration amount
  52402. * @param amount amount of chromatic aberration
  52403. */
  52404. setChromaticAberration(amount: number): void;
  52405. /**
  52406. * Sets chromatic aberration amount to 0
  52407. */
  52408. disableChromaticAberration(): void;
  52409. /**
  52410. * Sets the EdgeDistortion amount
  52411. * @param amount amount of EdgeDistortion
  52412. */
  52413. setEdgeDistortion(amount: number): void;
  52414. /**
  52415. * Sets edge distortion to 0
  52416. */
  52417. disableEdgeDistortion(): void;
  52418. /**
  52419. * Sets the FocusDistance amount
  52420. * @param amount amount of FocusDistance
  52421. */
  52422. setFocusDistance(amount: number): void;
  52423. /**
  52424. * Disables depth of field
  52425. */
  52426. disableDepthOfField(): void;
  52427. /**
  52428. * Sets the Aperture amount
  52429. * @param amount amount of Aperture
  52430. */
  52431. setAperture(amount: number): void;
  52432. /**
  52433. * Sets the DarkenOutOfFocus amount
  52434. * @param amount amount of DarkenOutOfFocus
  52435. */
  52436. setDarkenOutOfFocus(amount: number): void;
  52437. /**
  52438. * Creates a pentagon bokeh effect
  52439. */
  52440. enablePentagonBokeh(): void;
  52441. /**
  52442. * Disables the pentagon bokeh effect
  52443. */
  52444. disablePentagonBokeh(): void;
  52445. /**
  52446. * Enables noise blur
  52447. */
  52448. enableNoiseBlur(): void;
  52449. /**
  52450. * Disables noise blur
  52451. */
  52452. disableNoiseBlur(): void;
  52453. /**
  52454. * Sets the HighlightsGain amount
  52455. * @param amount amount of HighlightsGain
  52456. */
  52457. setHighlightsGain(amount: number): void;
  52458. /**
  52459. * Sets the HighlightsThreshold amount
  52460. * @param amount amount of HighlightsThreshold
  52461. */
  52462. setHighlightsThreshold(amount: number): void;
  52463. /**
  52464. * Disables highlights
  52465. */
  52466. disableHighlights(): void;
  52467. /**
  52468. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52469. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52470. */
  52471. dispose(disableDepthRender?: boolean): void;
  52472. private _createChromaticAberrationPostProcess;
  52473. private _createHighlightsPostProcess;
  52474. private _createDepthOfFieldPostProcess;
  52475. private _createGrainTexture;
  52476. }
  52477. }
  52478. declare module "babylonjs/Shaders/ssao2.fragment" {
  52479. /** @hidden */
  52480. export var ssao2PixelShader: {
  52481. name: string;
  52482. shader: string;
  52483. };
  52484. }
  52485. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  52486. /** @hidden */
  52487. export var ssaoCombinePixelShader: {
  52488. name: string;
  52489. shader: string;
  52490. };
  52491. }
  52492. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  52493. import { Camera } from "babylonjs/Cameras/camera";
  52494. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52495. import { Scene } from "babylonjs/scene";
  52496. import "babylonjs/Shaders/ssao2.fragment";
  52497. import "babylonjs/Shaders/ssaoCombine.fragment";
  52498. /**
  52499. * Render pipeline to produce ssao effect
  52500. */
  52501. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52502. /**
  52503. * @ignore
  52504. * The PassPostProcess id in the pipeline that contains the original scene color
  52505. */
  52506. SSAOOriginalSceneColorEffect: string;
  52507. /**
  52508. * @ignore
  52509. * The SSAO PostProcess id in the pipeline
  52510. */
  52511. SSAORenderEffect: string;
  52512. /**
  52513. * @ignore
  52514. * The horizontal blur PostProcess id in the pipeline
  52515. */
  52516. SSAOBlurHRenderEffect: string;
  52517. /**
  52518. * @ignore
  52519. * The vertical blur PostProcess id in the pipeline
  52520. */
  52521. SSAOBlurVRenderEffect: string;
  52522. /**
  52523. * @ignore
  52524. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52525. */
  52526. SSAOCombineRenderEffect: string;
  52527. /**
  52528. * The output strength of the SSAO post-process. Default value is 1.0.
  52529. */
  52530. totalStrength: number;
  52531. /**
  52532. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52533. */
  52534. maxZ: number;
  52535. /**
  52536. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52537. */
  52538. minZAspect: number;
  52539. private _samples;
  52540. /**
  52541. * Number of samples used for the SSAO calculations. Default value is 8
  52542. */
  52543. samples: number;
  52544. private _textureSamples;
  52545. /**
  52546. * Number of samples to use for antialiasing
  52547. */
  52548. textureSamples: number;
  52549. /**
  52550. * Ratio object used for SSAO ratio and blur ratio
  52551. */
  52552. private _ratio;
  52553. /**
  52554. * Dynamically generated sphere sampler.
  52555. */
  52556. private _sampleSphere;
  52557. /**
  52558. * Blur filter offsets
  52559. */
  52560. private _samplerOffsets;
  52561. private _expensiveBlur;
  52562. /**
  52563. * If bilateral blur should be used
  52564. */
  52565. expensiveBlur: boolean;
  52566. /**
  52567. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52568. */
  52569. radius: number;
  52570. /**
  52571. * The base color of the SSAO post-process
  52572. * The final result is "base + ssao" between [0, 1]
  52573. */
  52574. base: number;
  52575. /**
  52576. * Support test.
  52577. */
  52578. static readonly IsSupported: boolean;
  52579. private _scene;
  52580. private _depthTexture;
  52581. private _normalTexture;
  52582. private _randomTexture;
  52583. private _originalColorPostProcess;
  52584. private _ssaoPostProcess;
  52585. private _blurHPostProcess;
  52586. private _blurVPostProcess;
  52587. private _ssaoCombinePostProcess;
  52588. private _firstUpdate;
  52589. /**
  52590. * @constructor
  52591. * @param name The rendering pipeline name
  52592. * @param scene The scene linked to this pipeline
  52593. * @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 }
  52594. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52595. */
  52596. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52597. /**
  52598. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52599. */
  52600. dispose(disableGeometryBufferRenderer?: boolean): void;
  52601. private _createBlurPostProcess;
  52602. /** @hidden */
  52603. _rebuild(): void;
  52604. private _bits;
  52605. private _radicalInverse_VdC;
  52606. private _hammersley;
  52607. private _hemisphereSample_uniform;
  52608. private _generateHemisphere;
  52609. private _createSSAOPostProcess;
  52610. private _createSSAOCombinePostProcess;
  52611. private _createRandomTexture;
  52612. /**
  52613. * Serialize the rendering pipeline (Used when exporting)
  52614. * @returns the serialized object
  52615. */
  52616. serialize(): any;
  52617. /**
  52618. * Parse the serialized pipeline
  52619. * @param source Source pipeline.
  52620. * @param scene The scene to load the pipeline to.
  52621. * @param rootUrl The URL of the serialized pipeline.
  52622. * @returns An instantiated pipeline from the serialized object.
  52623. */
  52624. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52625. }
  52626. }
  52627. declare module "babylonjs/Shaders/ssao.fragment" {
  52628. /** @hidden */
  52629. export var ssaoPixelShader: {
  52630. name: string;
  52631. shader: string;
  52632. };
  52633. }
  52634. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  52635. import { Camera } from "babylonjs/Cameras/camera";
  52636. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52637. import { Scene } from "babylonjs/scene";
  52638. import "babylonjs/Shaders/ssao.fragment";
  52639. import "babylonjs/Shaders/ssaoCombine.fragment";
  52640. /**
  52641. * Render pipeline to produce ssao effect
  52642. */
  52643. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52644. /**
  52645. * @ignore
  52646. * The PassPostProcess id in the pipeline that contains the original scene color
  52647. */
  52648. SSAOOriginalSceneColorEffect: string;
  52649. /**
  52650. * @ignore
  52651. * The SSAO PostProcess id in the pipeline
  52652. */
  52653. SSAORenderEffect: string;
  52654. /**
  52655. * @ignore
  52656. * The horizontal blur PostProcess id in the pipeline
  52657. */
  52658. SSAOBlurHRenderEffect: string;
  52659. /**
  52660. * @ignore
  52661. * The vertical blur PostProcess id in the pipeline
  52662. */
  52663. SSAOBlurVRenderEffect: string;
  52664. /**
  52665. * @ignore
  52666. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52667. */
  52668. SSAOCombineRenderEffect: string;
  52669. /**
  52670. * The output strength of the SSAO post-process. Default value is 1.0.
  52671. */
  52672. totalStrength: number;
  52673. /**
  52674. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52675. */
  52676. radius: number;
  52677. /**
  52678. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52679. * Must not be equal to fallOff and superior to fallOff.
  52680. * Default value is 0.975
  52681. */
  52682. area: number;
  52683. /**
  52684. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52685. * Must not be equal to area and inferior to area.
  52686. * Default value is 0.0
  52687. */
  52688. fallOff: number;
  52689. /**
  52690. * The base color of the SSAO post-process
  52691. * The final result is "base + ssao" between [0, 1]
  52692. */
  52693. base: number;
  52694. private _scene;
  52695. private _depthTexture;
  52696. private _randomTexture;
  52697. private _originalColorPostProcess;
  52698. private _ssaoPostProcess;
  52699. private _blurHPostProcess;
  52700. private _blurVPostProcess;
  52701. private _ssaoCombinePostProcess;
  52702. private _firstUpdate;
  52703. /**
  52704. * @constructor
  52705. * @param name - The rendering pipeline name
  52706. * @param scene - The scene linked to this pipeline
  52707. * @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 }
  52708. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52709. */
  52710. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52711. /**
  52712. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52713. */
  52714. dispose(disableDepthRender?: boolean): void;
  52715. private _createBlurPostProcess;
  52716. /** @hidden */
  52717. _rebuild(): void;
  52718. private _createSSAOPostProcess;
  52719. private _createSSAOCombinePostProcess;
  52720. private _createRandomTexture;
  52721. }
  52722. }
  52723. declare module "babylonjs/Shaders/standard.fragment" {
  52724. /** @hidden */
  52725. export var standardPixelShader: {
  52726. name: string;
  52727. shader: string;
  52728. };
  52729. }
  52730. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  52731. import { Nullable } from "babylonjs/types";
  52732. import { IAnimatable } from "babylonjs/Misc/tools";
  52733. import { Camera } from "babylonjs/Cameras/camera";
  52734. import { Texture } from "babylonjs/Materials/Textures/texture";
  52735. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52736. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52737. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52738. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52739. import { IDisposable } from "babylonjs/scene";
  52740. import { SpotLight } from "babylonjs/Lights/spotLight";
  52741. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  52742. import { Scene } from "babylonjs/scene";
  52743. import { Animation } from "babylonjs/Animations/animation";
  52744. import "babylonjs/Shaders/standard.fragment";
  52745. /**
  52746. * Standard rendering pipeline
  52747. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52748. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52749. */
  52750. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52751. /**
  52752. * Public members
  52753. */
  52754. /**
  52755. * Post-process which contains the original scene color before the pipeline applies all the effects
  52756. */
  52757. originalPostProcess: Nullable<PostProcess>;
  52758. /**
  52759. * Post-process used to down scale an image x4
  52760. */
  52761. downSampleX4PostProcess: Nullable<PostProcess>;
  52762. /**
  52763. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  52764. */
  52765. brightPassPostProcess: Nullable<PostProcess>;
  52766. /**
  52767. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  52768. */
  52769. blurHPostProcesses: PostProcess[];
  52770. /**
  52771. * Post-process array storing all the vertical blur post-processes used by the pipeline
  52772. */
  52773. blurVPostProcesses: PostProcess[];
  52774. /**
  52775. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  52776. */
  52777. textureAdderPostProcess: Nullable<PostProcess>;
  52778. /**
  52779. * Post-process used to create volumetric lighting effect
  52780. */
  52781. volumetricLightPostProcess: Nullable<PostProcess>;
  52782. /**
  52783. * Post-process used to smooth the previous volumetric light post-process on the X axis
  52784. */
  52785. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  52786. /**
  52787. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  52788. */
  52789. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  52790. /**
  52791. * Post-process used to merge the volumetric light effect and the real scene color
  52792. */
  52793. volumetricLightMergePostProces: Nullable<PostProcess>;
  52794. /**
  52795. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  52796. */
  52797. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  52798. /**
  52799. * Base post-process used to calculate the average luminance of the final image for HDR
  52800. */
  52801. luminancePostProcess: Nullable<PostProcess>;
  52802. /**
  52803. * Post-processes used to create down sample post-processes in order to get
  52804. * the average luminance of the final image for HDR
  52805. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  52806. */
  52807. luminanceDownSamplePostProcesses: PostProcess[];
  52808. /**
  52809. * Post-process used to create a HDR effect (light adaptation)
  52810. */
  52811. hdrPostProcess: Nullable<PostProcess>;
  52812. /**
  52813. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  52814. */
  52815. textureAdderFinalPostProcess: Nullable<PostProcess>;
  52816. /**
  52817. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  52818. */
  52819. lensFlareFinalPostProcess: Nullable<PostProcess>;
  52820. /**
  52821. * Post-process used to merge the final HDR post-process and the real scene color
  52822. */
  52823. hdrFinalPostProcess: Nullable<PostProcess>;
  52824. /**
  52825. * Post-process used to create a lens flare effect
  52826. */
  52827. lensFlarePostProcess: Nullable<PostProcess>;
  52828. /**
  52829. * Post-process that merges the result of the lens flare post-process and the real scene color
  52830. */
  52831. lensFlareComposePostProcess: Nullable<PostProcess>;
  52832. /**
  52833. * Post-process used to create a motion blur effect
  52834. */
  52835. motionBlurPostProcess: Nullable<PostProcess>;
  52836. /**
  52837. * Post-process used to create a depth of field effect
  52838. */
  52839. depthOfFieldPostProcess: Nullable<PostProcess>;
  52840. /**
  52841. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52842. */
  52843. fxaaPostProcess: Nullable<FxaaPostProcess>;
  52844. /**
  52845. * Represents the brightness threshold in order to configure the illuminated surfaces
  52846. */
  52847. brightThreshold: number;
  52848. /**
  52849. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  52850. */
  52851. blurWidth: number;
  52852. /**
  52853. * Sets if the blur for highlighted surfaces must be only horizontal
  52854. */
  52855. horizontalBlur: boolean;
  52856. /**
  52857. * Sets the overall exposure used by the pipeline
  52858. */
  52859. exposure: number;
  52860. /**
  52861. * Texture used typically to simulate "dirty" on camera lens
  52862. */
  52863. lensTexture: Nullable<Texture>;
  52864. /**
  52865. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  52866. */
  52867. volumetricLightCoefficient: number;
  52868. /**
  52869. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  52870. */
  52871. volumetricLightPower: number;
  52872. /**
  52873. * Used the set the blur intensity to smooth the volumetric lights
  52874. */
  52875. volumetricLightBlurScale: number;
  52876. /**
  52877. * Light (spot or directional) used to generate the volumetric lights rays
  52878. * The source light must have a shadow generate so the pipeline can get its
  52879. * depth map
  52880. */
  52881. sourceLight: Nullable<SpotLight | DirectionalLight>;
  52882. /**
  52883. * For eye adaptation, represents the minimum luminance the eye can see
  52884. */
  52885. hdrMinimumLuminance: number;
  52886. /**
  52887. * For eye adaptation, represents the decrease luminance speed
  52888. */
  52889. hdrDecreaseRate: number;
  52890. /**
  52891. * For eye adaptation, represents the increase luminance speed
  52892. */
  52893. hdrIncreaseRate: number;
  52894. /**
  52895. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  52896. */
  52897. lensColorTexture: Nullable<Texture>;
  52898. /**
  52899. * The overall strengh for the lens flare effect
  52900. */
  52901. lensFlareStrength: number;
  52902. /**
  52903. * Dispersion coefficient for lens flare ghosts
  52904. */
  52905. lensFlareGhostDispersal: number;
  52906. /**
  52907. * Main lens flare halo width
  52908. */
  52909. lensFlareHaloWidth: number;
  52910. /**
  52911. * Based on the lens distortion effect, defines how much the lens flare result
  52912. * is distorted
  52913. */
  52914. lensFlareDistortionStrength: number;
  52915. /**
  52916. * Lens star texture must be used to simulate rays on the flares and is available
  52917. * in the documentation
  52918. */
  52919. lensStarTexture: Nullable<Texture>;
  52920. /**
  52921. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  52922. * flare effect by taking account of the dirt texture
  52923. */
  52924. lensFlareDirtTexture: Nullable<Texture>;
  52925. /**
  52926. * Represents the focal length for the depth of field effect
  52927. */
  52928. depthOfFieldDistance: number;
  52929. /**
  52930. * Represents the blur intensity for the blurred part of the depth of field effect
  52931. */
  52932. depthOfFieldBlurWidth: number;
  52933. /**
  52934. * For motion blur, defines how much the image is blurred by the movement
  52935. */
  52936. motionStrength: number;
  52937. /**
  52938. * List of animations for the pipeline (IAnimatable implementation)
  52939. */
  52940. animations: Animation[];
  52941. /**
  52942. * Private members
  52943. */
  52944. private _scene;
  52945. private _currentDepthOfFieldSource;
  52946. private _basePostProcess;
  52947. private _hdrCurrentLuminance;
  52948. private _floatTextureType;
  52949. private _ratio;
  52950. private _bloomEnabled;
  52951. private _depthOfFieldEnabled;
  52952. private _vlsEnabled;
  52953. private _lensFlareEnabled;
  52954. private _hdrEnabled;
  52955. private _motionBlurEnabled;
  52956. private _fxaaEnabled;
  52957. private _motionBlurSamples;
  52958. private _volumetricLightStepsCount;
  52959. private _samples;
  52960. /**
  52961. * @ignore
  52962. * Specifies if the bloom pipeline is enabled
  52963. */
  52964. BloomEnabled: boolean;
  52965. /**
  52966. * @ignore
  52967. * Specifies if the depth of field pipeline is enabed
  52968. */
  52969. DepthOfFieldEnabled: boolean;
  52970. /**
  52971. * @ignore
  52972. * Specifies if the lens flare pipeline is enabed
  52973. */
  52974. LensFlareEnabled: boolean;
  52975. /**
  52976. * @ignore
  52977. * Specifies if the HDR pipeline is enabled
  52978. */
  52979. HDREnabled: boolean;
  52980. /**
  52981. * @ignore
  52982. * Specifies if the volumetric lights scattering effect is enabled
  52983. */
  52984. VLSEnabled: boolean;
  52985. /**
  52986. * @ignore
  52987. * Specifies if the motion blur effect is enabled
  52988. */
  52989. MotionBlurEnabled: boolean;
  52990. /**
  52991. * Specifies if anti-aliasing is enabled
  52992. */
  52993. fxaaEnabled: boolean;
  52994. /**
  52995. * Specifies the number of steps used to calculate the volumetric lights
  52996. * Typically in interval [50, 200]
  52997. */
  52998. volumetricLightStepsCount: number;
  52999. /**
  53000. * Specifies the number of samples used for the motion blur effect
  53001. * Typically in interval [16, 64]
  53002. */
  53003. motionBlurSamples: number;
  53004. /**
  53005. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53006. */
  53007. samples: number;
  53008. /**
  53009. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53010. * @constructor
  53011. * @param name The rendering pipeline name
  53012. * @param scene The scene linked to this pipeline
  53013. * @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)
  53014. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53015. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53016. */
  53017. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53018. private _buildPipeline;
  53019. private _createDownSampleX4PostProcess;
  53020. private _createBrightPassPostProcess;
  53021. private _createBlurPostProcesses;
  53022. private _createTextureAdderPostProcess;
  53023. private _createVolumetricLightPostProcess;
  53024. private _createLuminancePostProcesses;
  53025. private _createHdrPostProcess;
  53026. private _createLensFlarePostProcess;
  53027. private _createDepthOfFieldPostProcess;
  53028. private _createMotionBlurPostProcess;
  53029. private _getDepthTexture;
  53030. private _disposePostProcesses;
  53031. /**
  53032. * Dispose of the pipeline and stop all post processes
  53033. */
  53034. dispose(): void;
  53035. /**
  53036. * Serialize the rendering pipeline (Used when exporting)
  53037. * @returns the serialized object
  53038. */
  53039. serialize(): any;
  53040. /**
  53041. * Parse the serialized pipeline
  53042. * @param source Source pipeline.
  53043. * @param scene The scene to load the pipeline to.
  53044. * @param rootUrl The URL of the serialized pipeline.
  53045. * @returns An instantiated pipeline from the serialized object.
  53046. */
  53047. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53048. /**
  53049. * Luminance steps
  53050. */
  53051. static LuminanceSteps: number;
  53052. }
  53053. }
  53054. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53055. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53056. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53057. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53058. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53059. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53060. }
  53061. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53062. import { Camera } from "babylonjs/Cameras/camera";
  53063. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53064. /**
  53065. * PostProcessRenderPipelineManager class
  53066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53067. */
  53068. export class PostProcessRenderPipelineManager {
  53069. private _renderPipelines;
  53070. /**
  53071. * Initializes a PostProcessRenderPipelineManager
  53072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53073. */
  53074. constructor();
  53075. /**
  53076. * Adds a pipeline to the manager
  53077. * @param renderPipeline The pipeline to add
  53078. */
  53079. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53080. /**
  53081. * Attaches a camera to the pipeline
  53082. * @param renderPipelineName The name of the pipeline to attach to
  53083. * @param cameras the camera to attach
  53084. * @param unique if the camera can be attached multiple times to the pipeline
  53085. */
  53086. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53087. /**
  53088. * Detaches a camera from the pipeline
  53089. * @param renderPipelineName The name of the pipeline to detach from
  53090. * @param cameras the camera to detach
  53091. */
  53092. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53093. /**
  53094. * Enables an effect by name on a pipeline
  53095. * @param renderPipelineName the name of the pipeline to enable the effect in
  53096. * @param renderEffectName the name of the effect to enable
  53097. * @param cameras the cameras that the effect should be enabled on
  53098. */
  53099. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53100. /**
  53101. * Disables an effect by name on a pipeline
  53102. * @param renderPipelineName the name of the pipeline to disable the effect in
  53103. * @param renderEffectName the name of the effect to disable
  53104. * @param cameras the cameras that the effect should be disabled on
  53105. */
  53106. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53107. /**
  53108. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53109. */
  53110. update(): void;
  53111. /** @hidden */
  53112. _rebuild(): void;
  53113. /**
  53114. * Disposes of the manager and pipelines
  53115. */
  53116. dispose(): void;
  53117. }
  53118. }
  53119. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53120. import { ISceneComponent } from "babylonjs/sceneComponent";
  53121. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53122. import { Scene } from "babylonjs/scene";
  53123. module "babylonjs/scene" {
  53124. interface Scene {
  53125. /** @hidden (Backing field) */
  53126. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53127. /**
  53128. * Gets the postprocess render pipeline manager
  53129. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53130. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53131. */
  53132. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53133. }
  53134. }
  53135. /**
  53136. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53137. */
  53138. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53139. /**
  53140. * The component name helpfull to identify the component in the list of scene components.
  53141. */
  53142. readonly name: string;
  53143. /**
  53144. * The scene the component belongs to.
  53145. */
  53146. scene: Scene;
  53147. /**
  53148. * Creates a new instance of the component for the given scene
  53149. * @param scene Defines the scene to register the component in
  53150. */
  53151. constructor(scene: Scene);
  53152. /**
  53153. * Registers the component in a given scene
  53154. */
  53155. register(): void;
  53156. /**
  53157. * Rebuilds the elements related to this component in case of
  53158. * context lost for instance.
  53159. */
  53160. rebuild(): void;
  53161. /**
  53162. * Disposes the component and the associated ressources
  53163. */
  53164. dispose(): void;
  53165. private _gatherRenderTargets;
  53166. }
  53167. }
  53168. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53169. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53170. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53171. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53172. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53173. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53174. }
  53175. declare module "babylonjs/Shaders/tonemap.fragment" {
  53176. /** @hidden */
  53177. export var tonemapPixelShader: {
  53178. name: string;
  53179. shader: string;
  53180. };
  53181. }
  53182. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53183. import { Camera } from "babylonjs/Cameras/camera";
  53184. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53185. import "babylonjs/Shaders/tonemap.fragment";
  53186. import { Engine } from "babylonjs/Engines/engine";
  53187. /** Defines operator used for tonemapping */
  53188. export enum TonemappingOperator {
  53189. /** Hable */
  53190. Hable = 0,
  53191. /** Reinhard */
  53192. Reinhard = 1,
  53193. /** HejiDawson */
  53194. HejiDawson = 2,
  53195. /** Photographic */
  53196. Photographic = 3
  53197. }
  53198. /**
  53199. * Defines a post process to apply tone mapping
  53200. */
  53201. export class TonemapPostProcess extends PostProcess {
  53202. private _operator;
  53203. /** Defines the required exposure adjustement */
  53204. exposureAdjustment: number;
  53205. /**
  53206. * Creates a new TonemapPostProcess
  53207. * @param name defines the name of the postprocess
  53208. * @param _operator defines the operator to use
  53209. * @param exposureAdjustment defines the required exposure adjustement
  53210. * @param camera defines the camera to use (can be null)
  53211. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53212. * @param engine defines the hosting engine (can be ignore if camera is set)
  53213. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53214. */
  53215. constructor(name: string, _operator: TonemappingOperator,
  53216. /** Defines the required exposure adjustement */
  53217. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53218. }
  53219. }
  53220. declare module "babylonjs/Shaders/depth.vertex" {
  53221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53222. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53225. /** @hidden */
  53226. export var depthVertexShader: {
  53227. name: string;
  53228. shader: string;
  53229. };
  53230. }
  53231. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53232. /** @hidden */
  53233. export var volumetricLightScatteringPixelShader: {
  53234. name: string;
  53235. shader: string;
  53236. };
  53237. }
  53238. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53239. /** @hidden */
  53240. export var volumetricLightScatteringPassPixelShader: {
  53241. name: string;
  53242. shader: string;
  53243. };
  53244. }
  53245. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53246. import { Vector3 } from "babylonjs/Maths/math";
  53247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53248. import { Mesh } from "babylonjs/Meshes/mesh";
  53249. import { Camera } from "babylonjs/Cameras/camera";
  53250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53252. import { Scene } from "babylonjs/scene";
  53253. import "babylonjs/Shaders/depth.vertex";
  53254. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53255. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53256. import { Engine } from "babylonjs/Engines/engine";
  53257. /**
  53258. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53259. */
  53260. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53261. private _volumetricLightScatteringPass;
  53262. private _volumetricLightScatteringRTT;
  53263. private _viewPort;
  53264. private _screenCoordinates;
  53265. private _cachedDefines;
  53266. /**
  53267. * If not undefined, the mesh position is computed from the attached node position
  53268. */
  53269. attachedNode: {
  53270. position: Vector3;
  53271. };
  53272. /**
  53273. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53274. */
  53275. customMeshPosition: Vector3;
  53276. /**
  53277. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53278. */
  53279. useCustomMeshPosition: boolean;
  53280. /**
  53281. * If the post-process should inverse the light scattering direction
  53282. */
  53283. invert: boolean;
  53284. /**
  53285. * The internal mesh used by the post-process
  53286. */
  53287. mesh: Mesh;
  53288. /**
  53289. * @hidden
  53290. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53291. */
  53292. useDiffuseColor: boolean;
  53293. /**
  53294. * Array containing the excluded meshes not rendered in the internal pass
  53295. */
  53296. excludedMeshes: AbstractMesh[];
  53297. /**
  53298. * Controls the overall intensity of the post-process
  53299. */
  53300. exposure: number;
  53301. /**
  53302. * Dissipates each sample's contribution in range [0, 1]
  53303. */
  53304. decay: number;
  53305. /**
  53306. * Controls the overall intensity of each sample
  53307. */
  53308. weight: number;
  53309. /**
  53310. * Controls the density of each sample
  53311. */
  53312. density: number;
  53313. /**
  53314. * @constructor
  53315. * @param name The post-process name
  53316. * @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)
  53317. * @param camera The camera that the post-process will be attached to
  53318. * @param mesh The mesh used to create the light scattering
  53319. * @param samples The post-process quality, default 100
  53320. * @param samplingModeThe post-process filtering mode
  53321. * @param engine The babylon engine
  53322. * @param reusable If the post-process is reusable
  53323. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53324. */
  53325. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53326. /**
  53327. * Returns the string "VolumetricLightScatteringPostProcess"
  53328. * @returns "VolumetricLightScatteringPostProcess"
  53329. */
  53330. getClassName(): string;
  53331. private _isReady;
  53332. /**
  53333. * Sets the new light position for light scattering effect
  53334. * @param position The new custom light position
  53335. */
  53336. setCustomMeshPosition(position: Vector3): void;
  53337. /**
  53338. * Returns the light position for light scattering effect
  53339. * @return Vector3 The custom light position
  53340. */
  53341. getCustomMeshPosition(): Vector3;
  53342. /**
  53343. * Disposes the internal assets and detaches the post-process from the camera
  53344. */
  53345. dispose(camera: Camera): void;
  53346. /**
  53347. * Returns the render target texture used by the post-process
  53348. * @return the render target texture used by the post-process
  53349. */
  53350. getPass(): RenderTargetTexture;
  53351. private _meshExcluded;
  53352. private _createPass;
  53353. private _updateMeshScreenCoordinates;
  53354. /**
  53355. * Creates a default mesh for the Volumeric Light Scattering post-process
  53356. * @param name The mesh name
  53357. * @param scene The scene where to create the mesh
  53358. * @return the default mesh
  53359. */
  53360. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53361. }
  53362. }
  53363. declare module "babylonjs/PostProcesses/index" {
  53364. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53365. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53366. export * from "babylonjs/PostProcesses/bloomEffect";
  53367. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53368. export * from "babylonjs/PostProcesses/blurPostProcess";
  53369. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53370. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53371. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53372. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53373. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53374. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53375. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53376. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53377. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53378. export * from "babylonjs/PostProcesses/filterPostProcess";
  53379. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53380. export * from "babylonjs/PostProcesses/grainPostProcess";
  53381. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53382. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53383. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53384. export * from "babylonjs/PostProcesses/passPostProcess";
  53385. export * from "babylonjs/PostProcesses/postProcess";
  53386. export * from "babylonjs/PostProcesses/postProcessManager";
  53387. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53388. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53389. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53390. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53391. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53392. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53393. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53394. }
  53395. declare module "babylonjs/Probes/index" {
  53396. export * from "babylonjs/Probes/reflectionProbe";
  53397. }
  53398. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53399. import { Scene } from "babylonjs/scene";
  53400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53401. import { Color3 } from "babylonjs/Maths/math";
  53402. import { SmartArray } from "babylonjs/Misc/smartArray";
  53403. import { ISceneComponent } from "babylonjs/sceneComponent";
  53404. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53405. import "babylonjs/Shaders/color.fragment";
  53406. import "babylonjs/Shaders/color.vertex";
  53407. module "babylonjs/scene" {
  53408. interface Scene {
  53409. /** @hidden (Backing field) */
  53410. _boundingBoxRenderer: BoundingBoxRenderer;
  53411. /** @hidden (Backing field) */
  53412. _forceShowBoundingBoxes: boolean;
  53413. /**
  53414. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53415. */
  53416. forceShowBoundingBoxes: boolean;
  53417. /**
  53418. * Gets the bounding box renderer associated with the scene
  53419. * @returns a BoundingBoxRenderer
  53420. */
  53421. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53422. }
  53423. }
  53424. module "babylonjs/Meshes/abstractMesh" {
  53425. interface AbstractMesh {
  53426. /** @hidden (Backing field) */
  53427. _showBoundingBox: boolean;
  53428. /**
  53429. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53430. */
  53431. showBoundingBox: boolean;
  53432. }
  53433. }
  53434. /**
  53435. * Component responsible of rendering the bounding box of the meshes in a scene.
  53436. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53437. */
  53438. export class BoundingBoxRenderer implements ISceneComponent {
  53439. /**
  53440. * The component name helpfull to identify the component in the list of scene components.
  53441. */
  53442. readonly name: string;
  53443. /**
  53444. * The scene the component belongs to.
  53445. */
  53446. scene: Scene;
  53447. /**
  53448. * Color of the bounding box lines placed in front of an object
  53449. */
  53450. frontColor: Color3;
  53451. /**
  53452. * Color of the bounding box lines placed behind an object
  53453. */
  53454. backColor: Color3;
  53455. /**
  53456. * Defines if the renderer should show the back lines or not
  53457. */
  53458. showBackLines: boolean;
  53459. /**
  53460. * @hidden
  53461. */
  53462. renderList: SmartArray<BoundingBox>;
  53463. private _colorShader;
  53464. private _vertexBuffers;
  53465. private _indexBuffer;
  53466. /**
  53467. * Instantiates a new bounding box renderer in a scene.
  53468. * @param scene the scene the renderer renders in
  53469. */
  53470. constructor(scene: Scene);
  53471. /**
  53472. * Registers the component in a given scene
  53473. */
  53474. register(): void;
  53475. private _evaluateSubMesh;
  53476. private _activeMesh;
  53477. private _prepareRessources;
  53478. private _createIndexBuffer;
  53479. /**
  53480. * Rebuilds the elements related to this component in case of
  53481. * context lost for instance.
  53482. */
  53483. rebuild(): void;
  53484. /**
  53485. * @hidden
  53486. */
  53487. reset(): void;
  53488. /**
  53489. * Render the bounding boxes of a specific rendering group
  53490. * @param renderingGroupId defines the rendering group to render
  53491. */
  53492. render(renderingGroupId: number): void;
  53493. /**
  53494. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53495. * @param mesh Define the mesh to render the occlusion bounding box for
  53496. */
  53497. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53498. /**
  53499. * Dispose and release the resources attached to this renderer.
  53500. */
  53501. dispose(): void;
  53502. }
  53503. }
  53504. declare module "babylonjs/Shaders/depth.fragment" {
  53505. /** @hidden */
  53506. export var depthPixelShader: {
  53507. name: string;
  53508. shader: string;
  53509. };
  53510. }
  53511. declare module "babylonjs/Rendering/depthRenderer" {
  53512. import { Nullable } from "babylonjs/types";
  53513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53514. import { Scene } from "babylonjs/scene";
  53515. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53516. import { Camera } from "babylonjs/Cameras/camera";
  53517. import "babylonjs/Shaders/depth.fragment";
  53518. import "babylonjs/Shaders/depth.vertex";
  53519. /**
  53520. * This represents a depth renderer in Babylon.
  53521. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53522. */
  53523. export class DepthRenderer {
  53524. private _scene;
  53525. private _depthMap;
  53526. private _effect;
  53527. private _cachedDefines;
  53528. private _camera;
  53529. /**
  53530. * Specifiess that the depth renderer will only be used within
  53531. * the camera it is created for.
  53532. * This can help forcing its rendering during the camera processing.
  53533. */
  53534. useOnlyInActiveCamera: boolean;
  53535. /** @hidden */
  53536. static _SceneComponentInitialization: (scene: Scene) => void;
  53537. /**
  53538. * Instantiates a depth renderer
  53539. * @param scene The scene the renderer belongs to
  53540. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53541. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53542. */
  53543. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53544. /**
  53545. * Creates the depth rendering effect and checks if the effect is ready.
  53546. * @param subMesh The submesh to be used to render the depth map of
  53547. * @param useInstances If multiple world instances should be used
  53548. * @returns if the depth renderer is ready to render the depth map
  53549. */
  53550. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53551. /**
  53552. * Gets the texture which the depth map will be written to.
  53553. * @returns The depth map texture
  53554. */
  53555. getDepthMap(): RenderTargetTexture;
  53556. /**
  53557. * Disposes of the depth renderer.
  53558. */
  53559. dispose(): void;
  53560. }
  53561. }
  53562. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  53563. import { Nullable } from "babylonjs/types";
  53564. import { Scene } from "babylonjs/scene";
  53565. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  53566. import { Camera } from "babylonjs/Cameras/camera";
  53567. import { ISceneComponent } from "babylonjs/sceneComponent";
  53568. module "babylonjs/scene" {
  53569. interface Scene {
  53570. /** @hidden (Backing field) */
  53571. _depthRenderer: {
  53572. [id: string]: DepthRenderer;
  53573. };
  53574. /**
  53575. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53576. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53577. * @returns the created depth renderer
  53578. */
  53579. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53580. /**
  53581. * Disables a depth renderer for a given camera
  53582. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53583. */
  53584. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53585. }
  53586. }
  53587. /**
  53588. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53589. * in several rendering techniques.
  53590. */
  53591. export class DepthRendererSceneComponent implements ISceneComponent {
  53592. /**
  53593. * The component name helpfull to identify the component in the list of scene components.
  53594. */
  53595. readonly name: string;
  53596. /**
  53597. * The scene the component belongs to.
  53598. */
  53599. scene: Scene;
  53600. /**
  53601. * Creates a new instance of the component for the given scene
  53602. * @param scene Defines the scene to register the component in
  53603. */
  53604. constructor(scene: Scene);
  53605. /**
  53606. * Registers the component in a given scene
  53607. */
  53608. register(): void;
  53609. /**
  53610. * Rebuilds the elements related to this component in case of
  53611. * context lost for instance.
  53612. */
  53613. rebuild(): void;
  53614. /**
  53615. * Disposes the component and the associated ressources
  53616. */
  53617. dispose(): void;
  53618. private _gatherRenderTargets;
  53619. private _gatherActiveCameraRenderTargets;
  53620. }
  53621. }
  53622. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53623. import { Nullable } from "babylonjs/types";
  53624. import { Scene } from "babylonjs/scene";
  53625. import { ISceneComponent } from "babylonjs/sceneComponent";
  53626. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53627. module "babylonjs/scene" {
  53628. interface Scene {
  53629. /** @hidden (Backing field) */
  53630. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53631. /**
  53632. * Gets or Sets the current geometry buffer associated to the scene.
  53633. */
  53634. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53635. /**
  53636. * Enables a GeometryBufferRender and associates it with the scene
  53637. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53638. * @returns the GeometryBufferRenderer
  53639. */
  53640. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53641. /**
  53642. * Disables the GeometryBufferRender associated with the scene
  53643. */
  53644. disableGeometryBufferRenderer(): void;
  53645. }
  53646. }
  53647. /**
  53648. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53649. * in several rendering techniques.
  53650. */
  53651. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53652. /**
  53653. * The component name helpful to identify the component in the list of scene components.
  53654. */
  53655. readonly name: string;
  53656. /**
  53657. * The scene the component belongs to.
  53658. */
  53659. scene: Scene;
  53660. /**
  53661. * Creates a new instance of the component for the given scene
  53662. * @param scene Defines the scene to register the component in
  53663. */
  53664. constructor(scene: Scene);
  53665. /**
  53666. * Registers the component in a given scene
  53667. */
  53668. register(): void;
  53669. /**
  53670. * Rebuilds the elements related to this component in case of
  53671. * context lost for instance.
  53672. */
  53673. rebuild(): void;
  53674. /**
  53675. * Disposes the component and the associated ressources
  53676. */
  53677. dispose(): void;
  53678. private _gatherRenderTargets;
  53679. }
  53680. }
  53681. declare module "babylonjs/Shaders/outline.fragment" {
  53682. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53683. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53684. /** @hidden */
  53685. export var outlinePixelShader: {
  53686. name: string;
  53687. shader: string;
  53688. };
  53689. }
  53690. declare module "babylonjs/Shaders/outline.vertex" {
  53691. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53692. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53693. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53694. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53695. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53696. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53697. /** @hidden */
  53698. export var outlineVertexShader: {
  53699. name: string;
  53700. shader: string;
  53701. };
  53702. }
  53703. declare module "babylonjs/Rendering/outlineRenderer" {
  53704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53705. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  53706. import { Scene } from "babylonjs/scene";
  53707. import { ISceneComponent } from "babylonjs/sceneComponent";
  53708. import "babylonjs/Shaders/outline.fragment";
  53709. import "babylonjs/Shaders/outline.vertex";
  53710. module "babylonjs/scene" {
  53711. interface Scene {
  53712. /** @hidden */
  53713. _outlineRenderer: OutlineRenderer;
  53714. /**
  53715. * Gets the outline renderer associated with the scene
  53716. * @returns a OutlineRenderer
  53717. */
  53718. getOutlineRenderer(): OutlineRenderer;
  53719. }
  53720. }
  53721. module "babylonjs/Meshes/abstractMesh" {
  53722. interface AbstractMesh {
  53723. /** @hidden (Backing field) */
  53724. _renderOutline: boolean;
  53725. /**
  53726. * Gets or sets a boolean indicating if the outline must be rendered as well
  53727. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53728. */
  53729. renderOutline: boolean;
  53730. /** @hidden (Backing field) */
  53731. _renderOverlay: boolean;
  53732. /**
  53733. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53734. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53735. */
  53736. renderOverlay: boolean;
  53737. }
  53738. }
  53739. /**
  53740. * This class is responsible to draw bothe outline/overlay of meshes.
  53741. * It should not be used directly but through the available method on mesh.
  53742. */
  53743. export class OutlineRenderer implements ISceneComponent {
  53744. /**
  53745. * The name of the component. Each component must have a unique name.
  53746. */
  53747. name: string;
  53748. /**
  53749. * The scene the component belongs to.
  53750. */
  53751. scene: Scene;
  53752. /**
  53753. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53754. */
  53755. zOffset: number;
  53756. private _engine;
  53757. private _effect;
  53758. private _cachedDefines;
  53759. private _savedDepthWrite;
  53760. /**
  53761. * Instantiates a new outline renderer. (There could be only one per scene).
  53762. * @param scene Defines the scene it belongs to
  53763. */
  53764. constructor(scene: Scene);
  53765. /**
  53766. * Register the component to one instance of a scene.
  53767. */
  53768. register(): void;
  53769. /**
  53770. * Rebuilds the elements related to this component in case of
  53771. * context lost for instance.
  53772. */
  53773. rebuild(): void;
  53774. /**
  53775. * Disposes the component and the associated ressources.
  53776. */
  53777. dispose(): void;
  53778. /**
  53779. * Renders the outline in the canvas.
  53780. * @param subMesh Defines the sumesh to render
  53781. * @param batch Defines the batch of meshes in case of instances
  53782. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53783. */
  53784. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53785. /**
  53786. * Returns whether or not the outline renderer is ready for a given submesh.
  53787. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53788. * @param subMesh Defines the submesh to check readyness for
  53789. * @param useInstances Defines wheter wee are trying to render instances or not
  53790. * @returns true if ready otherwise false
  53791. */
  53792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53793. private _beforeRenderingMesh;
  53794. private _afterRenderingMesh;
  53795. }
  53796. }
  53797. declare module "babylonjs/Rendering/index" {
  53798. export * from "babylonjs/Rendering/boundingBoxRenderer";
  53799. export * from "babylonjs/Rendering/depthRenderer";
  53800. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  53801. export * from "babylonjs/Rendering/edgesRenderer";
  53802. export * from "babylonjs/Rendering/geometryBufferRenderer";
  53803. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53804. export * from "babylonjs/Rendering/outlineRenderer";
  53805. export * from "babylonjs/Rendering/renderingGroup";
  53806. export * from "babylonjs/Rendering/renderingManager";
  53807. export * from "babylonjs/Rendering/utilityLayerRenderer";
  53808. }
  53809. declare module "babylonjs/Sprites/index" {
  53810. export * from "babylonjs/Sprites/sprite";
  53811. export * from "babylonjs/Sprites/spriteManager";
  53812. export * from "babylonjs/Sprites/spriteSceneComponent";
  53813. }
  53814. declare module "babylonjs/Misc/assetsManager" {
  53815. import { Scene } from "babylonjs/scene";
  53816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53817. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53818. import { Skeleton } from "babylonjs/Bones/skeleton";
  53819. import { Observable } from "babylonjs/Misc/observable";
  53820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53821. import { Texture } from "babylonjs/Materials/Textures/texture";
  53822. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53823. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  53824. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53825. /**
  53826. * Defines the list of states available for a task inside a AssetsManager
  53827. */
  53828. export enum AssetTaskState {
  53829. /**
  53830. * Initialization
  53831. */
  53832. INIT = 0,
  53833. /**
  53834. * Running
  53835. */
  53836. RUNNING = 1,
  53837. /**
  53838. * Done
  53839. */
  53840. DONE = 2,
  53841. /**
  53842. * Error
  53843. */
  53844. ERROR = 3
  53845. }
  53846. /**
  53847. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53848. */
  53849. export abstract class AbstractAssetTask {
  53850. /**
  53851. * Task name
  53852. */ name: string;
  53853. /**
  53854. * Callback called when the task is successful
  53855. */
  53856. onSuccess: (task: any) => void;
  53857. /**
  53858. * Callback called when the task is not successful
  53859. */
  53860. onError: (task: any, message?: string, exception?: any) => void;
  53861. /**
  53862. * Creates a new AssetsManager
  53863. * @param name defines the name of the task
  53864. */
  53865. constructor(
  53866. /**
  53867. * Task name
  53868. */ name: string);
  53869. private _isCompleted;
  53870. private _taskState;
  53871. private _errorObject;
  53872. /**
  53873. * Get if the task is completed
  53874. */
  53875. readonly isCompleted: boolean;
  53876. /**
  53877. * Gets the current state of the task
  53878. */
  53879. readonly taskState: AssetTaskState;
  53880. /**
  53881. * Gets the current error object (if task is in error)
  53882. */
  53883. readonly errorObject: {
  53884. message?: string;
  53885. exception?: any;
  53886. };
  53887. /**
  53888. * Internal only
  53889. * @hidden
  53890. */
  53891. _setErrorObject(message?: string, exception?: any): void;
  53892. /**
  53893. * Execute the current task
  53894. * @param scene defines the scene where you want your assets to be loaded
  53895. * @param onSuccess is a callback called when the task is successfully executed
  53896. * @param onError is a callback called if an error occurs
  53897. */
  53898. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53899. /**
  53900. * Execute the current task
  53901. * @param scene defines the scene where you want your assets to be loaded
  53902. * @param onSuccess is a callback called when the task is successfully executed
  53903. * @param onError is a callback called if an error occurs
  53904. */
  53905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53906. /**
  53907. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53908. * This can be used with failed tasks that have the reason for failure fixed.
  53909. */
  53910. reset(): void;
  53911. private onErrorCallback;
  53912. private onDoneCallback;
  53913. }
  53914. /**
  53915. * Define the interface used by progress events raised during assets loading
  53916. */
  53917. export interface IAssetsProgressEvent {
  53918. /**
  53919. * Defines the number of remaining tasks to process
  53920. */
  53921. remainingCount: number;
  53922. /**
  53923. * Defines the total number of tasks
  53924. */
  53925. totalCount: number;
  53926. /**
  53927. * Defines the task that was just processed
  53928. */
  53929. task: AbstractAssetTask;
  53930. }
  53931. /**
  53932. * Class used to share progress information about assets loading
  53933. */
  53934. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53935. /**
  53936. * Defines the number of remaining tasks to process
  53937. */
  53938. remainingCount: number;
  53939. /**
  53940. * Defines the total number of tasks
  53941. */
  53942. totalCount: number;
  53943. /**
  53944. * Defines the task that was just processed
  53945. */
  53946. task: AbstractAssetTask;
  53947. /**
  53948. * Creates a AssetsProgressEvent
  53949. * @param remainingCount defines the number of remaining tasks to process
  53950. * @param totalCount defines the total number of tasks
  53951. * @param task defines the task that was just processed
  53952. */
  53953. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53954. }
  53955. /**
  53956. * Define a task used by AssetsManager to load meshes
  53957. */
  53958. export class MeshAssetTask extends AbstractAssetTask {
  53959. /**
  53960. * Defines the name of the task
  53961. */
  53962. name: string;
  53963. /**
  53964. * Defines the list of mesh's names you want to load
  53965. */
  53966. meshesNames: any;
  53967. /**
  53968. * Defines the root url to use as a base to load your meshes and associated resources
  53969. */
  53970. rootUrl: string;
  53971. /**
  53972. * Defines the filename of the scene to load from
  53973. */
  53974. sceneFilename: string;
  53975. /**
  53976. * Gets the list of loaded meshes
  53977. */
  53978. loadedMeshes: Array<AbstractMesh>;
  53979. /**
  53980. * Gets the list of loaded particle systems
  53981. */
  53982. loadedParticleSystems: Array<IParticleSystem>;
  53983. /**
  53984. * Gets the list of loaded skeletons
  53985. */
  53986. loadedSkeletons: Array<Skeleton>;
  53987. /**
  53988. * Gets the list of loaded animation groups
  53989. */
  53990. loadedAnimationGroups: Array<AnimationGroup>;
  53991. /**
  53992. * Callback called when the task is successful
  53993. */
  53994. onSuccess: (task: MeshAssetTask) => void;
  53995. /**
  53996. * Callback called when the task is successful
  53997. */
  53998. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53999. /**
  54000. * Creates a new MeshAssetTask
  54001. * @param name defines the name of the task
  54002. * @param meshesNames defines the list of mesh's names you want to load
  54003. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54004. * @param sceneFilename defines the filename of the scene to load from
  54005. */
  54006. constructor(
  54007. /**
  54008. * Defines the name of the task
  54009. */
  54010. name: string,
  54011. /**
  54012. * Defines the list of mesh's names you want to load
  54013. */
  54014. meshesNames: any,
  54015. /**
  54016. * Defines the root url to use as a base to load your meshes and associated resources
  54017. */
  54018. rootUrl: string,
  54019. /**
  54020. * Defines the filename of the scene to load from
  54021. */
  54022. sceneFilename: string);
  54023. /**
  54024. * Execute the current task
  54025. * @param scene defines the scene where you want your assets to be loaded
  54026. * @param onSuccess is a callback called when the task is successfully executed
  54027. * @param onError is a callback called if an error occurs
  54028. */
  54029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54030. }
  54031. /**
  54032. * Define a task used by AssetsManager to load text content
  54033. */
  54034. export class TextFileAssetTask extends AbstractAssetTask {
  54035. /**
  54036. * Defines the name of the task
  54037. */
  54038. name: string;
  54039. /**
  54040. * Defines the location of the file to load
  54041. */
  54042. url: string;
  54043. /**
  54044. * Gets the loaded text string
  54045. */
  54046. text: string;
  54047. /**
  54048. * Callback called when the task is successful
  54049. */
  54050. onSuccess: (task: TextFileAssetTask) => void;
  54051. /**
  54052. * Callback called when the task is successful
  54053. */
  54054. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54055. /**
  54056. * Creates a new TextFileAssetTask object
  54057. * @param name defines the name of the task
  54058. * @param url defines the location of the file to load
  54059. */
  54060. constructor(
  54061. /**
  54062. * Defines the name of the task
  54063. */
  54064. name: string,
  54065. /**
  54066. * Defines the location of the file to load
  54067. */
  54068. url: string);
  54069. /**
  54070. * Execute the current task
  54071. * @param scene defines the scene where you want your assets to be loaded
  54072. * @param onSuccess is a callback called when the task is successfully executed
  54073. * @param onError is a callback called if an error occurs
  54074. */
  54075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54076. }
  54077. /**
  54078. * Define a task used by AssetsManager to load binary data
  54079. */
  54080. export class BinaryFileAssetTask extends AbstractAssetTask {
  54081. /**
  54082. * Defines the name of the task
  54083. */
  54084. name: string;
  54085. /**
  54086. * Defines the location of the file to load
  54087. */
  54088. url: string;
  54089. /**
  54090. * Gets the lodaded data (as an array buffer)
  54091. */
  54092. data: ArrayBuffer;
  54093. /**
  54094. * Callback called when the task is successful
  54095. */
  54096. onSuccess: (task: BinaryFileAssetTask) => void;
  54097. /**
  54098. * Callback called when the task is successful
  54099. */
  54100. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54101. /**
  54102. * Creates a new BinaryFileAssetTask object
  54103. * @param name defines the name of the new task
  54104. * @param url defines the location of the file to load
  54105. */
  54106. constructor(
  54107. /**
  54108. * Defines the name of the task
  54109. */
  54110. name: string,
  54111. /**
  54112. * Defines the location of the file to load
  54113. */
  54114. url: string);
  54115. /**
  54116. * Execute the current task
  54117. * @param scene defines the scene where you want your assets to be loaded
  54118. * @param onSuccess is a callback called when the task is successfully executed
  54119. * @param onError is a callback called if an error occurs
  54120. */
  54121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54122. }
  54123. /**
  54124. * Define a task used by AssetsManager to load images
  54125. */
  54126. export class ImageAssetTask extends AbstractAssetTask {
  54127. /**
  54128. * Defines the name of the task
  54129. */
  54130. name: string;
  54131. /**
  54132. * Defines the location of the image to load
  54133. */
  54134. url: string;
  54135. /**
  54136. * Gets the loaded images
  54137. */
  54138. image: HTMLImageElement;
  54139. /**
  54140. * Callback called when the task is successful
  54141. */
  54142. onSuccess: (task: ImageAssetTask) => void;
  54143. /**
  54144. * Callback called when the task is successful
  54145. */
  54146. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54147. /**
  54148. * Creates a new ImageAssetTask
  54149. * @param name defines the name of the task
  54150. * @param url defines the location of the image to load
  54151. */
  54152. constructor(
  54153. /**
  54154. * Defines the name of the task
  54155. */
  54156. name: string,
  54157. /**
  54158. * Defines the location of the image to load
  54159. */
  54160. url: string);
  54161. /**
  54162. * Execute the current task
  54163. * @param scene defines the scene where you want your assets to be loaded
  54164. * @param onSuccess is a callback called when the task is successfully executed
  54165. * @param onError is a callback called if an error occurs
  54166. */
  54167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54168. }
  54169. /**
  54170. * Defines the interface used by texture loading tasks
  54171. */
  54172. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54173. /**
  54174. * Gets the loaded texture
  54175. */
  54176. texture: TEX;
  54177. }
  54178. /**
  54179. * Define a task used by AssetsManager to load 2D textures
  54180. */
  54181. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54182. /**
  54183. * Defines the name of the task
  54184. */
  54185. name: string;
  54186. /**
  54187. * Defines the location of the file to load
  54188. */
  54189. url: string;
  54190. /**
  54191. * Defines if mipmap should not be generated (default is false)
  54192. */
  54193. noMipmap?: boolean | undefined;
  54194. /**
  54195. * Defines if texture must be inverted on Y axis (default is false)
  54196. */
  54197. invertY?: boolean | undefined;
  54198. /**
  54199. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54200. */
  54201. samplingMode: number;
  54202. /**
  54203. * Gets the loaded texture
  54204. */
  54205. texture: Texture;
  54206. /**
  54207. * Callback called when the task is successful
  54208. */
  54209. onSuccess: (task: TextureAssetTask) => void;
  54210. /**
  54211. * Callback called when the task is successful
  54212. */
  54213. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54214. /**
  54215. * Creates a new TextureAssetTask object
  54216. * @param name defines the name of the task
  54217. * @param url defines the location of the file to load
  54218. * @param noMipmap defines if mipmap should not be generated (default is false)
  54219. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54220. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54221. */
  54222. constructor(
  54223. /**
  54224. * Defines the name of the task
  54225. */
  54226. name: string,
  54227. /**
  54228. * Defines the location of the file to load
  54229. */
  54230. url: string,
  54231. /**
  54232. * Defines if mipmap should not be generated (default is false)
  54233. */
  54234. noMipmap?: boolean | undefined,
  54235. /**
  54236. * Defines if texture must be inverted on Y axis (default is false)
  54237. */
  54238. invertY?: boolean | undefined,
  54239. /**
  54240. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54241. */
  54242. samplingMode?: number);
  54243. /**
  54244. * Execute the current task
  54245. * @param scene defines the scene where you want your assets to be loaded
  54246. * @param onSuccess is a callback called when the task is successfully executed
  54247. * @param onError is a callback called if an error occurs
  54248. */
  54249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54250. }
  54251. /**
  54252. * Define a task used by AssetsManager to load cube textures
  54253. */
  54254. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54255. /**
  54256. * Defines the name of the task
  54257. */
  54258. name: string;
  54259. /**
  54260. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54261. */
  54262. url: string;
  54263. /**
  54264. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54265. */
  54266. extensions?: string[] | undefined;
  54267. /**
  54268. * Defines if mipmaps should not be generated (default is false)
  54269. */
  54270. noMipmap?: boolean | undefined;
  54271. /**
  54272. * Defines the explicit list of files (undefined by default)
  54273. */
  54274. files?: string[] | undefined;
  54275. /**
  54276. * Gets the loaded texture
  54277. */
  54278. texture: CubeTexture;
  54279. /**
  54280. * Callback called when the task is successful
  54281. */
  54282. onSuccess: (task: CubeTextureAssetTask) => void;
  54283. /**
  54284. * Callback called when the task is successful
  54285. */
  54286. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54287. /**
  54288. * Creates a new CubeTextureAssetTask
  54289. * @param name defines the name of the task
  54290. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54291. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54292. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54293. * @param files defines the explicit list of files (undefined by default)
  54294. */
  54295. constructor(
  54296. /**
  54297. * Defines the name of the task
  54298. */
  54299. name: string,
  54300. /**
  54301. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54302. */
  54303. url: string,
  54304. /**
  54305. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54306. */
  54307. extensions?: string[] | undefined,
  54308. /**
  54309. * Defines if mipmaps should not be generated (default is false)
  54310. */
  54311. noMipmap?: boolean | undefined,
  54312. /**
  54313. * Defines the explicit list of files (undefined by default)
  54314. */
  54315. files?: string[] | undefined);
  54316. /**
  54317. * Execute the current task
  54318. * @param scene defines the scene where you want your assets to be loaded
  54319. * @param onSuccess is a callback called when the task is successfully executed
  54320. * @param onError is a callback called if an error occurs
  54321. */
  54322. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54323. }
  54324. /**
  54325. * Define a task used by AssetsManager to load HDR cube textures
  54326. */
  54327. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54328. /**
  54329. * Defines the name of the task
  54330. */
  54331. name: string;
  54332. /**
  54333. * Defines the location of the file to load
  54334. */
  54335. url: string;
  54336. /**
  54337. * Defines the desired size (the more it increases the longer the generation will be)
  54338. */
  54339. size: number;
  54340. /**
  54341. * Defines if mipmaps should not be generated (default is false)
  54342. */
  54343. noMipmap: boolean;
  54344. /**
  54345. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54346. */
  54347. generateHarmonics: boolean;
  54348. /**
  54349. * 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)
  54350. */
  54351. gammaSpace: boolean;
  54352. /**
  54353. * Internal Use Only
  54354. */
  54355. reserved: boolean;
  54356. /**
  54357. * Gets the loaded texture
  54358. */
  54359. texture: HDRCubeTexture;
  54360. /**
  54361. * Callback called when the task is successful
  54362. */
  54363. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54364. /**
  54365. * Callback called when the task is successful
  54366. */
  54367. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54368. /**
  54369. * Creates a new HDRCubeTextureAssetTask object
  54370. * @param name defines the name of the task
  54371. * @param url defines the location of the file to load
  54372. * @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.
  54373. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54374. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54375. * @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)
  54376. * @param reserved Internal use only
  54377. */
  54378. constructor(
  54379. /**
  54380. * Defines the name of the task
  54381. */
  54382. name: string,
  54383. /**
  54384. * Defines the location of the file to load
  54385. */
  54386. url: string,
  54387. /**
  54388. * Defines the desired size (the more it increases the longer the generation will be)
  54389. */
  54390. size: number,
  54391. /**
  54392. * Defines if mipmaps should not be generated (default is false)
  54393. */
  54394. noMipmap?: boolean,
  54395. /**
  54396. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54397. */
  54398. generateHarmonics?: boolean,
  54399. /**
  54400. * 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)
  54401. */
  54402. gammaSpace?: boolean,
  54403. /**
  54404. * Internal Use Only
  54405. */
  54406. reserved?: boolean);
  54407. /**
  54408. * Execute the current task
  54409. * @param scene defines the scene where you want your assets to be loaded
  54410. * @param onSuccess is a callback called when the task is successfully executed
  54411. * @param onError is a callback called if an error occurs
  54412. */
  54413. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54414. }
  54415. /**
  54416. * This class can be used to easily import assets into a scene
  54417. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54418. */
  54419. export class AssetsManager {
  54420. private _scene;
  54421. private _isLoading;
  54422. protected _tasks: AbstractAssetTask[];
  54423. protected _waitingTasksCount: number;
  54424. protected _totalTasksCount: number;
  54425. /**
  54426. * Callback called when all tasks are processed
  54427. */
  54428. onFinish: (tasks: AbstractAssetTask[]) => void;
  54429. /**
  54430. * Callback called when a task is successful
  54431. */
  54432. onTaskSuccess: (task: AbstractAssetTask) => void;
  54433. /**
  54434. * Callback called when a task had an error
  54435. */
  54436. onTaskError: (task: AbstractAssetTask) => void;
  54437. /**
  54438. * Callback called when a task is done (whatever the result is)
  54439. */
  54440. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54441. /**
  54442. * Observable called when all tasks are processed
  54443. */
  54444. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54445. /**
  54446. * Observable called when a task had an error
  54447. */
  54448. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54449. /**
  54450. * Observable called when a task is successful
  54451. */
  54452. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54453. /**
  54454. * Observable called when a task is done (whatever the result is)
  54455. */
  54456. onProgressObservable: Observable<IAssetsProgressEvent>;
  54457. /**
  54458. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54459. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54460. */
  54461. useDefaultLoadingScreen: boolean;
  54462. /**
  54463. * Creates a new AssetsManager
  54464. * @param scene defines the scene to work on
  54465. */
  54466. constructor(scene: Scene);
  54467. /**
  54468. * Add a MeshAssetTask to the list of active tasks
  54469. * @param taskName defines the name of the new task
  54470. * @param meshesNames defines the name of meshes to load
  54471. * @param rootUrl defines the root url to use to locate files
  54472. * @param sceneFilename defines the filename of the scene file
  54473. * @returns a new MeshAssetTask object
  54474. */
  54475. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54476. /**
  54477. * Add a TextFileAssetTask to the list of active tasks
  54478. * @param taskName defines the name of the new task
  54479. * @param url defines the url of the file to load
  54480. * @returns a new TextFileAssetTask object
  54481. */
  54482. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54483. /**
  54484. * Add a BinaryFileAssetTask to the list of active tasks
  54485. * @param taskName defines the name of the new task
  54486. * @param url defines the url of the file to load
  54487. * @returns a new BinaryFileAssetTask object
  54488. */
  54489. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54490. /**
  54491. * Add a ImageAssetTask to the list of active tasks
  54492. * @param taskName defines the name of the new task
  54493. * @param url defines the url of the file to load
  54494. * @returns a new ImageAssetTask object
  54495. */
  54496. addImageTask(taskName: string, url: string): ImageAssetTask;
  54497. /**
  54498. * Add a TextureAssetTask to the list of active tasks
  54499. * @param taskName defines the name of the new task
  54500. * @param url defines the url of the file to load
  54501. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54502. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54503. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54504. * @returns a new TextureAssetTask object
  54505. */
  54506. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54507. /**
  54508. * Add a CubeTextureAssetTask to the list of active tasks
  54509. * @param taskName defines the name of the new task
  54510. * @param url defines the url of the file to load
  54511. * @param extensions defines the extension to use to load the cube map (can be null)
  54512. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54513. * @param files defines the list of files to load (can be null)
  54514. * @returns a new CubeTextureAssetTask object
  54515. */
  54516. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54517. /**
  54518. *
  54519. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54520. * @param taskName defines the name of the new task
  54521. * @param url defines the url of the file to load
  54522. * @param size defines the size you want for the cubemap (can be null)
  54523. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54524. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54525. * @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)
  54526. * @param reserved Internal use only
  54527. * @returns a new HDRCubeTextureAssetTask object
  54528. */
  54529. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54530. /**
  54531. * Remove a task from the assets manager.
  54532. * @param task the task to remove
  54533. */
  54534. removeTask(task: AbstractAssetTask): void;
  54535. private _decreaseWaitingTasksCount;
  54536. private _runTask;
  54537. /**
  54538. * Reset the AssetsManager and remove all tasks
  54539. * @return the current instance of the AssetsManager
  54540. */
  54541. reset(): AssetsManager;
  54542. /**
  54543. * Start the loading process
  54544. * @return the current instance of the AssetsManager
  54545. */
  54546. load(): AssetsManager;
  54547. }
  54548. }
  54549. declare module "babylonjs/Misc/deferred" {
  54550. /**
  54551. * Wrapper class for promise with external resolve and reject.
  54552. */
  54553. export class Deferred<T> {
  54554. /**
  54555. * The promise associated with this deferred object.
  54556. */
  54557. readonly promise: Promise<T>;
  54558. private _resolve;
  54559. private _reject;
  54560. /**
  54561. * The resolve method of the promise associated with this deferred object.
  54562. */
  54563. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54564. /**
  54565. * The reject method of the promise associated with this deferred object.
  54566. */
  54567. readonly reject: (reason?: any) => void;
  54568. /**
  54569. * Constructor for this deferred object.
  54570. */
  54571. constructor();
  54572. }
  54573. }
  54574. declare module "babylonjs/Misc/filesInput" {
  54575. import { Engine } from "babylonjs/Engines/engine";
  54576. import { Scene } from "babylonjs/scene";
  54577. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  54578. /**
  54579. * Class used to help managing file picking and drag'n'drop
  54580. */
  54581. export class FilesInput {
  54582. /**
  54583. * List of files ready to be loaded
  54584. */
  54585. static readonly FilesToLoad: {
  54586. [key: string]: File;
  54587. };
  54588. /**
  54589. * Callback called when a file is processed
  54590. */
  54591. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54592. private _engine;
  54593. private _currentScene;
  54594. private _sceneLoadedCallback;
  54595. private _progressCallback;
  54596. private _additionalRenderLoopLogicCallback;
  54597. private _textureLoadingCallback;
  54598. private _startingProcessingFilesCallback;
  54599. private _onReloadCallback;
  54600. private _errorCallback;
  54601. private _elementToMonitor;
  54602. private _sceneFileToLoad;
  54603. private _filesToLoad;
  54604. /**
  54605. * Creates a new FilesInput
  54606. * @param engine defines the rendering engine
  54607. * @param scene defines the hosting scene
  54608. * @param sceneLoadedCallback callback called when scene is loaded
  54609. * @param progressCallback callback called to track progress
  54610. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54611. * @param textureLoadingCallback callback called when a texture is loading
  54612. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54613. * @param onReloadCallback callback called when a reload is requested
  54614. * @param errorCallback callback call if an error occurs
  54615. */
  54616. 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);
  54617. private _dragEnterHandler;
  54618. private _dragOverHandler;
  54619. private _dropHandler;
  54620. /**
  54621. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54622. * @param elementToMonitor defines the DOM element to track
  54623. */
  54624. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54625. /**
  54626. * Release all associated resources
  54627. */
  54628. dispose(): void;
  54629. private renderFunction;
  54630. private drag;
  54631. private drop;
  54632. private _traverseFolder;
  54633. private _processFiles;
  54634. /**
  54635. * Load files from a drop event
  54636. * @param event defines the drop event to use as source
  54637. */
  54638. loadFiles(event: any): void;
  54639. private _processReload;
  54640. /**
  54641. * Reload the current scene from the loaded files
  54642. */
  54643. reload(): void;
  54644. }
  54645. }
  54646. declare module "babylonjs/Misc/HighDynamicRange/index" {
  54647. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  54648. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  54649. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54650. }
  54651. declare module "babylonjs/Misc/sceneOptimizer" {
  54652. import { Scene, IDisposable } from "babylonjs/scene";
  54653. import { Observable } from "babylonjs/Misc/observable";
  54654. /**
  54655. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54657. */
  54658. export class SceneOptimization {
  54659. /**
  54660. * Defines the priority of this optimization (0 by default which means first in the list)
  54661. */
  54662. priority: number;
  54663. /**
  54664. * Gets a string describing the action executed by the current optimization
  54665. * @returns description string
  54666. */
  54667. getDescription(): string;
  54668. /**
  54669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54670. * @param scene defines the current scene where to apply this optimization
  54671. * @param optimizer defines the current optimizer
  54672. * @returns true if everything that can be done was applied
  54673. */
  54674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54675. /**
  54676. * Creates the SceneOptimization object
  54677. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54678. * @param desc defines the description associated with the optimization
  54679. */
  54680. constructor(
  54681. /**
  54682. * Defines the priority of this optimization (0 by default which means first in the list)
  54683. */
  54684. priority?: number);
  54685. }
  54686. /**
  54687. * Defines an optimization used to reduce the size of render target textures
  54688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54689. */
  54690. export class TextureOptimization extends SceneOptimization {
  54691. /**
  54692. * Defines the priority of this optimization (0 by default which means first in the list)
  54693. */
  54694. priority: number;
  54695. /**
  54696. * 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
  54697. */
  54698. maximumSize: number;
  54699. /**
  54700. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54701. */
  54702. step: number;
  54703. /**
  54704. * Gets a string describing the action executed by the current optimization
  54705. * @returns description string
  54706. */
  54707. getDescription(): string;
  54708. /**
  54709. * Creates the TextureOptimization object
  54710. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54711. * @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
  54712. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54713. */
  54714. constructor(
  54715. /**
  54716. * Defines the priority of this optimization (0 by default which means first in the list)
  54717. */
  54718. priority?: number,
  54719. /**
  54720. * 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
  54721. */
  54722. maximumSize?: number,
  54723. /**
  54724. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54725. */
  54726. step?: number);
  54727. /**
  54728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54729. * @param scene defines the current scene where to apply this optimization
  54730. * @param optimizer defines the current optimizer
  54731. * @returns true if everything that can be done was applied
  54732. */
  54733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54734. }
  54735. /**
  54736. * Defines an optimization used to increase or decrease the rendering resolution
  54737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54738. */
  54739. export class HardwareScalingOptimization extends SceneOptimization {
  54740. /**
  54741. * Defines the priority of this optimization (0 by default which means first in the list)
  54742. */
  54743. priority: number;
  54744. /**
  54745. * Defines the maximum scale to use (2 by default)
  54746. */
  54747. maximumScale: number;
  54748. /**
  54749. * Defines the step to use between two passes (0.5 by default)
  54750. */
  54751. step: number;
  54752. private _currentScale;
  54753. private _directionOffset;
  54754. /**
  54755. * Gets a string describing the action executed by the current optimization
  54756. * @return description string
  54757. */
  54758. getDescription(): string;
  54759. /**
  54760. * Creates the HardwareScalingOptimization object
  54761. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54762. * @param maximumScale defines the maximum scale to use (2 by default)
  54763. * @param step defines the step to use between two passes (0.5 by default)
  54764. */
  54765. constructor(
  54766. /**
  54767. * Defines the priority of this optimization (0 by default which means first in the list)
  54768. */
  54769. priority?: number,
  54770. /**
  54771. * Defines the maximum scale to use (2 by default)
  54772. */
  54773. maximumScale?: number,
  54774. /**
  54775. * Defines the step to use between two passes (0.5 by default)
  54776. */
  54777. step?: number);
  54778. /**
  54779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54780. * @param scene defines the current scene where to apply this optimization
  54781. * @param optimizer defines the current optimizer
  54782. * @returns true if everything that can be done was applied
  54783. */
  54784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54785. }
  54786. /**
  54787. * Defines an optimization used to remove shadows
  54788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54789. */
  54790. export class ShadowsOptimization extends SceneOptimization {
  54791. /**
  54792. * Gets a string describing the action executed by the current optimization
  54793. * @return description string
  54794. */
  54795. getDescription(): string;
  54796. /**
  54797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54798. * @param scene defines the current scene where to apply this optimization
  54799. * @param optimizer defines the current optimizer
  54800. * @returns true if everything that can be done was applied
  54801. */
  54802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54803. }
  54804. /**
  54805. * Defines an optimization used to turn post-processes off
  54806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54807. */
  54808. export class PostProcessesOptimization extends SceneOptimization {
  54809. /**
  54810. * Gets a string describing the action executed by the current optimization
  54811. * @return description string
  54812. */
  54813. getDescription(): string;
  54814. /**
  54815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54816. * @param scene defines the current scene where to apply this optimization
  54817. * @param optimizer defines the current optimizer
  54818. * @returns true if everything that can be done was applied
  54819. */
  54820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54821. }
  54822. /**
  54823. * Defines an optimization used to turn lens flares off
  54824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54825. */
  54826. export class LensFlaresOptimization extends SceneOptimization {
  54827. /**
  54828. * Gets a string describing the action executed by the current optimization
  54829. * @return description string
  54830. */
  54831. getDescription(): string;
  54832. /**
  54833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54834. * @param scene defines the current scene where to apply this optimization
  54835. * @param optimizer defines the current optimizer
  54836. * @returns true if everything that can be done was applied
  54837. */
  54838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54839. }
  54840. /**
  54841. * Defines an optimization based on user defined callback.
  54842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54843. */
  54844. export class CustomOptimization extends SceneOptimization {
  54845. /**
  54846. * Callback called to apply the custom optimization.
  54847. */
  54848. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54849. /**
  54850. * Callback called to get custom description
  54851. */
  54852. onGetDescription: () => string;
  54853. /**
  54854. * Gets a string describing the action executed by the current optimization
  54855. * @returns description string
  54856. */
  54857. getDescription(): string;
  54858. /**
  54859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54860. * @param scene defines the current scene where to apply this optimization
  54861. * @param optimizer defines the current optimizer
  54862. * @returns true if everything that can be done was applied
  54863. */
  54864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54865. }
  54866. /**
  54867. * Defines an optimization used to turn particles off
  54868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54869. */
  54870. export class ParticlesOptimization extends SceneOptimization {
  54871. /**
  54872. * Gets a string describing the action executed by the current optimization
  54873. * @return description string
  54874. */
  54875. getDescription(): string;
  54876. /**
  54877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54878. * @param scene defines the current scene where to apply this optimization
  54879. * @param optimizer defines the current optimizer
  54880. * @returns true if everything that can be done was applied
  54881. */
  54882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54883. }
  54884. /**
  54885. * Defines an optimization used to turn render targets off
  54886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54887. */
  54888. export class RenderTargetsOptimization extends SceneOptimization {
  54889. /**
  54890. * Gets a string describing the action executed by the current optimization
  54891. * @return description string
  54892. */
  54893. getDescription(): string;
  54894. /**
  54895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54896. * @param scene defines the current scene where to apply this optimization
  54897. * @param optimizer defines the current optimizer
  54898. * @returns true if everything that can be done was applied
  54899. */
  54900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54901. }
  54902. /**
  54903. * Defines an optimization used to merge meshes with compatible materials
  54904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54905. */
  54906. export class MergeMeshesOptimization extends SceneOptimization {
  54907. private static _UpdateSelectionTree;
  54908. /**
  54909. * Gets or sets a boolean which defines if optimization octree has to be updated
  54910. */
  54911. /**
  54912. * Gets or sets a boolean which defines if optimization octree has to be updated
  54913. */
  54914. static UpdateSelectionTree: boolean;
  54915. /**
  54916. * Gets a string describing the action executed by the current optimization
  54917. * @return description string
  54918. */
  54919. getDescription(): string;
  54920. private _canBeMerged;
  54921. /**
  54922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54923. * @param scene defines the current scene where to apply this optimization
  54924. * @param optimizer defines the current optimizer
  54925. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54926. * @returns true if everything that can be done was applied
  54927. */
  54928. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54929. }
  54930. /**
  54931. * Defines a list of options used by SceneOptimizer
  54932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54933. */
  54934. export class SceneOptimizerOptions {
  54935. /**
  54936. * Defines the target frame rate to reach (60 by default)
  54937. */
  54938. targetFrameRate: number;
  54939. /**
  54940. * Defines the interval between two checkes (2000ms by default)
  54941. */
  54942. trackerDuration: number;
  54943. /**
  54944. * Gets the list of optimizations to apply
  54945. */
  54946. optimizations: SceneOptimization[];
  54947. /**
  54948. * Creates a new list of options used by SceneOptimizer
  54949. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  54950. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  54951. */
  54952. constructor(
  54953. /**
  54954. * Defines the target frame rate to reach (60 by default)
  54955. */
  54956. targetFrameRate?: number,
  54957. /**
  54958. * Defines the interval between two checkes (2000ms by default)
  54959. */
  54960. trackerDuration?: number);
  54961. /**
  54962. * Add a new optimization
  54963. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  54964. * @returns the current SceneOptimizerOptions
  54965. */
  54966. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  54967. /**
  54968. * Add a new custom optimization
  54969. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  54970. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  54971. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54972. * @returns the current SceneOptimizerOptions
  54973. */
  54974. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  54975. /**
  54976. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  54977. * @param targetFrameRate defines the target frame rate (60 by default)
  54978. * @returns a SceneOptimizerOptions object
  54979. */
  54980. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54981. /**
  54982. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  54983. * @param targetFrameRate defines the target frame rate (60 by default)
  54984. * @returns a SceneOptimizerOptions object
  54985. */
  54986. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54987. /**
  54988. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  54989. * @param targetFrameRate defines the target frame rate (60 by default)
  54990. * @returns a SceneOptimizerOptions object
  54991. */
  54992. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54993. }
  54994. /**
  54995. * Class used to run optimizations in order to reach a target frame rate
  54996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54997. */
  54998. export class SceneOptimizer implements IDisposable {
  54999. private _isRunning;
  55000. private _options;
  55001. private _scene;
  55002. private _currentPriorityLevel;
  55003. private _targetFrameRate;
  55004. private _trackerDuration;
  55005. private _currentFrameRate;
  55006. private _sceneDisposeObserver;
  55007. private _improvementMode;
  55008. /**
  55009. * Defines an observable called when the optimizer reaches the target frame rate
  55010. */
  55011. onSuccessObservable: Observable<SceneOptimizer>;
  55012. /**
  55013. * Defines an observable called when the optimizer enables an optimization
  55014. */
  55015. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55016. /**
  55017. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55018. */
  55019. onFailureObservable: Observable<SceneOptimizer>;
  55020. /**
  55021. * Gets a boolean indicating if the optimizer is in improvement mode
  55022. */
  55023. readonly isInImprovementMode: boolean;
  55024. /**
  55025. * Gets the current priority level (0 at start)
  55026. */
  55027. readonly currentPriorityLevel: number;
  55028. /**
  55029. * Gets the current frame rate checked by the SceneOptimizer
  55030. */
  55031. readonly currentFrameRate: number;
  55032. /**
  55033. * Gets or sets the current target frame rate (60 by default)
  55034. */
  55035. /**
  55036. * Gets or sets the current target frame rate (60 by default)
  55037. */
  55038. targetFrameRate: number;
  55039. /**
  55040. * Gets or sets the current interval between two checks (every 2000ms by default)
  55041. */
  55042. /**
  55043. * Gets or sets the current interval between two checks (every 2000ms by default)
  55044. */
  55045. trackerDuration: number;
  55046. /**
  55047. * Gets the list of active optimizations
  55048. */
  55049. readonly optimizations: SceneOptimization[];
  55050. /**
  55051. * Creates a new SceneOptimizer
  55052. * @param scene defines the scene to work on
  55053. * @param options defines the options to use with the SceneOptimizer
  55054. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55055. * @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)
  55056. */
  55057. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55058. /**
  55059. * Stops the current optimizer
  55060. */
  55061. stop(): void;
  55062. /**
  55063. * Reset the optimizer to initial step (current priority level = 0)
  55064. */
  55065. reset(): void;
  55066. /**
  55067. * Start the optimizer. By default it will try to reach a specific framerate
  55068. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55069. */
  55070. start(): void;
  55071. private _checkCurrentState;
  55072. /**
  55073. * Release all resources
  55074. */
  55075. dispose(): void;
  55076. /**
  55077. * Helper function to create a SceneOptimizer with one single line of code
  55078. * @param scene defines the scene to work on
  55079. * @param options defines the options to use with the SceneOptimizer
  55080. * @param onSuccess defines a callback to call on success
  55081. * @param onFailure defines a callback to call on failure
  55082. * @returns the new SceneOptimizer object
  55083. */
  55084. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55085. }
  55086. }
  55087. declare module "babylonjs/Misc/sceneSerializer" {
  55088. import { Scene } from "babylonjs/scene";
  55089. /**
  55090. * Class used to serialize a scene into a string
  55091. */
  55092. export class SceneSerializer {
  55093. /**
  55094. * Clear cache used by a previous serialization
  55095. */
  55096. static ClearCache(): void;
  55097. /**
  55098. * Serialize a scene into a JSON compatible object
  55099. * @param scene defines the scene to serialize
  55100. * @returns a JSON compatible object
  55101. */
  55102. static Serialize(scene: Scene): any;
  55103. /**
  55104. * Serialize a mesh into a JSON compatible object
  55105. * @param toSerialize defines the mesh to serialize
  55106. * @param withParents defines if parents must be serialized as well
  55107. * @param withChildren defines if children must be serialized as well
  55108. * @returns a JSON compatible object
  55109. */
  55110. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55111. }
  55112. }
  55113. declare module "babylonjs/Misc/videoRecorder" {
  55114. import { Nullable } from "babylonjs/types";
  55115. import { Engine } from "babylonjs/Engines/engine";
  55116. /**
  55117. * This represents the different options avilable for the video capture.
  55118. */
  55119. export interface VideoRecorderOptions {
  55120. /** Defines the mime type of the video */
  55121. mimeType: string;
  55122. /** Defines the video the video should be recorded at */
  55123. fps: number;
  55124. /** Defines the chunk size for the recording data */
  55125. recordChunckSize: number;
  55126. }
  55127. /**
  55128. * This can helps recording videos from BabylonJS.
  55129. * This is based on the available WebRTC functionalities of the browser.
  55130. *
  55131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55132. */
  55133. export class VideoRecorder {
  55134. private static readonly _defaultOptions;
  55135. /**
  55136. * Returns wehther or not the VideoRecorder is available in your browser.
  55137. * @param engine Defines the Babylon Engine to check the support for
  55138. * @returns true if supported otherwise false
  55139. */
  55140. static IsSupported(engine: Engine): boolean;
  55141. private readonly _options;
  55142. private _canvas;
  55143. private _mediaRecorder;
  55144. private _recordedChunks;
  55145. private _fileName;
  55146. private _resolve;
  55147. private _reject;
  55148. /**
  55149. * True wether a recording is already in progress.
  55150. */
  55151. readonly isRecording: boolean;
  55152. /**
  55153. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55154. * a video file.
  55155. * @param engine Defines the BabylonJS Engine you wish to record
  55156. * @param options Defines options that can be used to customized the capture
  55157. */
  55158. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55159. /**
  55160. * Stops the current recording before the default capture timeout passed in the startRecording
  55161. * functions.
  55162. */
  55163. stopRecording(): void;
  55164. /**
  55165. * Starts recording the canvas for a max duration specified in parameters.
  55166. * @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.
  55167. * @param maxDuration Defines the maximum recording time in seconds.
  55168. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55169. * @return a promise callback at the end of the recording with the video data in Blob.
  55170. */
  55171. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55172. /**
  55173. * Releases internal resources used during the recording.
  55174. */
  55175. dispose(): void;
  55176. private _handleDataAvailable;
  55177. private _handleError;
  55178. private _handleStop;
  55179. }
  55180. }
  55181. declare module "babylonjs/Misc/workerPool" {
  55182. import { IDisposable } from "babylonjs/scene";
  55183. /**
  55184. * Helper class to push actions to a pool of workers.
  55185. */
  55186. export class WorkerPool implements IDisposable {
  55187. private _workerInfos;
  55188. private _pendingActions;
  55189. /**
  55190. * Constructor
  55191. * @param workers Array of workers to use for actions
  55192. */
  55193. constructor(workers: Array<Worker>);
  55194. /**
  55195. * Terminates all workers and clears any pending actions.
  55196. */
  55197. dispose(): void;
  55198. /**
  55199. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55200. * pended until a worker has completed its action.
  55201. * @param action The action to perform. Call onComplete when the action is complete.
  55202. */
  55203. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55204. private _execute;
  55205. }
  55206. }
  55207. declare module "babylonjs/Misc/screenshotTools" {
  55208. import { Camera } from "babylonjs/Cameras/camera";
  55209. import { Engine } from "babylonjs/Engines/engine";
  55210. /**
  55211. * Class containing a set of static utilities functions for screenshots
  55212. */
  55213. export class ScreenshotTools {
  55214. /**
  55215. * Captures a screenshot of the current rendering
  55216. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55217. * @param engine defines the rendering engine
  55218. * @param camera defines the source camera
  55219. * @param size This parameter can be set to a single number or to an object with the
  55220. * following (optional) properties: precision, width, height. If a single number is passed,
  55221. * it will be used for both width and height. If an object is passed, the screenshot size
  55222. * will be derived from the parameters. The precision property is a multiplier allowing
  55223. * rendering at a higher or lower resolution
  55224. * @param successCallback defines the callback receives a single parameter which contains the
  55225. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55226. * src parameter of an <img> to display it
  55227. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55228. * Check your browser for supported MIME types
  55229. */
  55230. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55231. /**
  55232. * Generates an image screenshot from the specified camera.
  55233. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55234. * @param engine The engine to use for rendering
  55235. * @param camera The camera to use for rendering
  55236. * @param size This parameter can be set to a single number or to an object with the
  55237. * following (optional) properties: precision, width, height. If a single number is passed,
  55238. * it will be used for both width and height. If an object is passed, the screenshot size
  55239. * will be derived from the parameters. The precision property is a multiplier allowing
  55240. * rendering at a higher or lower resolution
  55241. * @param successCallback The callback receives a single parameter which contains the
  55242. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55243. * src parameter of an <img> to display it
  55244. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55245. * Check your browser for supported MIME types
  55246. * @param samples Texture samples (default: 1)
  55247. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55248. * @param fileName A name for for the downloaded file.
  55249. */
  55250. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55251. }
  55252. }
  55253. declare module "babylonjs/Misc/index" {
  55254. export * from "babylonjs/Misc/andOrNotEvaluator";
  55255. export * from "babylonjs/Misc/assetsManager";
  55256. export * from "babylonjs/Misc/dds";
  55257. export * from "babylonjs/Misc/decorators";
  55258. export * from "babylonjs/Misc/deferred";
  55259. export * from "babylonjs/Misc/environmentTextureTools";
  55260. export * from "babylonjs/Misc/filesInput";
  55261. export * from "babylonjs/Misc/HighDynamicRange/index";
  55262. export * from "babylonjs/Misc/khronosTextureContainer";
  55263. export * from "babylonjs/Misc/observable";
  55264. export * from "babylonjs/Misc/performanceMonitor";
  55265. export * from "babylonjs/Misc/promise";
  55266. export * from "babylonjs/Misc/sceneOptimizer";
  55267. export * from "babylonjs/Misc/sceneSerializer";
  55268. export * from "babylonjs/Misc/smartArray";
  55269. export * from "babylonjs/Misc/stringDictionary";
  55270. export * from "babylonjs/Misc/tags";
  55271. export * from "babylonjs/Misc/textureTools";
  55272. export * from "babylonjs/Misc/tga";
  55273. export * from "babylonjs/Misc/tools";
  55274. export * from "babylonjs/Misc/videoRecorder";
  55275. export * from "babylonjs/Misc/virtualJoystick";
  55276. export * from "babylonjs/Misc/workerPool";
  55277. export * from "babylonjs/Misc/logger";
  55278. export * from "babylonjs/Misc/typeStore";
  55279. export * from "babylonjs/Misc/filesInputStore";
  55280. export * from "babylonjs/Misc/deepCopier";
  55281. export * from "babylonjs/Misc/pivotTools";
  55282. export * from "babylonjs/Misc/precisionDate";
  55283. export * from "babylonjs/Misc/screenshotTools";
  55284. export * from "babylonjs/Misc/typeStore";
  55285. }
  55286. declare module "babylonjs/index" {
  55287. export * from "babylonjs/abstractScene";
  55288. export * from "babylonjs/Actions/index";
  55289. export * from "babylonjs/Animations/index";
  55290. export * from "babylonjs/assetContainer";
  55291. export * from "babylonjs/Audio/index";
  55292. export * from "babylonjs/Behaviors/index";
  55293. export * from "babylonjs/Bones/index";
  55294. export * from "babylonjs/Cameras/index";
  55295. export * from "babylonjs/Collisions/index";
  55296. export * from "babylonjs/Culling/index";
  55297. export * from "babylonjs/Debug/index";
  55298. export * from "babylonjs/Engines/index";
  55299. export * from "babylonjs/Events/index";
  55300. export * from "babylonjs/Gamepads/index";
  55301. export * from "babylonjs/Gizmos/index";
  55302. export * from "babylonjs/Helpers/index";
  55303. export * from "babylonjs/Instrumentation/index";
  55304. export * from "babylonjs/Layers/index";
  55305. export * from "babylonjs/LensFlares/index";
  55306. export * from "babylonjs/Lights/index";
  55307. export * from "babylonjs/Loading/index";
  55308. export * from "babylonjs/Materials/index";
  55309. export * from "babylonjs/Maths/index";
  55310. export * from "babylonjs/Meshes/index";
  55311. export * from "babylonjs/Morph/index";
  55312. export * from "babylonjs/node";
  55313. export * from "babylonjs/Offline/index";
  55314. export * from "babylonjs/Particles/index";
  55315. export * from "babylonjs/Physics/index";
  55316. export * from "babylonjs/PostProcesses/index";
  55317. export * from "babylonjs/Probes/index";
  55318. export * from "babylonjs/Rendering/index";
  55319. export * from "babylonjs/scene";
  55320. export * from "babylonjs/sceneComponent";
  55321. export * from "babylonjs/Sprites/index";
  55322. export * from "babylonjs/States/index";
  55323. export * from "babylonjs/Misc/index";
  55324. export * from "babylonjs/types";
  55325. }
  55326. declare module "babylonjs/Legacy/legacy" {
  55327. export * from "babylonjs/index";
  55328. }
  55329. declare module "babylonjs/Shaders/blur.fragment" {
  55330. /** @hidden */
  55331. export var blurPixelShader: {
  55332. name: string;
  55333. shader: string;
  55334. };
  55335. }
  55336. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55337. /** @hidden */
  55338. export var bones300Declaration: {
  55339. name: string;
  55340. shader: string;
  55341. };
  55342. }
  55343. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55344. /** @hidden */
  55345. export var instances300Declaration: {
  55346. name: string;
  55347. shader: string;
  55348. };
  55349. }
  55350. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55351. /** @hidden */
  55352. export var pointCloudVertexDeclaration: {
  55353. name: string;
  55354. shader: string;
  55355. };
  55356. }
  55357. // Mixins
  55358. interface Window {
  55359. mozIndexedDB: IDBFactory;
  55360. webkitIndexedDB: IDBFactory;
  55361. msIndexedDB: IDBFactory;
  55362. webkitURL: typeof URL;
  55363. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55364. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55365. WebGLRenderingContext: WebGLRenderingContext;
  55366. MSGesture: MSGesture;
  55367. CANNON: any;
  55368. AudioContext: AudioContext;
  55369. webkitAudioContext: AudioContext;
  55370. PointerEvent: any;
  55371. Math: Math;
  55372. Uint8Array: Uint8ArrayConstructor;
  55373. Float32Array: Float32ArrayConstructor;
  55374. mozURL: typeof URL;
  55375. msURL: typeof URL;
  55376. VRFrameData: any; // WebVR, from specs 1.1
  55377. DracoDecoderModule: any;
  55378. setImmediate(handler: (...args: any[]) => void): number;
  55379. }
  55380. interface Document {
  55381. mozCancelFullScreen(): void;
  55382. msCancelFullScreen(): void;
  55383. webkitCancelFullScreen(): void;
  55384. requestPointerLock(): void;
  55385. exitPointerLock(): void;
  55386. mozFullScreen: boolean;
  55387. msIsFullScreen: boolean;
  55388. readonly webkitIsFullScreen: boolean;
  55389. readonly pointerLockElement: Element;
  55390. mozPointerLockElement: HTMLElement;
  55391. msPointerLockElement: HTMLElement;
  55392. webkitPointerLockElement: HTMLElement;
  55393. }
  55394. interface HTMLCanvasElement {
  55395. requestPointerLock(): void;
  55396. msRequestPointerLock?(): void;
  55397. mozRequestPointerLock?(): void;
  55398. webkitRequestPointerLock?(): void;
  55399. /** Track wether a record is in progress */
  55400. isRecording: boolean;
  55401. /** Capture Stream method defined by some browsers */
  55402. captureStream(fps?: number): MediaStream;
  55403. }
  55404. interface CanvasRenderingContext2D {
  55405. msImageSmoothingEnabled: boolean;
  55406. }
  55407. interface MouseEvent {
  55408. mozMovementX: number;
  55409. mozMovementY: number;
  55410. webkitMovementX: number;
  55411. webkitMovementY: number;
  55412. msMovementX: number;
  55413. msMovementY: number;
  55414. }
  55415. interface Navigator {
  55416. mozGetVRDevices: (any: any) => any;
  55417. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55418. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55419. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55420. webkitGetGamepads(): Gamepad[];
  55421. msGetGamepads(): Gamepad[];
  55422. webkitGamepads(): Gamepad[];
  55423. }
  55424. interface HTMLVideoElement {
  55425. mozSrcObject: any;
  55426. }
  55427. interface Math {
  55428. fround(x: number): number;
  55429. imul(a: number, b: number): number;
  55430. }
  55431. interface WebGLProgram {
  55432. context?: WebGLRenderingContext;
  55433. vertexShader?: WebGLShader;
  55434. fragmentShader?: WebGLShader;
  55435. isParallelCompiled: boolean;
  55436. onCompiled?: () => void;
  55437. }
  55438. interface WebGLRenderingContext {
  55439. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55440. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55441. vertexAttribDivisor(index: number, divisor: number): void;
  55442. createVertexArray(): any;
  55443. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55444. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55445. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55446. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55447. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55448. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55449. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55450. // Queries
  55451. createQuery(): WebGLQuery;
  55452. deleteQuery(query: WebGLQuery): void;
  55453. beginQuery(target: number, query: WebGLQuery): void;
  55454. endQuery(target: number): void;
  55455. getQueryParameter(query: WebGLQuery, pname: number): any;
  55456. getQuery(target: number, pname: number): any;
  55457. MAX_SAMPLES: number;
  55458. RGBA8: number;
  55459. READ_FRAMEBUFFER: number;
  55460. DRAW_FRAMEBUFFER: number;
  55461. UNIFORM_BUFFER: number;
  55462. HALF_FLOAT_OES: number;
  55463. RGBA16F: number;
  55464. RGBA32F: number;
  55465. R32F: number;
  55466. RG32F: number;
  55467. RGB32F: number;
  55468. R16F: number;
  55469. RG16F: number;
  55470. RGB16F: number;
  55471. RED: number;
  55472. RG: number;
  55473. R8: number;
  55474. RG8: number;
  55475. UNSIGNED_INT_24_8: number;
  55476. DEPTH24_STENCIL8: number;
  55477. /* Multiple Render Targets */
  55478. drawBuffers(buffers: number[]): void;
  55479. readBuffer(src: number): void;
  55480. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55481. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55482. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55483. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55484. // Occlusion Query
  55485. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55486. ANY_SAMPLES_PASSED: number;
  55487. QUERY_RESULT_AVAILABLE: number;
  55488. QUERY_RESULT: number;
  55489. }
  55490. interface WebGLBuffer {
  55491. references: number;
  55492. capacity: number;
  55493. is32Bits: boolean;
  55494. }
  55495. interface WebGLProgram {
  55496. transformFeedback?: WebGLTransformFeedback | null;
  55497. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55498. }
  55499. interface EXT_disjoint_timer_query {
  55500. QUERY_COUNTER_BITS_EXT: number;
  55501. TIME_ELAPSED_EXT: number;
  55502. TIMESTAMP_EXT: number;
  55503. GPU_DISJOINT_EXT: number;
  55504. QUERY_RESULT_EXT: number;
  55505. QUERY_RESULT_AVAILABLE_EXT: number;
  55506. queryCounterEXT(query: WebGLQuery, target: number): void;
  55507. createQueryEXT(): WebGLQuery;
  55508. beginQueryEXT(target: number, query: WebGLQuery): void;
  55509. endQueryEXT(target: number): void;
  55510. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55511. deleteQueryEXT(query: WebGLQuery): void;
  55512. }
  55513. interface WebGLUniformLocation {
  55514. _currentState: any;
  55515. }
  55516. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55517. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55518. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55519. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55520. interface WebGLRenderingContext {
  55521. readonly RASTERIZER_DISCARD: number;
  55522. readonly DEPTH_COMPONENT24: number;
  55523. readonly TEXTURE_3D: number;
  55524. readonly TEXTURE_2D_ARRAY: number;
  55525. readonly TEXTURE_COMPARE_FUNC: number;
  55526. readonly TEXTURE_COMPARE_MODE: number;
  55527. readonly COMPARE_REF_TO_TEXTURE: number;
  55528. readonly TEXTURE_WRAP_R: number;
  55529. readonly HALF_FLOAT: number;
  55530. readonly RGB8: number;
  55531. readonly RED_INTEGER: number;
  55532. readonly RG_INTEGER: number;
  55533. readonly RGB_INTEGER: number;
  55534. readonly RGBA_INTEGER: number;
  55535. readonly R8_SNORM: number;
  55536. readonly RG8_SNORM: number;
  55537. readonly RGB8_SNORM: number;
  55538. readonly RGBA8_SNORM: number;
  55539. readonly R8I: number;
  55540. readonly RG8I: number;
  55541. readonly RGB8I: number;
  55542. readonly RGBA8I: number;
  55543. readonly R8UI: number;
  55544. readonly RG8UI: number;
  55545. readonly RGB8UI: number;
  55546. readonly RGBA8UI: number;
  55547. readonly R16I: number;
  55548. readonly RG16I: number;
  55549. readonly RGB16I: number;
  55550. readonly RGBA16I: number;
  55551. readonly R16UI: number;
  55552. readonly RG16UI: number;
  55553. readonly RGB16UI: number;
  55554. readonly RGBA16UI: number;
  55555. readonly R32I: number;
  55556. readonly RG32I: number;
  55557. readonly RGB32I: number;
  55558. readonly RGBA32I: number;
  55559. readonly R32UI: number;
  55560. readonly RG32UI: number;
  55561. readonly RGB32UI: number;
  55562. readonly RGBA32UI: number;
  55563. readonly RGB10_A2UI: number;
  55564. readonly R11F_G11F_B10F: number;
  55565. readonly RGB9_E5: number;
  55566. readonly RGB10_A2: number;
  55567. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55568. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55569. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55570. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55571. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55572. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55573. 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;
  55574. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55575. readonly TRANSFORM_FEEDBACK: number;
  55576. readonly INTERLEAVED_ATTRIBS: number;
  55577. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55578. createTransformFeedback(): WebGLTransformFeedback;
  55579. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55580. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55581. beginTransformFeedback(primitiveMode: number): void;
  55582. endTransformFeedback(): void;
  55583. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55584. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55585. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55586. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55587. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55588. }
  55589. interface ImageBitmap {
  55590. readonly width: number;
  55591. readonly height: number;
  55592. close(): void;
  55593. }
  55594. interface WebGLQuery extends WebGLObject {
  55595. }
  55596. declare var WebGLQuery: {
  55597. prototype: WebGLQuery;
  55598. new(): WebGLQuery;
  55599. };
  55600. interface WebGLSampler extends WebGLObject {
  55601. }
  55602. declare var WebGLSampler: {
  55603. prototype: WebGLSampler;
  55604. new(): WebGLSampler;
  55605. };
  55606. interface WebGLSync extends WebGLObject {
  55607. }
  55608. declare var WebGLSync: {
  55609. prototype: WebGLSync;
  55610. new(): WebGLSync;
  55611. };
  55612. interface WebGLTransformFeedback extends WebGLObject {
  55613. }
  55614. declare var WebGLTransformFeedback: {
  55615. prototype: WebGLTransformFeedback;
  55616. new(): WebGLTransformFeedback;
  55617. };
  55618. interface WebGLVertexArrayObject extends WebGLObject {
  55619. }
  55620. declare var WebGLVertexArrayObject: {
  55621. prototype: WebGLVertexArrayObject;
  55622. new(): WebGLVertexArrayObject;
  55623. };
  55624. // Type definitions for WebVR API
  55625. // Project: https://w3c.github.io/webvr/
  55626. // Definitions by: six a <https://github.com/lostfictions>
  55627. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55628. interface VRDisplay extends EventTarget {
  55629. /**
  55630. * Dictionary of capabilities describing the VRDisplay.
  55631. */
  55632. readonly capabilities: VRDisplayCapabilities;
  55633. /**
  55634. * z-depth defining the far plane of the eye view frustum
  55635. * enables mapping of values in the render target depth
  55636. * attachment to scene coordinates. Initially set to 10000.0.
  55637. */
  55638. depthFar: number;
  55639. /**
  55640. * z-depth defining the near plane of the eye view frustum
  55641. * enables mapping of values in the render target depth
  55642. * attachment to scene coordinates. Initially set to 0.01.
  55643. */
  55644. depthNear: number;
  55645. /**
  55646. * An identifier for this distinct VRDisplay. Used as an
  55647. * association point in the Gamepad API.
  55648. */
  55649. readonly displayId: number;
  55650. /**
  55651. * A display name, a user-readable name identifying it.
  55652. */
  55653. readonly displayName: string;
  55654. readonly isConnected: boolean;
  55655. readonly isPresenting: boolean;
  55656. /**
  55657. * If this VRDisplay supports room-scale experiences, the optional
  55658. * stage attribute contains details on the room-scale parameters.
  55659. */
  55660. readonly stageParameters: VRStageParameters | null;
  55661. /**
  55662. * Passing the value returned by `requestAnimationFrame` to
  55663. * `cancelAnimationFrame` will unregister the callback.
  55664. * @param handle Define the hanle of the request to cancel
  55665. */
  55666. cancelAnimationFrame(handle: number): void;
  55667. /**
  55668. * Stops presenting to the VRDisplay.
  55669. * @returns a promise to know when it stopped
  55670. */
  55671. exitPresent(): Promise<void>;
  55672. /**
  55673. * Return the current VREyeParameters for the given eye.
  55674. * @param whichEye Define the eye we want the parameter for
  55675. * @returns the eye parameters
  55676. */
  55677. getEyeParameters(whichEye: string): VREyeParameters;
  55678. /**
  55679. * Populates the passed VRFrameData with the information required to render
  55680. * the current frame.
  55681. * @param frameData Define the data structure to populate
  55682. * @returns true if ok otherwise false
  55683. */
  55684. getFrameData(frameData: VRFrameData): boolean;
  55685. /**
  55686. * Get the layers currently being presented.
  55687. * @returns the list of VR layers
  55688. */
  55689. getLayers(): VRLayer[];
  55690. /**
  55691. * Return a VRPose containing the future predicted pose of the VRDisplay
  55692. * when the current frame will be presented. The value returned will not
  55693. * change until JavaScript has returned control to the browser.
  55694. *
  55695. * The VRPose will contain the position, orientation, velocity,
  55696. * and acceleration of each of these properties.
  55697. * @returns the pose object
  55698. */
  55699. getPose(): VRPose;
  55700. /**
  55701. * Return the current instantaneous pose of the VRDisplay, with no
  55702. * prediction applied.
  55703. * @returns the current instantaneous pose
  55704. */
  55705. getImmediatePose(): VRPose;
  55706. /**
  55707. * The callback passed to `requestAnimationFrame` will be called
  55708. * any time a new frame should be rendered. When the VRDisplay is
  55709. * presenting the callback will be called at the native refresh
  55710. * rate of the HMD. When not presenting this function acts
  55711. * identically to how window.requestAnimationFrame acts. Content should
  55712. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55713. * asynchronously from other displays and at differing refresh rates.
  55714. * @param callback Define the eaction to run next frame
  55715. * @returns the request handle it
  55716. */
  55717. requestAnimationFrame(callback: FrameRequestCallback): number;
  55718. /**
  55719. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55720. * Repeat calls while already presenting will update the VRLayers being displayed.
  55721. * @param layers Define the list of layer to present
  55722. * @returns a promise to know when the request has been fulfilled
  55723. */
  55724. requestPresent(layers: VRLayer[]): Promise<void>;
  55725. /**
  55726. * Reset the pose for this display, treating its current position and
  55727. * orientation as the "origin/zero" values. VRPose.position,
  55728. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55729. * updated when calling resetPose(). This should be called in only
  55730. * sitting-space experiences.
  55731. */
  55732. resetPose(): void;
  55733. /**
  55734. * The VRLayer provided to the VRDisplay will be captured and presented
  55735. * in the HMD. Calling this function has the same effect on the source
  55736. * canvas as any other operation that uses its source image, and canvases
  55737. * created without preserveDrawingBuffer set to true will be cleared.
  55738. * @param pose Define the pose to submit
  55739. */
  55740. submitFrame(pose?: VRPose): void;
  55741. }
  55742. declare var VRDisplay: {
  55743. prototype: VRDisplay;
  55744. new(): VRDisplay;
  55745. };
  55746. interface VRLayer {
  55747. leftBounds?: number[] | Float32Array | null;
  55748. rightBounds?: number[] | Float32Array | null;
  55749. source?: HTMLCanvasElement | null;
  55750. }
  55751. interface VRDisplayCapabilities {
  55752. readonly canPresent: boolean;
  55753. readonly hasExternalDisplay: boolean;
  55754. readonly hasOrientation: boolean;
  55755. readonly hasPosition: boolean;
  55756. readonly maxLayers: number;
  55757. }
  55758. interface VREyeParameters {
  55759. /** @deprecated */
  55760. readonly fieldOfView: VRFieldOfView;
  55761. readonly offset: Float32Array;
  55762. readonly renderHeight: number;
  55763. readonly renderWidth: number;
  55764. }
  55765. interface VRFieldOfView {
  55766. readonly downDegrees: number;
  55767. readonly leftDegrees: number;
  55768. readonly rightDegrees: number;
  55769. readonly upDegrees: number;
  55770. }
  55771. interface VRFrameData {
  55772. readonly leftProjectionMatrix: Float32Array;
  55773. readonly leftViewMatrix: Float32Array;
  55774. readonly pose: VRPose;
  55775. readonly rightProjectionMatrix: Float32Array;
  55776. readonly rightViewMatrix: Float32Array;
  55777. readonly timestamp: number;
  55778. }
  55779. interface VRPose {
  55780. readonly angularAcceleration: Float32Array | null;
  55781. readonly angularVelocity: Float32Array | null;
  55782. readonly linearAcceleration: Float32Array | null;
  55783. readonly linearVelocity: Float32Array | null;
  55784. readonly orientation: Float32Array | null;
  55785. readonly position: Float32Array | null;
  55786. readonly timestamp: number;
  55787. }
  55788. interface VRStageParameters {
  55789. sittingToStandingTransform?: Float32Array;
  55790. sizeX?: number;
  55791. sizeY?: number;
  55792. }
  55793. interface Navigator {
  55794. getVRDisplays(): Promise<VRDisplay[]>;
  55795. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55796. }
  55797. interface Window {
  55798. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55799. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55800. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55801. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55802. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55803. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55804. }
  55805. interface Gamepad {
  55806. readonly displayId: number;
  55807. }
  55808. interface XRDevice {
  55809. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55810. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55811. }
  55812. interface XRSession {
  55813. getInputSources(): Array<any>;
  55814. baseLayer: XRWebGLLayer;
  55815. requestFrameOfReference(type: string): Promise<void>;
  55816. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55817. end(): Promise<void>;
  55818. requestAnimationFrame: Function;
  55819. addEventListener: Function;
  55820. }
  55821. interface XRSessionCreationOptions {
  55822. outputContext?: WebGLRenderingContext | null;
  55823. immersive?: boolean;
  55824. environmentIntegration?: boolean;
  55825. }
  55826. interface XRLayer {
  55827. getViewport: Function;
  55828. framebufferWidth: number;
  55829. framebufferHeight: number;
  55830. }
  55831. interface XRView {
  55832. projectionMatrix: Float32Array;
  55833. }
  55834. interface XRFrame {
  55835. getDevicePose: Function;
  55836. getInputPose: Function;
  55837. views: Array<XRView>;
  55838. baseLayer: XRLayer;
  55839. }
  55840. interface XRFrameOfReference {
  55841. }
  55842. interface XRWebGLLayer extends XRLayer {
  55843. framebuffer: WebGLFramebuffer;
  55844. }
  55845. declare var XRWebGLLayer: {
  55846. prototype: XRWebGLLayer;
  55847. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55848. };
  55849. declare module "babylonjs" {
  55850. export * from "babylonjs/Legacy/legacy";
  55851. }